Skip to content

Commit

Permalink
refactor: darwin native rake tasks follow convention
Browse files Browse the repository at this point in the history
That is, darwin tasks now mirror the linux and windows tasks even
though there's no guest container (only a child process). This way we
avoid having darwin-specific handling from the POV of the person
invoking rake.

The native platform tasks previously named "guest" are now named
"builder" because that's a more descriptive and more accurate name,
especially since (on darwin) there's no actual guest.
  • Loading branch information
flavorjones committed Dec 3, 2020
1 parent 17c84fc commit 440dc4e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 15 deletions.
2 changes: 1 addition & 1 deletion concourse/tasks/gem-test/gem-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ bundle install --local || bundle install
bundle exec rake set-version-to-timestamp

if [ -n "${BUILD_NATIVE_GEM:-}" ] ; then
bundle exec rake gem:x86_64-linux:guest FORCE_CROSS_COMPILING=true
bundle exec rake gem:x86_64-linux:builder FORCE_CROSS_COMPILING=true
else
# TODO we're only compiling so that we retrieve libxml2/libxslt
# tarballs, we can do better a couple of different ways
Expand Down
40 changes: 26 additions & 14 deletions rakelib/cross-ruby.rake
Original file line number Diff line number Diff line change
Expand Up @@ -237,37 +237,49 @@ CROSS_RUBIES.each do |cross_ruby|
end

namespace "gem" do
def gem_builder(plat)
# use Task#invoke because the pkg/*gem task is defined at runtime
Rake::Task["native:#{plat}"].invoke
Rake::Task["pkg/#{HOE.spec.full_name}-#{Gem::Platform.new(plat).to_s}.gem"].invoke
end

CROSS_RUBIES.find_all { |cr| cr.windows? || cr.linux? }.map(&:platform).uniq.each do |plat|
desc "build native gem for #{plat} platform (host)"
desc "build native gem for #{plat} platform"
task plat do
RakeCompilerDock.sh <<~EOT, platform: plat
gem install bundler --no-document &&
bundle &&
rake gem:#{plat}:guest MAKE='nice make -j`nproc`' FORCE_CROSS_COMPILING=true
rake gem:#{plat}:builder MAKE='nice make -j`nproc`' FORCE_CROSS_COMPILING=true
EOT
end

namespace plat do
desc "build native gem for #{plat} platform (guest)"
task "guest" do
# use Task#invoke because the pkg/*gem task is defined at runtime
Rake::Task["native:#{plat}"].invoke
Rake::Task["pkg/#{HOE.spec.full_name}-#{Gem::Platform.new(plat).to_s}.gem"].invoke
desc "build native gem for #{plat} platform (guest container)"
task "builder" do
gem_builder(plat)
end
task "guest" => "builder" # TODO: remove me after this code is on master, temporary backwards compat for CI
end
end

desc "build a jruby gem"
task "jruby" do
RakeCompilerDock.sh "gem install bundler --no-document && bundle && rake java gem", rubyvm: "jruby"
end

CROSS_RUBIES.find_all { |cr| cr.darwin? }.map(&:platform).uniq.each do |plat|
desc "build native gem for #{plat} platform"
task plat do
Rake::Task["native:#{plat}"].invoke
Rake::Task["pkg/#{HOE.spec.full_name}-#{Gem::Platform.new(plat).to_s}.gem"].invoke
sh "rake gem:#{plat}:builder MAKE='nice make -j`nproc`' FORCE_CROSS_COMPILING=true"
end

namespace plat do
desc "build native gem for #{plat} platform (child process)"
task "builder" do
gem_builder(plat)
end
task "guest" => "builder" # TODO: remove me after this code is on master, temporary backwards compat for CI
end
end

desc "build a jruby gem"
task "jruby" do
RakeCompilerDock.sh "gem install bundler --no-document && bundle && rake java gem", rubyvm: "jruby"
end

desc "build native gems for windows"
Expand Down

0 comments on commit 440dc4e

Please sign in to comment.