diff options
author | Colin Cross <ccross@android.com> | 2018-10-25 14:37:27 -0700 |
---|---|---|
committer | Colin Cross <ccross@android.com> | 2018-10-25 14:37:34 -0700 |
commit | f4fe6ab6726e235448020c5fd203e4fc1dad728e (patch) | |
tree | 172e736d6c7428f6afd8f706fb3eae2e8ac786b3 /ruby/Rakefile | |
parent | 6e463f53f1f82dfe0a74e25ae729601a9678730c (diff) | |
parent | b0f5cf02f86449e35377c9ff7b9c0f727d3bf63b (diff) | |
download | protobuf-javalite-f4fe6ab6726e235448020c5fd203e4fc1dad728e.tar.gz |
Merge tag 'v3.0.1-javalite'
Test: m checkbuild
Change-Id: If5b58ea9b85a243ef67c30b182d7ce748c8eb734
Diffstat (limited to 'ruby/Rakefile')
-rw-r--r-- | ruby/Rakefile | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/ruby/Rakefile b/ruby/Rakefile new file mode 100644 index 00000000..fa29c315 --- /dev/null +++ b/ruby/Rakefile @@ -0,0 +1,103 @@ +require "rubygems" +require "rubygems/package_task" +require "rake/extensiontask" unless RUBY_PLATFORM == "java" +require "rake/testtask" + +spec = Gem::Specification.load("google-protobuf.gemspec") + +well_known_protos = %w[ + google/protobuf/any.proto + google/protobuf/api.proto + google/protobuf/duration.proto + google/protobuf/empty.proto + google/protobuf/field_mask.proto + google/protobuf/source_context.proto + google/protobuf/struct.proto + google/protobuf/timestamp.proto + google/protobuf/type.proto + google/protobuf/wrappers.proto +] + +# These are omitted for now because we don't support proto2. +proto2_protos = %w[ + google/protobuf/descriptor.proto + google/protobuf/compiler/plugin.proto +] + +genproto_output = [] + +# We won't have access to .. from within docker, but the proto files +# will be there, thanks to the :genproto rule dependency for gem:native. +unless ENV['IN_DOCKER'] == 'true' + well_known_protos.each do |proto_file| + input_file = "../src/" + proto_file + output_file = "lib/" + proto_file.sub(/\.proto$/, ".rb") + genproto_output << output_file + file output_file => input_file do |file_task| + sh "../src/protoc -I../src --ruby_out=lib #{input_file}" + end + end +end + +if RUBY_PLATFORM == "java" + if `which mvn` == '' + raise ArgumentError, "maven needs to be installed" + end + task :clean do + system("mvn clean") + end + + task :compile do + system("mvn package") + end +else + Rake::ExtensionTask.new("protobuf_c", spec) do |ext| + ext.ext_dir = "ext/google/protobuf_c" + ext.lib_dir = "lib/google" + ext.cross_compile = true + ext.cross_platform = [ + 'x86-mingw32', 'x64-mingw32', + 'x86_64-linux', 'x86-linux', + 'universal-darwin' + ] + end + + task 'gem:windows' do + require 'rake_compiler_dock' + RakeCompilerDock.sh "bundle && IN_DOCKER=true rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0" + end + + if RUBY_PLATFORM =~ /darwin/ + task 'gem:native' do + system "rake genproto" + system "rake cross native gem RUBY_CC_VERSION=2.3.0:2.2.2:2.1.5:2.0.0" + end + else + task 'gem:native' => [:genproto, 'gem:windows'] + end +end + + +# Proto for tests. +genproto_output << "tests/generated_code.rb" +file "tests/generated_code.rb" => "tests/generated_code.proto" do |file_task| + sh "../src/protoc --ruby_out=. tests/generated_code.proto" +end + +task :genproto => genproto_output + +task :clean do + sh "rm -f #{genproto_output.join(' ')}" +end + +Gem::PackageTask.new(spec) do |pkg| +end + +Rake::TestTask.new(:test => :build) do |t| + t.test_files = FileList["tests/*.rb"] +end + +task :build => [:clean, :compile, :genproto] +task :default => [:build] + +# vim:sw=2:et |