• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2# Copyright 2015 gRPC authors.
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16set -ex
17
18rm -rf ~/.rake-compiler
19
20CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX)
21
22curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.1.0/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
23
24# See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details
25patch "$CROSS_RUBY" << EOF
26--- cross-ruby.rake	2018-04-10 11:32:16.000000000 -0700
27+++ patched	2018-04-10 11:40:25.000000000 -0700
28@@ -133,8 +133,10 @@
29     "--host=#{MINGW_HOST}",
30     "--target=#{MINGW_TARGET}",
31     "--build=#{RUBY_BUILD}",
32-    '--enable-shared',
33+    '--enable-static',
34+    '--disable-shared',
35     '--disable-install-doc',
36+    '--without-gmp',
37     '--with-ext='
38   ]
39 
40@@ -151,6 +153,7 @@
41 # make
42 file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
43   chdir File.dirname(t.prerequisites.first) do
44+    sh "test -s verconf.h || rm -f verconf.h"  # if verconf.h has size 0, make sure it gets re-built by make
45     sh MAKE
46   end
47 end
48EOF
49
50MAKE="make -j8"
51
52set +x # rvm commands are very verbose
53source ~/.rvm/scripts/rvm
54rvm use 2.7.0
55set -x
56ruby --version | grep 'ruby 2.7.0'
57for v in 2.7.0 ; do
58  ccache -c
59  rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
60done
61set +x
62rvm use 2.5.0
63set -x
64ruby --version | grep 'ruby 2.5.0'
65for v in 2.6.0 2.5.0 2.4.0 2.3.0 2.2.2 ; do
66  ccache -c
67  rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
68done
69
70sed 's/x86_64-darwin-11/universal-darwin/' ~/.rake-compiler/config.yml > "$CROSS_RUBY"
71mv "$CROSS_RUBY" ~/.rake-compiler/config.yml
72