Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(374)

Side by Side Diff: third_party/grpc/Rakefile

Issue 1932353002: Initial checkin of gRPC to third_party/ Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/grpc/README.md ('k') | third_party/grpc/binding.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 # -*- ruby -*-
2 require 'rake/extensiontask'
3 require 'rspec/core/rake_task'
4 require 'rubocop/rake_task'
5 require 'bundler/gem_tasks'
6 require 'fileutils'
7
8 load 'tools/distrib/docker_for_windows.rb'
9
10 # Add rubocop style checking tasks
11 RuboCop::RakeTask.new(:rubocop) do |task|
12 task.options = ['-c', 'src/ruby/.rubocop.yml']
13 task.patterns = ['src/ruby/{lib,spec}/**/*.rb']
14 end
15
16 spec = Gem::Specification.load('grpc.gemspec')
17
18 Gem::PackageTask.new(spec) do |pkg|
19 end
20
21 # Add the extension compiler task
22 Rake::ExtensionTask.new('grpc_c', spec) do |ext|
23 ext.source_pattern = '**/*.{c,h}'
24 ext.ext_dir = File.join('src', 'ruby', 'ext', 'grpc')
25 ext.lib_dir = File.join('src', 'ruby', 'lib', 'grpc')
26 ext.cross_compile = true
27 ext.cross_platform = [
28 'x86-mingw32', 'x64-mingw32',
29 'x86_64-linux', 'x86-linux',
30 'universal-darwin'
31 ]
32 ext.cross_compiling do |spec|
33 spec.files = %w( etc/roots.pem grpc_c.32.ruby grpc_c.64.ruby )
34 spec.files += Dir.glob('src/ruby/bin/**/*')
35 spec.files += Dir.glob('src/ruby/ext/**/*')
36 spec.files += Dir.glob('src/ruby/lib/**/*')
37 spec.files += Dir.glob('src/ruby/pb/**/*')
38 end
39 end
40
41 # Define the test suites
42 SPEC_SUITES = [
43 { id: :wrapper, title: 'wrapper layer', files: %w(src/ruby/spec/*.rb) },
44 { id: :idiomatic, title: 'idiomatic layer', dir: %w(src/ruby/spec/generic),
45 tags: ['~bidi', '~server'] },
46 { id: :bidi, title: 'bidi tests', dir: %w(src/ruby/spec/generic),
47 tag: 'bidi' },
48 { id: :server, title: 'rpc server thread tests', dir: %w(src/ruby/spec/generic ),
49 tag: 'server' },
50 { id: :pb, title: 'protobuf service tests', dir: %w(src/ruby/spec/pb) }
51 ]
52 namespace :suite do
53 SPEC_SUITES.each do |suite|
54 desc "Run all specs in the #{suite[:title]} spec suite"
55 RSpec::Core::RakeTask.new(suite[:id]) do |t|
56 ENV['COVERAGE_NAME'] = suite[:id].to_s
57 spec_files = []
58 suite[:files].each { |f| spec_files += Dir[f] } if suite[:files]
59
60 if suite[:dir]
61 suite[:dir].each { |f| spec_files += Dir["#{f}/**/*_spec.rb"] }
62 end
63 helper = 'src/ruby/spec/spec_helper.rb'
64 spec_files << helper unless spec_files.include?(helper)
65
66 t.pattern = spec_files
67 t.rspec_opts = "--tag #{suite[:tag]}" if suite[:tag]
68 if suite[:tags]
69 t.rspec_opts = suite[:tags].map { |x| "--tag #{x}" }.join(' ')
70 end
71 end
72 end
73 end
74
75 desc 'Build the Windows gRPC DLLs for Ruby'
76 task 'dlls' do
77 grpc_config = ENV['GRPC_CONFIG'] || 'opt'
78 verbose = ENV['V'] || '0'
79
80 env = 'CPPFLAGS="-D_WIN32_WINNT=0x600 -DUNICODE -D_UNICODE" '
81 env += 'LDFLAGS=-static '
82 env += 'SYSTEM=MINGW32 '
83 env += 'EMBED_ZLIB=true '
84 env += 'BUILDDIR=/tmp '
85 env += "V=#{verbose} "
86 out = '/tmp/libs/opt/grpc-0.dll'
87
88 w64 = { cross: 'x86_64-w64-mingw32', out: 'grpc_c.64.ruby' }
89 w32 = { cross: 'i686-w64-mingw32', out: 'grpc_c.32.ruby' }
90
91 [ w64, w32 ].each do |opt|
92 env_comp = "CC=#{opt[:cross]}-gcc "
93 env_comp += "LD=#{opt[:cross]}-gcc "
94 docker_for_windows "#{env} #{env_comp} make -j #{out} && #{opt[:cross]}-stri p -x -S #{out} && cp #{out} #{opt[:out]}"
95 end
96
97 end
98
99 desc 'Build the native gem file under rake_compiler_dock'
100 task 'gem:native' do
101 verbose = ENV['V'] || '0'
102
103 if RUBY_PLATFORM =~ /darwin/
104 FileUtils.touch 'grpc_c.32.ruby'
105 FileUtils.touch 'grpc_c.64.ruby'
106 system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0 V=#{ve rbose}"
107 else
108 Rake::Task['dlls'].execute
109 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}"
110 end
111 end
112
113 # Define dependencies between the suites.
114 task 'suite:wrapper' => [:compile, :rubocop]
115 task 'suite:idiomatic' => 'suite:wrapper'
116 task 'suite:bidi' => 'suite:wrapper'
117 task 'suite:server' => 'suite:wrapper'
118 task 'suite:pb' => 'suite:server'
119
120 desc 'Compiles the gRPC extension then runs all the tests'
121 task all: ['suite:idiomatic', 'suite:bidi', 'suite:pb', 'suite:server']
122 task default: :all
OLDNEW
« no previous file with comments | « third_party/grpc/README.md ('k') | third_party/grpc/binding.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698