Skip to content

Commit ffe2fa2

Browse files
committed
attempt to fix "build from source" for musl
1 parent b9125aa commit ffe2fa2

File tree

3 files changed

+14
-4
lines changed

3 files changed

+14
-4
lines changed

.github/workflows/build.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ jobs:
358358
- name: Set metadata
359359
id: set-metadata
360360
run: |
361-
docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ruby -e 'puts Gem.platforms.last.to_s' | tee gem_platform
361+
docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ruby -e 'p = Gem::Platform.local; parts = [p.cpu, p.os, p.version]; parts[2] = "musl" if RUBY_PLATFORM =~ /musl/; puts parts.compact.reject { |s| s.to_s.empty? }.join("-").gsub(/-darwin-?\d+/, "-darwin")' | tee gem_platform
362362
echo "GEM_PLATFORM=$(cat gem_platform)" >> $GITHUB_OUTPUT
363363
- name: Download a single artifact
364364
uses: actions/download-artifact@v4
@@ -473,7 +473,7 @@ jobs:
473473
- name: Set metadata
474474
id: set-metadata
475475
run: |
476-
docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ruby -e 'puts Gem::Platform.local.tap { |p| RUBY_PLATFORM =~ /musl/ && p.version.nil? and p.instance_eval { @version = "musl" } }.to_s' | tee gem_platform
476+
docker exec -w "${PWD}" ${{ steps.container.outputs.id }} ruby -e 'p = Gem::Platform.local; parts = [p.cpu, p.os, p.version]; parts[2] = "musl" if RUBY_PLATFORM =~ /musl/; puts parts.compact.reject { |s| s.to_s.empty? }.join("-").gsub(/-darwin-?\d+/, "-darwin")' | tee gem_platform
477477
echo "GEM_PLATFORM=$(cat gem_platform)" >> $GITHUB_OUTPUT
478478
- name: Download a single artifact
479479
uses: actions/download-artifact@v4

ext/libv8-node/paths.rb

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,17 @@ def object_paths
2222
end
2323

2424
def platform
25-
Gem::Platform.local.tap { |p| RUBY_PLATFORM =~ /musl/ && p.version.nil? && p.instance_eval { @version = 'musl' } }.to_s.gsub(/-darwin-?\d+/, '-darwin')
25+
@platform ||= begin
26+
local = Gem::Platform.local
27+
parts = [local.cpu, local.os, local.version]
28+
parts[2] = 'musl' if RUBY_PLATFORM =~ /musl/
29+
ideal = parts.compact.reject { |s| s.to_s.empty? }.join('-').gsub(/-darwin-?\d+/, '-darwin')
30+
31+
return ideal if File.directory?(File.join(vendored_source_path, ideal))
32+
33+
available = Dir.glob(File.join(vendored_source_path, '*')).select { |d| File.directory?(d) }.map { |d| File.basename(d) } - ['include']
34+
available.size == 1 ? available.first : ideal
35+
end
2636
end
2737

2838
def config

libexec/metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ case "$1" in
55
ruby -e 'puts RUBY_PLATFORM'
66
;;
77
gem_platform)
8-
ruby -e 'puts Gem::Platform.local.tap { |p| RUBY_PLATFORM =~ /musl/ && p.version.nil? and p.instance_eval { @version = "musl" } }.to_s.gsub(/-darwin-?\d+/, "-darwin")'
8+
ruby -e 'p = Gem::Platform.local; parts = [p.cpu, p.os, p.version]; parts[2] = "musl" if RUBY_PLATFORM =~ /musl/; puts parts.compact.reject { |s| s.to_s.empty? }.join("-").gsub(/-darwin-?\d+/, "-darwin")'
99
;;
1010
gem_version|version)
1111
ruby -I'lib' -r'libv8/node/version' -e 'puts Libv8::Node::VERSION'

0 commit comments

Comments
 (0)