aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar murgatroid99 <michael.lumish@gmail.com>2017-01-17 11:47:06 -0800
committerGravatar murgatroid99 <michael.lumish@gmail.com>2017-01-17 11:47:06 -0800
commitc781f6451887ee5b47623c511ba337b08532f583 (patch)
treef25fcf83028e365dfdfeeb677a073230018de3ee
parent116901598f05690168e18e6cd73c6422089006b8 (diff)
Use config file template instead of Rakefile template
-rwxr-xr-xRakefile4
-rw-r--r--build_config.rb3
-rw-r--r--templates/Rakefile.template126
-rw-r--r--templates/build_config.rb.template5
4 files changed, 11 insertions, 127 deletions
diff --git a/Rakefile b/Rakefile
index 8a88b4401f..c8bca20ad1 100755
--- a/Rakefile
+++ b/Rakefile
@@ -5,6 +5,8 @@ require 'rubocop/rake_task'
require 'bundler/gem_tasks'
require 'fileutils'
+require_relative 'build_config.rb'
+
load 'tools/distrib/docker_for_windows.rb'
# Add rubocop style checking tasks
@@ -83,7 +85,7 @@ task 'dlls' do
env += 'EMBED_ZLIB=true '
env += 'BUILDDIR=/tmp '
env += "V=#{verbose} "
- out = '/tmp/libs/opt/grpc-2.dll'
+ 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' }
diff --git a/build_config.rb b/build_config.rb
new file mode 100644
index 0000000000..83edb1c390
--- /dev/null
+++ b/build_config.rb
@@ -0,0 +1,3 @@
+module GrpcBuildConfig
+ CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-2.dll'
+end
diff --git a/templates/Rakefile.template b/templates/Rakefile.template
deleted file mode 100644
index 2ab505b7c1..0000000000
--- a/templates/Rakefile.template
+++ /dev/null
@@ -1,126 +0,0 @@
-%YAML 1.2
---- |
- # -*- ruby -*-
- require 'rake/extensiontask'
- require 'rspec/core/rake_task'
- require 'rubocop/rake_task'
- require 'bundler/gem_tasks'
- require 'fileutils'
-
- 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']
- task.patterns = ['src/ruby/{lib,spec}/**/*.rb']
- end
-
- spec = Gem::Specification.load('grpc.gemspec')
-
- Gem::PackageTask.new(spec) do |pkg|
- end
-
- # Add the extension compiler task
- Rake::ExtensionTask.new('grpc_c', spec) do |ext|
- ext.source_pattern = '**/*.{c,h}'
- 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',
- 'x86_64-linux', 'x86-linux',
- 'universal-darwin'
- ]
- 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/**/*')
- spec.files += Dir.glob('src/ruby/ext/**/*')
- spec.files += Dir.glob('src/ruby/lib/**/*')
- spec.files += Dir.glob('src/ruby/pb/**/*')
- end
- end
-
- # Define the test suites
- SPEC_SUITES = [
- { id: :wrapper, title: 'wrapper layer', files: %w(src/ruby/spec/*.rb) },
- { id: :idiomatic, title: 'idiomatic layer', dir: %w(src/ruby/spec/generic),
- tags: ['~bidi', '~server'] },
- { id: :bidi, title: 'bidi tests', dir: %w(src/ruby/spec/generic),
- tag: 'bidi' },
- { id: :server, title: 'rpc server thread tests', dir: %w(src/ruby/spec/generic),
- tag: 'server' },
- { id: :pb, title: 'protobuf service tests', dir: %w(src/ruby/spec/pb) }
- ]
- namespace :suite do
- SPEC_SUITES.each do |suite|
- desc "Run all specs in the #{suite[:title]} spec suite"
- RSpec::Core::RakeTask.new(suite[:id]) do |t|
- ENV['COVERAGE_NAME'] = suite[:id].to_s
- spec_files = []
- suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
-
- if suite[:dir]
- suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
- end
- helper = 'src/ruby/spec/spec_helper.rb'
- spec_files << helper unless spec_files.include?(helper)
-
- t.pattern = spec_files
- t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
- if suite[:tags]
- t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
- end
- end
- end
- end
-
- desc 'Build the Windows gRPC DLLs for Ruby'
- task 'dlls' do
- grpc_config = ENV['GRPC_CONFIG'] || 'opt'
- verbose = ENV['V'] || '0'
-
- env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE -Wno-unused-variable -Wno-unused-result" '
- env += 'LDFLAGS=-static '
- env += 'SYSTEM=MINGW32 '
- env += 'EMBED_ZLIB=true '
- env += 'BUILDDIR=/tmp '
- env += "V=#{verbose} "
- out = '/tmp/libs/opt/grpc-${settings.core_version.major}.dll'
-
- w64 = { cross: 'x86_64-w64-mingw32', out: 'grpc_c.64.ruby' }
- w32 = { cross: 'i686-w64-mingw32', out: 'grpc_c.32.ruby' }
-
- [ w64, w32 ].each do |opt|
- env_comp = "CC=#{opt[:cross]}-gcc "
- env_comp += "LD=#{opt[:cross]}-gcc "
- docker_for_windows "#{env} #{env_comp} make -j #{out} && #{opt[:cross]}-strip -x -S #{out} && cp #{out} #{opt[:out]}"
- end
-
- end
-
- desc 'Build the native gem file under rake_compiler_dock'
- task 'gem:native' do
- verbose = ENV['V'] || '0'
-
- grpc_config = ENV['GRPC_CONFIG'] || 'opt'
-
- if RUBY_PLATFORM =~ /darwin/
- FileUtils.touch 'grpc_c.32.ruby'
- FileUtils.touch 'grpc_c.64.ruby'
- system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
- else
- Rake::Task['dlls'].execute
- docker_for_windows "bundle && rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{verbose} GRPC_CONFIG=#{grpc_config}"
- end
- end
-
- # Define dependencies between the suites.
- task 'suite:wrapper' => [:compile, :rubocop]
- task 'suite:idiomatic' => 'suite:wrapper'
- task 'suite:bidi' => 'suite:wrapper'
- task 'suite:server' => 'suite:wrapper'
- task 'suite:pb' => 'suite:server'
-
- desc 'Compiles the gRPC extension then runs all the tests'
- task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server']
- task default: :all
diff --git a/templates/build_config.rb.template b/templates/build_config.rb.template
new file mode 100644
index 0000000000..4cb4810d33
--- /dev/null
+++ b/templates/build_config.rb.template
@@ -0,0 +1,5 @@
+%YAML 1.2
+--- |
+ module GrpcBuildConfig
+ CORE_WINDOWS_DLL = '/tmp/libs/opt/grpc-${settings.core_version.major}.dll'
+ end \ No newline at end of file