Merge pull request #22039 from larskanis/binary-ruby-2.7

Add ruby-2.7 to build process of binary gems for Windows and Linux
pull/22129/head
Esun Kim 5 years ago committed by GitHub
commit b540b8a71c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 31
      Rakefile
  2. 11
      grpc.gemspec
  3. 11
      templates/grpc.gemspec.template
  4. 22
      third_party/rake-compiler-dock/Dockerfile
  5. 22
      third_party/rake-compiler-dock/LICENSE.txt
  6. 1
      third_party/rake-compiler-dock/README.md
  7. 56
      tools/distrib/docker_for_windows.rb
  8. 2
      tools/dockerfile/push_testing_images.sh
  9. 2
      tools/run_tests/artifacts/distribtest_targets.py

@ -7,8 +7,6 @@ require 'fileutils'
require_relative 'build_config.rb'
load 'tools/distrib/docker_for_windows.rb'
# Add rubocop style checking tasks
RuboCop::RakeTask.new(:rubocop) do |task|
task.options = ['-c', 'src/ruby/.rubocop.yml']
@ -83,6 +81,8 @@ end
desc 'Build the Windows gRPC DLLs for Ruby'
task 'dlls' do
require 'rake_compiler_dock'
grpc_config = ENV['GRPC_CONFIG'] || 'opt'
verbose = ENV['V'] || '0'
@ -98,15 +98,20 @@ task 'dlls' do
env += "V=#{verbose} "
out = GrpcBuildConfig::CORE_WINDOWS_DLL
w64 = { cross: 'x86_64-w64-mingw32', out: 'grpc_c.64.ruby' }
w32 = { cross: 'i686-w64-mingw32', out: 'grpc_c.32.ruby' }
w64 = { cross: 'x86_64-w64-mingw32', out: 'grpc_c.64.ruby', platform: 'x64-mingw32' }
w32 = { cross: 'i686-w64-mingw32', out: 'grpc_c.32.ruby', platform: 'x86-mingw32' }
[ w64, w32 ].each do |opt|
env_comp = "CC=#{opt[:cross]}-gcc "
env_comp += "CXX=#{opt[:cross]}-g++ "
env_comp += "LD=#{opt[:cross]}-gcc "
env_comp += "LDXX=#{opt[:cross]}-g++ "
docker_for_windows "gem update --system --no-document && #{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
RakeCompilerDock.sh <<-EOT, platform: opt[:platform]
gem update --system --no-document && \
#{env} #{env_comp} make -j`nproc` #{out} && \
#{opt[:cross]}-strip -x -S #{out} && \
cp #{out} #{opt[:out]}
EOT
end
end
@ -127,8 +132,22 @@ task 'gem:native' do
end
system "rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
else
require 'rake_compiler_dock'
Rake::Task['dlls'].execute
docker_for_windows "gem update --system --no-document && bundle && rake cross native gem RUBY_CC_VERSION=2.6.0:2.5.0:2.4.0:2.3.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
['x86-mingw32', 'x64-mingw32', 'x86_64-linux', 'x86-linux'].each do |plat|
RakeCompilerDock.sh <<-EOT, platform: plat
# Avoid conflicting declarations of gettimeofday: https://github.com/rake-compiler/rake-compiler-dock/issues/32
find /usr/local/rake-compiler -name win32.h | while read f ; do sudo sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done && \
gem update --system --no-document && \
bundle && \
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 \
V=#{verbose} \
GRPC_CONFIG=#{grpc_config}
EOT
end
end
end

@ -19,7 +19,10 @@ Gem::Specification.new do |s|
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
s.files += Dir.glob('src/ruby/lib/**/*')
s.files += Dir.glob('src/ruby/lib/**/*').reject do |f|
# Binaries are included by rake-compiler and would lead to circular dependencies here
File.fnmatch("**/?.?/grpc_c.so", f)
end
s.files += Dir.glob('src/ruby/pb/**/*').reject do |f|
f.match(%r{^src/ruby/pb/test})
end
@ -36,9 +39,9 @@ Gem::Specification.new do |s|
s.add_development_dependency 'facter', '~> 2.4'
s.add_development_dependency 'logging', '~> 2.0'
s.add_development_dependency 'simplecov', '~> 0.14.1'
s.add_development_dependency 'rake', '~> 12.0'
s.add_development_dependency 'rake-compiler', '~> 1.0'
s.add_development_dependency 'rake-compiler-dock', '~> 0.5.1'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rake-compiler', '~> 1.1'
s.add_development_dependency 'rake-compiler-dock', '~> 1.0'
s.add_development_dependency 'rspec', '~> 3.6'
s.add_development_dependency 'rubocop', '~> 0.49.1'
s.add_development_dependency 'signet', '~> 0.7'

@ -21,7 +21,10 @@
s.files += %w( etc/roots.pem )
s.files += Dir.glob('src/ruby/bin/**/*')
s.files += Dir.glob('src/ruby/ext/**/*')
s.files += Dir.glob('src/ruby/lib/**/*')
s.files += Dir.glob('src/ruby/lib/**/*').reject do |f|
# Binaries are included by rake-compiler and would lead to circular dependencies here
File.fnmatch("**/?.?/grpc_c.so", f)
end
s.files += Dir.glob('src/ruby/pb/**/*').reject do |f|
f.match(%r{^src/ruby/pb/test})
end
@ -38,9 +41,9 @@
s.add_development_dependency 'facter', '~> 2.4'
s.add_development_dependency 'logging', '~> 2.0'
s.add_development_dependency 'simplecov', '~> 0.14.1'
s.add_development_dependency 'rake', '~> 12.0'
s.add_development_dependency 'rake-compiler', '~> 1.0'
s.add_development_dependency 'rake-compiler-dock', '~> 0.5.1'
s.add_development_dependency 'rake', '~> 13.0'
s.add_development_dependency 'rake-compiler', '~> 1.1'
s.add_development_dependency 'rake-compiler-dock', '~> 1.0'
s.add_development_dependency 'rspec', '~> 3.6'
s.add_development_dependency 'rubocop', '~> 0.49.1'
s.add_development_dependency 'signet', '~> 0.7'

@ -1,22 +0,0 @@
FROM larskanis/rake-compiler-dock-mri:0.7.2
RUN find / -name rbconfig.rb | while read f ; do sed -i 's/0x0501/0x0600/' $f ; done
RUN find / -name win32.h | while read f ; do sed -i 's/gettimeofday/rb_gettimeofday/' $f ; done
RUN find / -name libwinpthread.dll.a | xargs rm
RUN find / -name libwinpthread-1.dll | xargs rm
RUN find / -name *msvcrt-ruby*.dll.a | while read f ; do n=`echo $f | sed s/.dll//` ; mv $f $n ; done
RUN apt-get install -y g++-multilib
# Make the system to have GLIBC 2.12 instead of 2.23 so that
# generated ruby package can run on CentOS 6 with GLIBC 2.12
RUN sed -i 's/__GLIBC_MINOR__\t23/__GLIBC_MINOR__\t12/' /usr/include/features.h
# Use posix pthread for mingw so that C++ standard library for thread could be
# available such as std::thread, std::mutex, so on.
# https://sourceware.org/pthreads-win32/
RUN printf "1\n" | update-alternatives --config x86_64-w64-mingw32-gcc && \
printf "1\n" | update-alternatives --config x86_64-w64-mingw32-g++ && \
printf "1\n" | update-alternatives --config i686-w64-mingw32-gcc && \
printf "1\n" | update-alternatives --config i686-w64-mingw32-g++
CMD bash

@ -1,22 +0,0 @@
Copyright (c) 2015 Lars Kanis
MIT License
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

@ -1 +0,0 @@
This is a modified Dockerfile taken from [rake-compiler-dock](https://github.com/rake-compiler/rake-compiler-dock) for the purpose of building gRPC's ruby gem.

@ -1,56 +0,0 @@
#!/usr/bin/env ruby
# Copyright 2016 gRPC authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
def grpc_root()
File.expand_path(File.join(File.dirname(__FILE__), '..', '..'))
end
def docker_for_windows_image()
require 'digest'
dockerfile = File.join(grpc_root, 'third_party', 'rake-compiler-dock', 'Dockerfile')
dockerpath = File.dirname(dockerfile)
version = Digest::SHA1.file(dockerfile).hexdigest
image_name = 'rake-compiler-dock_' + version
# if "DOCKERHUB_ORGANIZATION" env is set, we try to pull the pre-built
# rake-compiler-dock image from dockerhub rather then building from scratch.
if ENV.has_key?('DOCKERHUB_ORGANIZATION')
image_name = ENV['DOCKERHUB_ORGANIZATION'] + '/' + image_name
cmd = "docker pull #{image_name}"
puts cmd
system cmd
raise "Failed to pull the docker image." unless $? == 0
else
cmd = "docker build -t #{image_name} --file #{dockerfile} #{dockerpath}"
puts cmd
system cmd
raise "Failed to build the docker image." unless $? == 0
end
image_name
end
def docker_for_windows(args)
require 'rake_compiler_dock'
args = 'bash -l' if args.empty?
ENV['RAKE_COMPILER_DOCK_IMAGE'] = docker_for_windows_image
RakeCompilerDock.sh args
end
if __FILE__ == $0
docker_for_windows $*.join(' ')
end

@ -29,7 +29,7 @@ cd -
DOCKERHUB_ORGANIZATION=grpctesting
for DOCKERFILE_DIR in tools/dockerfile/test/* tools/dockerfile/grpc_artifact_* tools/dockerfile/interoptest/* tools/dockerfile/distribtest/* third_party/rake-compiler-dock
for DOCKERFILE_DIR in tools/dockerfile/test/* tools/dockerfile/grpc_artifact_* tools/dockerfile/interoptest/* tools/dockerfile/distribtest/*
do
# Generate image name based on Dockerfile checksum. That works well as long
# as can count on dockerfiles being written in a way that changing the logical

@ -340,7 +340,7 @@ def targets():
RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_4'),
RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_5'),
RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_6'),
# RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_7'),
RubyDistribTest('linux', 'x64', 'jessie', ruby_version='ruby_2_7'),
RubyDistribTest('linux', 'x64', 'centos6'),
RubyDistribTest('linux', 'x64', 'centos7'),
RubyDistribTest('linux', 'x64', 'fedora23'),

Loading…
Cancel
Save