Skip to content

Commit 64f6c59

Browse files
authored
Build extensions for Ruby 2.7 (#7027)
* Build extensions for Ruby 2.7 * Try installing bundler 2.x * Try bumping rake-compiler-dock * Use standard RCD images * Avoid 'rake cross native' with rake-compiler-dock * Use Ruby 2.5 for building Ruby <= 2.6 * Use rake-compiler 1.1.0 * Specify target * Don't update Ruby test image for now
1 parent 97f5f64 commit 64f6c59

6 files changed

Lines changed: 34 additions & 18 deletions

File tree

kokoro/linux/dockerfile/release/ruby_rake_compiler/Dockerfile

Lines changed: 0 additions & 3 deletions
This file was deleted.

kokoro/release/ruby/linux/prepare_build.sh

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,6 @@ echo 'DOCKER_OPTS="${DOCKER_OPTS} --graph=/tmpfs/docker"' | sudo tee --append /e
77
echo 'DOCKER_OPTS="${DOCKER_OPTS} --registry-mirror=https://mirror.gcr.io"' | sudo tee --append /etc/default/docker
88
sudo service docker restart
99

10-
# Download Docker images from DockerHub
11-
DOCKERHUB_ORGANIZATION=protobuftesting
12-
DOCKERFILE_DIR=kokoro/linux/dockerfile/release/ruby_rake_compiler
13-
DOCKERFILE_PREFIX=$(basename $DOCKERFILE_DIR)
14-
export RAKE_COMPILER_DOCK_IMAGE=${DOCKERHUB_ORGANIZATION}/${DOCKERFILE_PREFIX}_$(sha1sum $DOCKERFILE_DIR/Dockerfile | cut -f1 -d\ )
15-
1610
# All artifacts come here
1711
mkdir artifacts
1812
export ARTIFACT_DIR=$(pwd)/artifacts

kokoro/release/ruby/linux/ruby/ruby_build.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111

1212
umask 0022
1313
pushd ruby
14+
gem install bundler -v 2.1.4
1415
bundle install && bundle exec rake gem:native
1516
ls pkg
1617
mv pkg/* $ARTIFACT_DIR

kokoro/release/ruby/macos/ruby/ruby_build_environment.sh

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ set +ex # rvm script is very verbose and exits with errorcode
66
source $HOME/.rvm/scripts/rvm
77
set -e # rvm commands are very verbose
88
time rvm install 2.5.0
9-
rvm use 2.5.0 --default
9+
rvm use 2.5.0
10+
gem install rake-compiler --no-document
11+
gem install bundler --no-document
12+
time rvm install 2.7.0
13+
rvm use 2.7.0 --default
1014
gem install rake-compiler --no-document
1115
gem install bundler --no-document
1216
rvm osx-ssl-certs status all
@@ -17,13 +21,13 @@ rm -rf ~/.rake-compiler
1721

1822
CROSS_RUBY=$(mktemp tmpfile.XXXXXXXX)
1923

20-
curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.0.3/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
24+
curl https://raw.githubusercontent.com/rake-compiler/rake-compiler/v1.1.0/tasks/bin/cross-ruby.rake > "$CROSS_RUBY"
2125

2226
# See https://github.com/grpc/grpc/issues/12161 for verconf.h patch details
2327
patch "$CROSS_RUBY" << EOF
2428
--- cross-ruby.rake 2018-04-10 11:32:16.000000000 -0700
2529
+++ patched 2018-04-10 11:40:25.000000000 -0700
26-
@@ -133,8 +133,10 @@
30+
@@ -141,8 +141,10 @@
2731
"--host=#{MINGW_HOST}",
2832
"--target=#{MINGW_TARGET}",
2933
"--build=#{RUBY_BUILD}",
@@ -35,9 +39,9 @@ patch "$CROSS_RUBY" << EOF
3539
'--with-ext='
3640
]
3741
38-
@@ -151,6 +153,7 @@
42+
@@ -159,6 +161,7 @@
3943
# make
40-
file "#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/ruby.exe" => ["#{USER_HOME}/builds/#{MINGW_HOST}/#{RUBY_CC_VERSION}/Makefile"] do |t|
44+
file "#{build_dir}/ruby.exe" => ["#{build_dir}/Makefile"] do |t|
4145
chdir File.dirname(t.prerequisites.first) do
4246
+ sh "test -s verconf.h || rm -f verconf.h" # if verconf.h has size 0, make sure it gets re-built by make
4347
sh MAKE
@@ -47,10 +51,25 @@ EOF
4751

4852
MAKE="make -j8"
4953

54+
set +x # rvm commands are very verbose
55+
rvm use 2.7.0
56+
set -x
57+
ruby --version | grep 'ruby 2.7.0'
58+
for v in 2.7.0 ; do
59+
ccache -c
60+
rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
61+
done
62+
set +x
63+
rvm use 2.5.0
64+
set -x
65+
ruby --version | grep 'ruby 2.5.0'
5066
for v in 2.6.0 2.5.1 2.4.0 2.3.0 ; do
5167
ccache -c
5268
rake -f "$CROSS_RUBY" cross-ruby VERSION="$v" HOST=x86_64-darwin11 MAKE="$MAKE"
5369
done
70+
set +x
71+
rvm use 2.7.0
72+
set -x
5473

5574
sed 's/x86_64-darwin-11/universal-darwin/' ~/.rake-compiler/config.yml > "$CROSS_RUBY"
5675
mv "$CROSS_RUBY" ~/.rake-compiler/config.yml

ruby/Rakefile

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,18 @@ else
7070

7171
task 'gem:windows' do
7272
require 'rake_compiler_dock'
73-
RakeCompilerDock.sh "bundle && IN_DOCKER=true rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0"
73+
['x86-mingw32', 'x64-mingw32', 'x86_64-linux', 'x86-linux'].each do |plat|
74+
RakeCompilerDock.sh <<-"EOT", platform: plat
75+
bundle && \
76+
IN_DOCKER=true rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem RUBY_CC_VERSION=2.7.0:2.6.0:2.5.0:2.4.0:2.3.0
77+
EOT
78+
end
7479
end
7580

7681
if RUBY_PLATFORM =~ /darwin/
7782
task 'gem:native' do
7883
system "rake genproto"
79-
system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.1:2.4.0:2.3.0"
84+
system "rake cross native gem RUBY_CC_VERSION=2.7.0:2.6.0:2.5.1:2.4.0:2.3.0"
8085
end
8186
else
8287
task 'gem:native' => [:genproto, 'gem:windows']

ruby/google-protobuf.gemspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ Gem::Specification.new do |s|
1717
else
1818
s.files += Dir.glob('ext/**/*')
1919
s.extensions= ["ext/google/protobuf_c/extconf.rb"]
20-
s.add_development_dependency "rake-compiler-dock", "~> 0.6.0"
20+
s.add_development_dependency "rake-compiler-dock", ">= 1.0.1", "< 2.0"
2121
end
2222
s.test_files = ["tests/basic.rb",
2323
"tests/stress.rb",
2424
"tests/generated_code_test.rb"]
2525
s.required_ruby_version = '>= 2.3'
26-
s.add_development_dependency "rake-compiler", "~> 0.9.5"
26+
s.add_development_dependency "rake-compiler", "~> 1.1.0"
2727
s.add_development_dependency "test-unit", '~> 3.0', '>= 3.0.9'
2828
s.add_development_dependency "rubygems-tasks", "~> 0.2.4"
2929
end

0 commit comments

Comments
 (0)