Skip to content

Commit 60f4bcf

Browse files
committed
Build all possible darwin gems
1 parent 80dadb2 commit 60f4bcf

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

.github/workflows/build.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ jobs:
4545
./inject-libv8 ${{ steps.set-metadata.outputs.NODE_VERSION }}
4646
- name: Build gem
4747
run: |
48-
bundle exec rake binary
48+
bundle exec rake binary:all
4949
- name: Upload V8
5050
uses: actions/upload-artifact@v1
5151
with:

Rakefile

+26-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Bundler::GemHelper.install_tasks
55
module Helpers
66
module_function
77

8-
def binary_gemspec(platform = Gem::Platform.local, str = RUBY_PLATFORM)
8+
def binary_gemspec(platform: Gem::Platform.local, str: RUBY_PLATFORM)
99
platform.instance_eval { @version = 'musl' } if str =~ /-musl/ && platform.version.nil?
1010

1111
gemspec = eval(File.read('libv8-node.gemspec'))
@@ -22,8 +22,8 @@ task :compile do
2222
#sh 'ruby ext/libv8-node/extconf.rb'
2323
end
2424

25-
task :binary => :compile do
26-
gemspec = Helpers.binary_gemspec
25+
task :binary, [:platform] => [:compile] do |_, args|
26+
gemspec = Helpers.binary_gemspec(**args.to_h)
2727
gemspec.extensions.clear
2828

2929
# We don't need most things for the binary
@@ -48,3 +48,26 @@ task :binary => :compile do
4848

4949
FileUtils.mv(package, 'pkg')
5050
end
51+
52+
namespace :binary do
53+
task :all => :binary do
54+
return unless RUBY_PLATFORM =~ /darwin-?(\d+)/
55+
56+
Helpers.binary_gemspec # loads NODE_VERSION
57+
58+
current = Integer($1)
59+
major, minor = File.read(Dir["src/node-#{Libv8::Node::NODE_VERSION}/common.gypi"].last).lines.find { |l| l =~ /-mmacosx-version-min=(\d+).(\d+)/ } && [Integer($1), Integer($2)]
60+
first = minor + 4
61+
max = 20
62+
63+
(first..max).each do |version|
64+
next if version == current
65+
66+
platform = Gem::Platform.local.dup
67+
platform.instance_eval { @version = version }
68+
puts "> building #{platform}"
69+
70+
Rake::Task["binary"].execute(Rake::TaskArguments.new([:platform], [platform]))
71+
end
72+
end
73+
end

0 commit comments

Comments
 (0)