OLD | NEW |
1 require "rubygems" | 1 require "rubygems" |
2 require "rubygems/package_task" | 2 require "rubygems/package_task" |
3 require "rake/extensiontask" unless RUBY_PLATFORM == "java" | 3 require "rake/extensiontask" unless RUBY_PLATFORM == "java" |
4 require "rake/testtask" | 4 require "rake/testtask" |
5 | 5 |
6 spec = Gem::Specification.load("google-protobuf.gemspec") | 6 spec = Gem::Specification.load("google-protobuf.gemspec") |
7 | 7 |
8 well_known_protos = %w[ | 8 well_known_protos = %w[ |
9 google/protobuf/any.proto | 9 google/protobuf/any.proto |
10 google/protobuf/api.proto | 10 google/protobuf/api.proto |
(...skipping 13 matching lines...) Expand all Loading... |
24 google/protobuf/compiler/plugin.proto | 24 google/protobuf/compiler/plugin.proto |
25 ] | 25 ] |
26 | 26 |
27 genproto_output = [] | 27 genproto_output = [] |
28 | 28 |
29 # We won't have access to .. from within docker, but the proto files | 29 # We won't have access to .. from within docker, but the proto files |
30 # will be there, thanks to the :genproto rule dependency for gem:native. | 30 # will be there, thanks to the :genproto rule dependency for gem:native. |
31 unless ENV['IN_DOCKER'] == 'true' | 31 unless ENV['IN_DOCKER'] == 'true' |
32 well_known_protos.each do |proto_file| | 32 well_known_protos.each do |proto_file| |
33 input_file = "../src/" + proto_file | 33 input_file = "../src/" + proto_file |
34 output_file = "lib/" + proto_file.sub(/\.proto$/, "_pb.rb") | 34 output_file = "lib/" + proto_file.sub(/\.proto$/, ".rb") |
35 genproto_output << output_file | 35 genproto_output << output_file |
36 file output_file => input_file do |file_task| | 36 file output_file => input_file do |file_task| |
37 sh "../src/protoc -I../src --ruby_out=lib #{input_file}" | 37 sh "../src/protoc -I../src --ruby_out=lib #{input_file}" |
38 end | 38 end |
39 end | 39 end |
40 end | 40 end |
41 | 41 |
42 if RUBY_PLATFORM == "java" | 42 if RUBY_PLATFORM == "java" |
43 if `which mvn` == '' | 43 if `which mvn` == '' |
44 raise ArgumentError, "maven needs to be installed" | 44 raise ArgumentError, "maven needs to be installed" |
45 end | 45 end |
46 task :clean do | 46 task :clean do |
47 system("mvn --batch-mode clean") | 47 system("mvn clean") |
48 end | 48 end |
49 | 49 |
50 task :compile do | 50 task :compile do |
51 system("mvn --batch-mode package") | 51 system("mvn package") |
52 end | 52 end |
53 else | 53 else |
54 Rake::ExtensionTask.new("protobuf_c", spec) do |ext| | 54 Rake::ExtensionTask.new("protobuf_c", spec) do |ext| |
55 ext.ext_dir = "ext/google/protobuf_c" | 55 ext.ext_dir = "ext/google/protobuf_c" |
56 ext.lib_dir = "lib/google" | 56 ext.lib_dir = "lib/google" |
57 ext.cross_compile = true | 57 ext.cross_compile = true |
58 ext.cross_platform = [ | 58 ext.cross_platform = [ |
59 'x86-mingw32', 'x64-mingw32', | 59 'x86-mingw32', 'x64-mingw32', |
60 'x86_64-linux', 'x86-linux', | 60 'x86_64-linux', 'x86-linux', |
61 'universal-darwin' | 61 'universal-darwin' |
(...skipping 11 matching lines...) Expand all Loading... |
73 system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0" | 73 system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0" |
74 end | 74 end |
75 else | 75 else |
76 task 'gem:native' => [:genproto, 'gem:windows'] | 76 task 'gem:native' => [:genproto, 'gem:windows'] |
77 end | 77 end |
78 end | 78 end |
79 | 79 |
80 | 80 |
81 # Proto for tests. | 81 # Proto for tests. |
82 genproto_output << "tests/generated_code.rb" | 82 genproto_output << "tests/generated_code.rb" |
83 genproto_output << "tests/test_import.rb" | |
84 file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task| | 83 file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task| |
85 sh "../src/protoc --ruby_out=. tests/generated_code.proto" | 84 sh "../src/protoc --ruby_out=. tests/generated_code.proto" |
86 end | 85 end |
87 | 86 |
88 file "tests/test_import.rb" => "tests/test_import.proto" do |file_task| | |
89 sh "../src/protoc --ruby_out=. tests/test_import.proto" | |
90 end | |
91 | |
92 task :genproto => genproto_output | 87 task :genproto => genproto_output |
93 | 88 |
94 task :clean do | 89 task :clean do |
95 sh "rm -f #{genproto_output.join(' ')}" | 90 sh "rm -f #{genproto_output.join(' ')}" |
96 end | 91 end |
97 | 92 |
98 Gem::PackageTask.new(spec) do |pkg| | 93 Gem::PackageTask.new(spec) do |pkg| |
99 end | 94 end |
100 | 95 |
101 Rake::TestTask.new(:test => :build) do |t| | 96 Rake::TestTask.new(:test => :build) do |t| |
102 t.test_files = FileList["tests/*.rb"] | 97 t.test_files = FileList["tests/*.rb"] |
103 end | 98 end |
104 | 99 |
105 task :build => [:clean, :compile, :genproto] | 100 task :build => [:clean, :compile, :genproto] |
106 task :default => [:build] | 101 task :default => [:build] |
107 | 102 |
108 # vim:sw=2:et | 103 # vim:sw=2:et |
OLD | NEW |