Skip to content

Commit

Permalink
(PA-4774) Enable macOS 13 for agent-runtime main
Browse files Browse the repository at this point in the history
  • Loading branch information
shubhamshinde360 committed Jun 22, 2023
1 parent 1a77733 commit d8a59d5
Show file tree
Hide file tree
Showing 11 changed files with 51 additions and 13 deletions.
5 changes: 3 additions & 2 deletions configs/components/_base-ruby-augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
pkg.build_requires "ruby-#{ruby_version}"
pkg.build_requires "augeas"

pkg.environment "PATH", "$(PATH):/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
pkg.environment "PATH", "$(PATH):/opt/homebrew/bin:/opt/pl-build-tools/bin:/usr/local/bin:/opt/csw/bin:/usr/ccs/bin:/usr/sfw/bin"
if platform.is_aix?
if platform.name == 'aix-7.1-ppc'
pkg.environment "CC", "/opt/pl-build-tools/bin/gcc"
Expand All @@ -40,11 +40,12 @@
pkg.environment "RUBY", host_ruby
end
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
elsif platform.is_cross_compiled?
elsif platform.architecture == 'arm64'
if platform.is_linux? || platform.is_macos?
pkg.environment "RUBY", host_ruby
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/
ruby = "#{host_ruby} -r#{settings[:datadir]}/doc/rbconfig-#{ruby_version}-orig.rb"
pkg.environment "LDFLAGS", settings[:ldflags]
end
Expand Down
3 changes: 2 additions & 1 deletion configs/components/_base-ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
pkg.environment 'optflags', settings[:cflags] + ' -O3'
elsif platform.is_macos?
pkg.environment 'optflags', settings[:cflags]
if platform.is_cross_compiled?
if platform.architecture == 'arm64'
# Pin to an older version of ruby@2.5. This can be removed once we're no longer cross-compiling
if ruby_version_y == "2.5"
pkg.build_requires "puppetlabs/puppet/ruby@2.5"
Expand All @@ -59,6 +59,7 @@
end
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/
end
end

Expand Down
14 changes: 11 additions & 3 deletions configs/components/augeas.rb
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,14 @@
pkg.environment "PKG_CONFIG", "/opt/pl-build-tools/bin/pkg-config"
end
elsif platform.is_macos?
pkg.environment "PATH", "$(PATH):/usr/local/bin"
pkg.environment "PATH", "$(PATH):/usr/local/bin:/opt/homebrew/bin"
pkg.environment 'CFLAGS', settings[:cflags]
pkg.environment 'CPPFLAGS', settings[:cppflags]
pkg.environment "LDFLAGS", settings[:ldflags]
if platform.is_cross_compiled?
if platform.architecture == 'arm64'
pkg.environment 'CC', 'clang -target arm64-apple-macos11' if platform.name =~ /osx-11/
pkg.environment 'CC', 'clang -target arm64-apple-macos12' if platform.name =~ /osx-12/
pkg.environment 'CC', 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/
end
end

Expand All @@ -120,7 +121,14 @@
end

# fix libtool linking on big sur
pkg.configure { ["/usr/local/bin/autoreconf --force --install"] } if platform.is_macos?
if platform.is_macos?
if(platform.os_version.to_i >= 13 && platform.architecture == 'arm64')
pkg.configure { ["/opt/homebrew/bin/autoreconf --force --install"] }
else
pkg.configure { ["/usr/local/bin/autoreconf --force --install"] }
end
end


pkg.configure do
["./configure #{extra_config_flags} --prefix=#{settings[:prefix]} #{settings[:host]}"]
Expand Down
2 changes: 2 additions & 0 deletions configs/components/boost.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@
'clang++ -target arm64-apple-macos11'
elsif platform.is_cross_compiled? && platform.name =~ /osx-12/
'clang++ -target arm64-apple-macos12'
elsif platform.name =~ /osx-13/
'clang++ -target arm64-apple-macos13'
else
'clang++'
end
Expand Down
3 changes: 2 additions & 1 deletion configs/components/curl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@
configure_options << "--with-ssl=#{settings[:prefix]}"

extra_cflags = []
if platform.is_cross_compiled? && platform.is_macos?
if platform.architecture == 'arm64' && platform.is_macos?
extra_cflags << '-mmacosx-version-min=11.0 -arch arm64' if platform.name =~ /osx-11/
extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-12/
extra_cflags << '-mmacosx-version-min=12.0 -arch arm64' if platform.name =~ /osx-13/
end

if (platform.is_solaris? && platform.os_version == "11") || platform.is_aix?
Expand Down
4 changes: 3 additions & 1 deletion configs/components/openssl-1.1.1.rb
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,9 @@
pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin'

cflags = settings[:cflags]
target = if platform.is_cross_compiled?
puts "HEY, #{platform.is_cross_compiled?}"
puts "platform.name = #{platform.name} $##############################"
target = if platform.is_cross_compiled? or
'darwin64-arm64-cc'
else
'darwin64-x86_64-cc'
Expand Down
9 changes: 7 additions & 2 deletions configs/components/openssl-3.0.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,14 @@
# ldflags = "-R/opt/pl-build-tools/#{settings[:platform_triple]}/lib -Wl,-rpath=#{settings[:libdir]} -L/opt/pl-build-tools/#{settings[:platform_triple]}/lib"
# target = platform.architecture =~ /86/ ? 'solaris-x86-gcc' : 'solaris-sparcv9-gcc'
elsif platform.is_macos?
pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin'

target = if platform.is_cross_compiled?
if platform.os_version.to_i >= 13 && platform.architecture == 'arm64'
pkg.environment 'PATH', '$(PATH):/opt/homebrew/bin:/usr/local/bin'
else
pkg.environment 'PATH', '/opt/pl-build-tools/bin:$(PATH):/usr/local/bin'
end

target = if platform.architecture == "arm64"
'darwin64-arm64'
else
'darwin64-x86_64'
Expand Down
6 changes: 5 additions & 1 deletion configs/components/ruby-3.2.2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@

if platform.is_macos?
pkg.environment 'optflags', settings[:cflags]
pkg.environment 'PATH', '$(PATH):/usr/local/bin'
pkg.environment 'PATH', '/opt/homebrew/bin:$(PATH):/usr/local/bin'

elsif platform.is_windows?
pkg.environment 'optflags', settings[:cflags] + ' -O3'
pkg.environment 'MAKE', 'make'
Expand Down Expand Up @@ -215,6 +216,9 @@
end

rbconfig_changes = {}
if platform.is_macos? && platform.os_version.to_i >= 13
rbconfig_changes["CC"] = 'clang -target arm64-apple-macos13' if platform.name =~ /osx-13/
end
if platform.is_aix?
rbconfig_changes["CC"] = "gcc"
elsif platform.is_cross_compiled? || platform.is_solaris?
Expand Down
7 changes: 6 additions & 1 deletion configs/components/yaml-cpp.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,14 @@
elsif platform.is_macos?
cmake_toolchain_file = ""
cmake = "/usr/local/bin/cmake"
if platform.is_cross_compiled?
pkg.environment "PATH", "$(PATH):/opt/csw/bin"
if platform.architecture == 'arm64'
pkg.environment 'CXX', 'clang++ -target arm64-apple-macos11' if platform.name =~ /osx-11/
pkg.environment 'CXX', 'clang++ -target arm64-apple-macos12' if platform.name =~ /osx-12/
pkg.environment 'CXX', 'clang++ -target arm64-apple-macos13' if platform.name =~ /osx-13/
if(platform.architecture == "arm64" and platform.os_version.to_i >= 13)
cmake = "/opt/homebrew/bin/cmake"
end
end
elsif platform.is_windows?
make = "#{settings[:gcc_bindir]}/mingw32-make"
Expand Down
9 changes: 9 additions & 0 deletions configs/platforms/osx-13-arm64.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
platform 'osx-13-arm64' do |plat|
plat.inherit_from_default

packages = %w[automake cmake pkg-config yaml-cpp]
plat.provision_with "su test -c '/opt/homebrew/bin/brew install #{packages.join(' ')}'"

plat.output_dir File.join('apple', '13', 'PC1', 'arm64')
end

2 changes: 1 addition & 1 deletion configs/projects/_shared-agent-settings.rb
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@
# break gcc or clang if they try to use the RPATH values we forced.
proj.setting(:cppflags, "-I#{proj.includedir}")
proj.setting(:ldflags, "-L#{proj.libdir}")
if platform.is_cross_compiled?
if platform.architecture == 'arm64'
proj.setting(:cflags, "#{proj.cppflags}")
else
proj.setting(:cflags, "-march=core2 -msse4 #{proj.cppflags}")
Expand Down

0 comments on commit d8a59d5

Please sign in to comment.