Properly compiling distributable native gems.

pull/5097/head
Nicolas "Pixel" Noble 9 years ago
parent a7f52c51e5
commit 5219c6d8e8
  1. 16
      Rakefile
  2. 1
      src/ruby/ext/grpc/extconf.rb
  3. 15
      third_party/rake-compiler-dock/Dockerfile

@ -23,7 +23,15 @@ Rake::ExtensionTask.new('grpc_c', spec) do |ext|
ext.ext_dir = File.join('src', 'ruby', 'ext', 'grpc')
ext.lib_dir = File.join('src', 'ruby', 'lib', 'grpc')
ext.cross_compile = true
ext.cross_platform = ['x86-mingw32', 'x64-mingw32']
ext.cross_platform = [
'x86-mingw32', 'x64-mingw32',
'x86_64-linux', 'x86-linux',
'x86_64-darwin-11',
'x86_64-darwin-12',
'x86_64-darwin-13',
'x86_64-darwin-14',
'x86_64-darwin-15'
]
ext.cross_compiling do |spec|
spec.files = %w( etc/roots.pem grpc_c.32.ruby grpc_c.64.ruby )
spec.files += Dir.glob('src/ruby/bin/**/*')
@ -91,8 +99,8 @@ task 'dlls' do
end
desc 'Build the gem file under rake_compiler_dock'
task 'gem:windows' do
desc 'Build the native gem file under rake_compiler_dock'
task 'gem:native' do
verbose = ENV['V'] || '0'
docker_for_windows "bundle && rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.6:2.0.0 V=#{verbose}"
@ -105,7 +113,7 @@ task 'suite:bidi' => 'suite:wrapper'
task 'suite:server' => 'suite:wrapper'
task 'suite:pb' => 'suite:server'
task 'gem:windows' => 'dlls'
task 'gem:native' => 'dlls'
desc 'Compiles the gRPC extension then runs all the tests'
task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server']

@ -75,6 +75,7 @@ unless File.exist?(File.join(grpc_lib_dir, 'libgrpc.a')) or windows
ENV['EMBED_OPENSSL'] = 'true'
ENV['EMBED_ZLIB'] = 'true'
ENV['ARCH_FLAGS'] = RbConfig::CONFIG['ARCH_FLAG']
ENV['ARCH_FLAGS'] = '-arch i386 -arch x86_64' if RUBY_PLATFORM =~ /darwin/
output_dir = File.expand_path(RbConfig::CONFIG['topdir'])

@ -1,7 +1,7 @@
FROM ubuntu:14.04
RUN apt-get -y update && \
apt-get install -y curl git-core mingw-w64 xz-utils build-essential wget unzip
apt-get install -y curl git-core mingw-w64 xz-utils build-essential gcc-multilib wget unzip
RUN mkdir -p /opt/mingw && \
curl -SL http://downloads.sourceforge.net/mingw-w64/i686-w64-mingw32-gcc-4.7.2-release-linux64_rubenvb.tar.xz | \
@ -103,12 +103,25 @@ RUN bash -c "rvm use 2.3.0 --default && \
export MAKE=\"make -j`nproc`\" CFLAGS='-s -O1 -fno-omit-frame-pointer -fno-fast-math' && \
rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.3.0 HOST=x86_64-linux-gnu && \
rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.2.2 HOST=x86_64-linux-gnu && \
rake-compiler cross-ruby VERSION=2.1.6 HOST=i686-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.1.6 HOST=x86_64-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.1.6 HOST=x86_64-linux-gnu && \
rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-w64-mingw32 && \
rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=x86_64-linux-gnu && \
rm -rf ~/.rake-compiler/tmp/builds ~/.rake-compiler/sources && \
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "
RUN bash -c "rvm use 2.3.0 --default && \
export MAKE=\"make -j`nproc`\" CFLAGS='-m32 -s -O1 -fno-omit-frame-pointer -fno-fast-math' LDFLAGS='-m32' && \
rake-compiler cross-ruby VERSION=2.3.0 HOST=i686-linux-gnu && \
rake-compiler cross-ruby VERSION=2.2.2 HOST=i686-linux-gnu && \
rake-compiler cross-ruby VERSION=2.1.6 HOST=i686-linux-gnu && \
rake-compiler cross-ruby VERSION=2.0.0-p645 HOST=i686-linux-gnu && \
rm -rf ~/.rake-compiler/tmp/builds ~/.rake-compiler/sources && \
find /usr/local/rvm -type d -print0 | sudo xargs -0 chmod g+sw "

Loading…
Cancel
Save