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