Skip to content

Commit

Permalink
gem: setup-osx-native-builders to set up rubies for native gem
Browse files Browse the repository at this point in the history
  • Loading branch information
flavorjones committed Sep 7, 2020
1 parent ac1c1fe commit d0cf141
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions scripts/setup-osx-native-builders
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#! /usr/bin/env bash

# for inspiration / related cross-ruby building, see:
# - 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

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

# prerequisites on OSX
if [[ -z "$(which ruby-install)" ]] ; then
echo "ERROR: ruby-install is not installed, please install it: https://github.com/postmodern/ruby-install"
exit 1
fi

set -o errexit
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

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

for ruby in $RUBIES ; do
ruby_fullname="native-builder-${ruby}"
ruby_minor="${ruby}.0"

rbconfig=$(echo ${RUBIES_DIR}/${ruby_fullname}/lib/ruby/${ruby_minor}/*/rbconfig.rb)
if [[ ! -e $rbconfig ]] ; then
echo "installing $ruby_fullname ..."
ruby-install -i ${RUBIES_DIR}/${ruby_fullname} ruby ${ruby} \
-- \
--enable-static \
--disable-shared \
--without-gmp \
--disable-install-doc
rbconfig=$(echo $rbconfig)
else
echo "ruby $ruby_fullname is installed"
fi

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

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

cat $RAKE_COMPILER_CONFIG

0 comments on commit d0cf141

Please sign in to comment.