Skip to content

Commit

Permalink
gem(native): package a gem that supports all darwin versions
Browse files Browse the repository at this point in the history
related to #2079
  • Loading branch information
flavorjones committed Dec 3, 2020
1 parent eec0923 commit 342ed1c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions .cross_rubies
Expand Up @@ -2,19 +2,19 @@
2.7.0:x86_64-w64-mingw32
2.7.0:i686-linux-gnu
2.7.0:x86_64-linux-gnu
2.7.0:x86_64-darwin19
2.7.0:x86_64-darwin
2.6.0:i686-w64-mingw32
2.6.0:x86_64-w64-mingw32
2.6.0:i686-linux-gnu
2.6.0:x86_64-linux-gnu
2.6.0:x86_64-darwin19
2.6.0:x86_64-darwin
2.5.0:i686-w64-mingw32
2.5.0:x86_64-w64-mingw32
2.5.0:i686-linux-gnu
2.5.0:x86_64-linux-gnu
2.5.0:x86_64-darwin19
2.5.0:x86_64-darwin
2.4.0:i686-w64-mingw32
2.4.0:x86_64-w64-mingw32
2.4.0:i686-linux-gnu
2.4.0:x86_64-linux-gnu
2.4.0:x86_64-darwin19
2.4.0:x86_64-darwin
12 changes: 6 additions & 6 deletions rakelib/cross-ruby.rake
Expand Up @@ -46,8 +46,8 @@ CrossRuby = Struct.new(:version, :host) do
"x86_64-linux"
when /\Ai[3-6]86.*linux/
"x86-linux"
when /\Ax86_64-darwin19/
"x86_64-darwin19"
when /\Ax86_64-darwin/
"x86_64-darwin"
else
raise "CrossRuby.platform: unsupported host: #{host}"
end
Expand All @@ -63,8 +63,8 @@ CrossRuby = Struct.new(:version, :host) do
"x86_64-linux-gnu-"
when "x86-linux"
"i686-linux-gnu-"
when /darwin/
""
# when /darwin/
# ""
else
raise "CrossRuby.tool: unmatched platform: #{platform}"
end) + name
Expand All @@ -80,8 +80,8 @@ CrossRuby = Struct.new(:version, :host) do
"elf64-x86-64"
when "x86-linux"
"elf32-i386"
when "x86_64-darwin19"
"Mach-O 64-bit x86-64"
when "x86_64-darwin"
"Mach-O 64-bit x86-64" # hmm
else
raise "CrossRuby.target_file_format: unmatched platform: #{platform}"
end
Expand Down
14 changes: 9 additions & 5 deletions scripts/setup-osx-native-builders
Expand Up @@ -4,6 +4,9 @@
# - https://github.com/rake-compiler/rake-compiler/blob/master/tasks/bin/cross-ruby.rake
# - https://github.com/apolcyn/grpc/blob/master/tools/distrib/build_ruby_environment_macos.sh

# see test/test_gem_platform.rb for context
gem_platform_name="x86_64-darwin"

# chosen so chruby will see it, should you be a user of chruby
RUBIES_DIR=${HOME}/.rubies

Expand All @@ -18,11 +21,12 @@ set -o pipefail

CROSS_FILE=".cross_rubies"
RUBIES=$(cat $CROSS_FILE | fgrep darwin | cut -d. -f1,2 | sort -u)

RAKE_COMPILER_CONFIG_DIR=${HOME}/.rake-compiler
RAKE_COMPILER_CONFIG=${RAKE_COMPILER_CONFIG_DIR}/config.yml
TMP_CONFIG=$(mktemp /tmp/rake-compiler-config.XXXXXXXX)

mkdir -p $RAKE_COMPILER_CONFIG_DIR
echo "---" > $RAKE_COMPILER_CONFIG
echo "---" > $TMP_CONFIG

for ruby in $RUBIES ; do
ruby_fullname="native-builder-${ruby}"
Expand All @@ -42,9 +46,9 @@ for ruby in $RUBIES ; do
echo "ruby $ruby_fullname is installed"
fi

platform=$(basename $(dirname $rbconfig))

echo "rbconfig-${platform}-${ruby_minor}: \"${rbconfig}\"" >> $RAKE_COMPILER_CONFIG
echo "rbconfig-${gem_platform_name}-${ruby_minor}: \"${rbconfig}\"" >> $TMP_CONFIG
done

mkdir -p $RAKE_COMPILER_CONFIG_DIR
cp $TMP_CONFIG $RAKE_COMPILER_CONFIG
cat $RAKE_COMPILER_CONFIG

0 comments on commit 342ed1c

Please sign in to comment.