|
|
|
@ -144,91 +144,75 @@ task 'gem:native', [:plat] do |t, args| |
|
|
|
|
verbose = ENV['V'] || '0' |
|
|
|
|
|
|
|
|
|
grpc_config = ENV['GRPC_CONFIG'] || 'opt' |
|
|
|
|
ruby_cc_versions = ['3.1.0', '3.0.0', '2.7.0', '2.6.0'].join(':') |
|
|
|
|
ruby_cc_versions = ['3.2.0', '3.1.0', '3.0.0', '2.7.0'].join(':') |
|
|
|
|
selected_plat = "#{args[:plat]}" |
|
|
|
|
|
|
|
|
|
if RUBY_PLATFORM =~ /darwin/ |
|
|
|
|
if !selected_plat.empty? && selected_plat != 'darwin' |
|
|
|
|
fail "Cannot pass platform as an argument when on Darwin." |
|
|
|
|
end |
|
|
|
|
# use env variable to set artifact build paralellism |
|
|
|
|
nproc_override = ENV['GRPC_RUBY_BUILD_PROCS'] || `nproc`.strip |
|
|
|
|
|
|
|
|
|
FileUtils.touch 'grpc_c.32-msvcrt.ruby' |
|
|
|
|
FileUtils.touch 'grpc_c.64-msvcrt.ruby' |
|
|
|
|
FileUtils.touch 'grpc_c.64-ucrt.ruby' |
|
|
|
|
unless '2.5' == /(\d+\.\d+)/.match(RUBY_VERSION).to_s |
|
|
|
|
fail "rake gem:native (the rake task to build the binary packages) is being " \ |
|
|
|
|
"invoked on macos with ruby #{RUBY_VERSION}. The ruby macos artifact " \ |
|
|
|
|
"build should be running on ruby 2.5." |
|
|
|
|
end |
|
|
|
|
system "bundle exec rake cross native gem RUBY_CC_VERSION=#{ruby_cc_versions} V=#{verbose} GRPC_CONFIG=#{grpc_config}" |
|
|
|
|
# propagate env variables with ccache configuration to the rake-compiler-dock docker container |
|
|
|
|
# and setup ccache symlinks as needed. |
|
|
|
|
prepare_ccache_cmd = "export GRPC_BUILD_ENABLE_CCACHE=\"#{ENV.fetch('GRPC_BUILD_ENABLE_CCACHE', '')}\" && " |
|
|
|
|
prepare_ccache_cmd += "export CCACHE_SECONDARY_STORAGE=\"#{ENV.fetch('CCACHE_SECONDARY_STORAGE', '')}\" && " |
|
|
|
|
prepare_ccache_cmd += "export PATH=\"$PATH:/usr/local/bin\" && " |
|
|
|
|
prepare_ccache_cmd += "source tools/internal_ci/helper_scripts/prepare_ccache_symlinks_rc " |
|
|
|
|
|
|
|
|
|
supported_windows_platforms = ['x86-mingw32', 'x64-mingw32', 'x64-mingw-ucrt'] |
|
|
|
|
supported_unix_platforms = ['x86_64-linux', 'x86-linux', 'x86_64-darwin', 'arm64-darwin'] |
|
|
|
|
supported_platforms = supported_windows_platforms + supported_unix_platforms |
|
|
|
|
|
|
|
|
|
if selected_plat.empty? |
|
|
|
|
# build everything |
|
|
|
|
windows_platforms = supported_windows_platforms |
|
|
|
|
unix_platforms = supported_unix_platforms |
|
|
|
|
else |
|
|
|
|
# use env variable to set artifact build paralellism |
|
|
|
|
nproc_override = ENV['GRPC_RUBY_BUILD_PROCS'] || `nproc`.strip |
|
|
|
|
|
|
|
|
|
# propagate env variables with ccache configuration to the rake-compiler-dock docker container |
|
|
|
|
# and setup ccache symlinks as needed. |
|
|
|
|
prepare_ccache_cmd = "export GRPC_BUILD_ENABLE_CCACHE=\"#{ENV.fetch('GRPC_BUILD_ENABLE_CCACHE', '')}\" && " |
|
|
|
|
prepare_ccache_cmd += "export CCACHE_SECONDARY_STORAGE=\"#{ENV.fetch('CCACHE_SECONDARY_STORAGE', '')}\" && " |
|
|
|
|
prepare_ccache_cmd += "export PATH=\"$PATH:/usr/local/bin\" && " |
|
|
|
|
prepare_ccache_cmd += "source tools/internal_ci/helper_scripts/prepare_ccache_symlinks_rc " |
|
|
|
|
|
|
|
|
|
supported_windows_platforms = ['x86-mingw32', 'x64-mingw32', 'x64-mingw-ucrt'] |
|
|
|
|
supported_unix_platforms = ['x86_64-linux', 'x86-linux', 'x86_64-darwin', 'arm64-darwin'] |
|
|
|
|
supported_platforms = supported_windows_platforms + supported_unix_platforms |
|
|
|
|
|
|
|
|
|
if selected_plat.empty? |
|
|
|
|
# build everything |
|
|
|
|
windows_platforms = supported_windows_platforms |
|
|
|
|
unix_platforms = supported_unix_platforms |
|
|
|
|
# build only selected platform |
|
|
|
|
if supported_windows_platforms.include?(selected_plat) |
|
|
|
|
windows_platforms = [selected_plat] |
|
|
|
|
unix_platforms = [] |
|
|
|
|
elsif supported_unix_platforms.include?(selected_plat) |
|
|
|
|
windows_platforms = [] |
|
|
|
|
unix_platforms = [selected_plat] |
|
|
|
|
else |
|
|
|
|
# build only selected platform |
|
|
|
|
if supported_windows_platforms.include?(selected_plat) |
|
|
|
|
windows_platforms = [selected_plat] |
|
|
|
|
unix_platforms = [] |
|
|
|
|
elsif supported_unix_platforms.include?(selected_plat) |
|
|
|
|
windows_platforms = [] |
|
|
|
|
unix_platforms = [selected_plat] |
|
|
|
|
else |
|
|
|
|
fail "Unsupported platform '#{selected_plat}' passed as an argument." |
|
|
|
|
end |
|
|
|
|
fail "Unsupported platform '#{selected_plat}' passed as an argument." |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Create the windows dlls or create the empty placeholders |
|
|
|
|
Rake::Task['dlls'].execute(plat: windows_platforms) |
|
|
|
|
|
|
|
|
|
windows_platforms.each do |plat| |
|
|
|
|
run_rake_compiler(plat, <<~EOT) |
|
|
|
|
#{prepare_ccache_cmd} && \ |
|
|
|
|
gem update --system --no-document && \ |
|
|
|
|
bundle && \ |
|
|
|
|
bundle exec rake clean && \ |
|
|
|
|
bundle exec rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem pkg/#{spec.full_name}.gem \ |
|
|
|
|
RUBY_CC_VERSION=#{ruby_cc_versions} \ |
|
|
|
|
V=#{verbose} \ |
|
|
|
|
GRPC_CONFIG=#{grpc_config} \ |
|
|
|
|
GRPC_RUBY_BUILD_PROCS=#{nproc_override} |
|
|
|
|
EOT |
|
|
|
|
end |
|
|
|
|
# Create the windows dlls or create the empty placeholders |
|
|
|
|
Rake::Task['dlls'].execute(plat: windows_platforms) |
|
|
|
|
|
|
|
|
|
# Truncate grpc_c.*.ruby files because they're for Windows only and we don't want |
|
|
|
|
# them to take up space in the gems that don't target windows. |
|
|
|
|
File.truncate('grpc_c.32-msvcrt.ruby', 0) |
|
|
|
|
File.truncate('grpc_c.64-msvcrt.ruby', 0) |
|
|
|
|
File.truncate('grpc_c.64-ucrt.ruby', 0) |
|
|
|
|
|
|
|
|
|
unix_platforms.each do |plat| |
|
|
|
|
run_rake_compiler(plat, <<~EOT) |
|
|
|
|
#{prepare_ccache_cmd} && \ |
|
|
|
|
gem update --system --no-document && \ |
|
|
|
|
bundle && \ |
|
|
|
|
bundle exec rake clean && \ |
|
|
|
|
bundle exec rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem pkg/#{spec.full_name}.gem \ |
|
|
|
|
RUBY_CC_VERSION=#{ruby_cc_versions} \ |
|
|
|
|
V=#{verbose} \ |
|
|
|
|
GRPC_CONFIG=#{grpc_config} \ |
|
|
|
|
GRPC_RUBY_BUILD_PROCS=#{nproc_override} |
|
|
|
|
EOT |
|
|
|
|
end |
|
|
|
|
windows_platforms.each do |plat| |
|
|
|
|
run_rake_compiler(plat, <<~EOT) |
|
|
|
|
#{prepare_ccache_cmd} && \ |
|
|
|
|
gem update --system --no-document && \ |
|
|
|
|
bundle && \ |
|
|
|
|
bundle exec rake clean && \ |
|
|
|
|
bundle exec rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem pkg/#{spec.full_name}.gem \ |
|
|
|
|
RUBY_CC_VERSION=#{ruby_cc_versions} \ |
|
|
|
|
V=#{verbose} \ |
|
|
|
|
GRPC_CONFIG=#{grpc_config} \ |
|
|
|
|
GRPC_RUBY_BUILD_PROCS=#{nproc_override} |
|
|
|
|
EOT |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
# Truncate grpc_c.*.ruby files because they're for Windows only and we don't want |
|
|
|
|
# them to take up space in the gems that don't target windows. |
|
|
|
|
File.truncate('grpc_c.32-msvcrt.ruby', 0) |
|
|
|
|
File.truncate('grpc_c.64-msvcrt.ruby', 0) |
|
|
|
|
File.truncate('grpc_c.64-ucrt.ruby', 0) |
|
|
|
|
|
|
|
|
|
unix_platforms.each do |plat| |
|
|
|
|
run_rake_compiler(plat, <<~EOT) |
|
|
|
|
#{prepare_ccache_cmd} && \ |
|
|
|
|
gem update --system --no-document && \ |
|
|
|
|
bundle && \ |
|
|
|
|
bundle exec rake clean && \ |
|
|
|
|
bundle exec rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem pkg/#{spec.full_name}.gem \ |
|
|
|
|
RUBY_CC_VERSION=#{ruby_cc_versions} \ |
|
|
|
|
V=#{verbose} \ |
|
|
|
|
GRPC_CONFIG=#{grpc_config} \ |
|
|
|
|
GRPC_RUBY_BUILD_PROCS=#{nproc_override} |
|
|
|
|
EOT |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|