2014-12-24 14:48:41 +00:00
|
|
|
require "rubygems"
|
|
|
|
require "rubygems/package_task"
|
|
|
|
require "rake/extensiontask" unless RUBY_PLATFORM == "java"
|
2014-11-18 22:19:58 +00:00
|
|
|
require "rake/testtask"
|
|
|
|
|
2014-12-12 23:58:26 +00:00
|
|
|
spec = Gem::Specification.load("google-protobuf.gemspec")
|
2014-11-18 22:19:58 +00:00
|
|
|
|
2016-04-29 18:00:43 +00:00
|
|
|
well_known_protos = %w[
|
|
|
|
google/protobuf/any.proto
|
|
|
|
google/protobuf/api.proto
|
2021-07-31 18:13:08 +00:00
|
|
|
google/protobuf/descriptor.proto
|
2016-04-29 18:00:43 +00:00
|
|
|
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
|
|
|
|
]
|
|
|
|
|
2021-05-18 05:40:33 +00:00
|
|
|
test_protos = %w[
|
|
|
|
tests/basic_test.proto
|
|
|
|
tests/basic_test_proto2.proto
|
|
|
|
tests/generated_code.proto
|
|
|
|
tests/generated_code_proto2.proto
|
|
|
|
tests/multi_level_nesting_test.proto
|
|
|
|
tests/test_import.proto
|
|
|
|
tests/test_import_proto2.proto
|
|
|
|
tests/test_ruby_package.proto
|
|
|
|
tests/test_ruby_package_proto2.proto
|
|
|
|
]
|
|
|
|
|
2016-04-29 18:00:43 +00:00
|
|
|
# These are omitted for now because we don't support proto2.
|
|
|
|
proto2_protos = %w[
|
|
|
|
google/protobuf/descriptor.proto
|
|
|
|
google/protobuf/compiler/plugin.proto
|
|
|
|
]
|
|
|
|
|
2021-04-12 17:06:44 +00:00
|
|
|
if system('../src/protoc --version')
|
|
|
|
protoc_command = '../src/protoc'
|
|
|
|
else
|
|
|
|
protoc_command = 'protoc'
|
|
|
|
end
|
|
|
|
|
2016-04-29 18:00:43 +00:00
|
|
|
genproto_output = []
|
|
|
|
|
2016-04-30 00:14:18 +00:00
|
|
|
# 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.
|
2016-04-29 18:00:43 +00:00
|
|
|
unless ENV['IN_DOCKER'] == 'true'
|
|
|
|
well_known_protos.each do |proto_file|
|
|
|
|
input_file = "../src/" + proto_file
|
2016-07-25 08:47:50 +00:00
|
|
|
output_file = "lib/" + proto_file.sub(/\.proto$/, "_pb.rb")
|
2016-04-29 18:00:43 +00:00
|
|
|
genproto_output << output_file
|
|
|
|
file output_file => input_file do |file_task|
|
2021-04-12 17:06:44 +00:00
|
|
|
sh "#{protoc_command} -I../src --ruby_out=lib #{input_file}"
|
2016-04-29 18:00:43 +00:00
|
|
|
end
|
|
|
|
end
|
2021-05-18 05:40:33 +00:00
|
|
|
|
|
|
|
test_protos.each do |proto_file|
|
|
|
|
output_file = proto_file.sub(/\.proto$/, "_pb.rb")
|
|
|
|
genproto_output << output_file
|
|
|
|
file output_file => proto_file do |file_task|
|
2021-09-22 16:16:09 +00:00
|
|
|
sh "#{protoc_command} -I../src -I. -I./tests --ruby_out=. #{proto_file}"
|
2021-05-18 05:40:33 +00:00
|
|
|
end
|
|
|
|
end
|
2016-04-29 18:00:43 +00:00
|
|
|
end
|
|
|
|
|
2014-12-24 14:48:41 +00:00
|
|
|
if RUBY_PLATFORM == "java"
|
2015-05-01 18:54:29 +00:00
|
|
|
if `which mvn` == ''
|
|
|
|
raise ArgumentError, "maven needs to be installed"
|
|
|
|
end
|
2014-12-24 14:48:41 +00:00
|
|
|
task :clean do
|
2016-12-03 16:51:25 +00:00
|
|
|
system("mvn --batch-mode clean")
|
2014-12-24 14:48:41 +00:00
|
|
|
end
|
2014-11-18 22:19:58 +00:00
|
|
|
|
2014-12-24 14:48:41 +00:00
|
|
|
task :compile do
|
2016-12-03 16:51:25 +00:00
|
|
|
system("mvn --batch-mode package")
|
2014-12-24 14:48:41 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
Rake::ExtensionTask.new("protobuf_c", spec) do |ext|
|
2018-04-25 16:52:30 +00:00
|
|
|
unless RUBY_PLATFORM =~ /darwin/
|
|
|
|
# TODO: also set "no_native to true" for mac if possible. As is,
|
|
|
|
# "no_native" can only be set if the RUBY_PLATFORM doing
|
|
|
|
# cross-compilation is contained in the "ext.cross_platform" array.
|
|
|
|
ext.no_native = true
|
|
|
|
end
|
2014-12-24 14:48:41 +00:00
|
|
|
ext.ext_dir = "ext/google/protobuf_c"
|
|
|
|
ext.lib_dir = "lib/google"
|
2016-02-05 23:55:45 +00:00
|
|
|
ext.cross_compile = true
|
|
|
|
ext.cross_platform = [
|
|
|
|
'x86-mingw32', 'x64-mingw32',
|
|
|
|
'x86_64-linux', 'x86-linux',
|
|
|
|
'universal-darwin'
|
|
|
|
]
|
2014-12-24 14:48:41 +00:00
|
|
|
end
|
2016-02-04 18:44:22 +00:00
|
|
|
|
|
|
|
task 'gem:windows' do
|
|
|
|
require 'rake_compiler_dock'
|
2020-04-17 06:31:47 +00:00
|
|
|
['x86-mingw32', 'x64-mingw32', 'x86_64-linux', 'x86-linux'].each do |plat|
|
|
|
|
RakeCompilerDock.sh <<-"EOT", platform: plat
|
|
|
|
bundle && \
|
Ported Ruby extension to upb_msg (#8184)
* WIP.
* WIP.
* WIP.
* WIP.
* WIP.
* WIP.
* Added some missing files.
* WIP.
* WIP.
* Updated upb.
* Extension loads, but crashes immediately.
* Gets through the test suite without SEGV!
Still a lot of bugs to fix, but it is a major step!
214 tests, 378 assertions, 37 failures, 147 errors, 0 pendings, 0 omissions, 0 notifications
14.0187% passed
* Test and build for Ruby 3.0
* Fixed a few more bugs, efficient #inspect is almost done.
214 tests, 134243 assertions, 30 failures, 144 errors, 0 pendings, 0 omissions, 0 notifications
18.6916% passed
* Fixed message hash initialization and encode depth checking.
214 tests, 124651 assertions, 53 failures, 70 errors, 0 pendings, 0 omissions, 0 notifications
42.5234% passed
* A bunch of fixes to failing tests, now 70% passing.
214 tests, 202091 assertions, 41 failures, 23 errors, 0 pendings, 0 omissions, 0 notifications
70.0935% passed
* More than 80% of tests are passing now.
214 tests, 322331 assertions, 30 failures, 9 errors, 0 pendings, 0 omissions, 0 notifications
81.7757% passed
Unfortunately there is also a sporadic bug/segfault hanging around
that appears to be GC-related.
* Add linux/ruby30 and macos/ruby30
* Use rvm master for 3.0.0-preview2
* Over 90% of tests are passing!
214 tests, 349898 assertions, 15 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
92.5234% passed
* Passes all tests!
214 tests, 369388 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
* A bunch of cleanup.
1. Removed a bunch of internal-only symbols from headers.
2. Required a frozen check to get a non-const pointer to a map or array.
3. De-duplicated the code to get a type argument for Map/RepeatedField.
* Removed a bunch more stuff from protobuf.h. There is an intermittent assert failure.
Intermittent failure:
ruby: ../../../../ext/google/protobuf_c/protobuf.c:263: ObjectCache_Add: Assertion `rb_funcall(obj_cache2, (__builtin_constant_p("[]") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2((("[]")
), (long)strlen(("[]"))); (ID) rb_intern_id_cache; }) : rb_intern("[]")), 1, key_rb) == val' failed
* Removed a few more things from protobuf.h.
* Ruby 3.0.0-preview2 to 3.0.0
* Require rake-compiler-dock >= 1.1.0
* More progress, fighting with the object cache.
* Passes on all Ruby versions!
* Updated and clarified comment regarding WeakMap.
* Fixed the wyhash compile.
* Fixed conformance tests for Ruby.
Conformance results now look like:
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
CONFORMANCE TEST BEGIN ====================================
CONFORMANCE SUITE PASSED: 1955 successes, 0 skipped, 58 expected failures, 0 unexpected failures.
CONFORMANCE TEST BEGIN ====================================
CONFORMANCE SUITE PASSED: 0 successes, 111 skipped, 8 expected failures, 0 unexpected failures.
Fixes include:
- Changed Ruby compiler to no longer reject proto2 maps.
- Changed Ruby compiler to emit a warning when proto2 extensions are
present instead of rejecting the .proto file completely.
- Fixed conformance tests to allow proto2 and look up message by name
instead of hardcoding a specific list of messages.
- Fixed conformance test to support the "ignore unknown" option for
JSON.
- Fixed conformance test to properly report serialization errors.
* Removed debug printf and fixed #inspect for floats.
* Fixed compatibility test to have proper semantics for #to_json.
* Updated Makefile.am with new file list.
* Don't try to copy wyhash when inside Docker.
* Fixed bug where we would forget that a sub-object is frozen in Ruby >=2.7.
* Avoid exporting unneeded symbols and refactored a bit of code.
* Some more refactoring.
* Simplified and added more comments.
* Some more comments and simplification. Added a missing license block.
Co-authored-by: Masaki Hara <hara@wantedly.com>
2021-01-13 20:16:25 +00:00
|
|
|
IN_DOCKER=true rake native:#{plat} pkg/#{spec.full_name}-#{plat}.gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.0:2.4.0:2.3.0
|
2020-04-17 06:31:47 +00:00
|
|
|
EOT
|
|
|
|
end
|
2016-02-04 18:44:22 +00:00
|
|
|
end
|
2014-11-18 22:19:58 +00:00
|
|
|
|
2016-04-30 00:14:18 +00:00
|
|
|
if RUBY_PLATFORM =~ /darwin/
|
|
|
|
task 'gem:native' do
|
2016-05-04 00:29:17 +00:00
|
|
|
system "rake genproto"
|
Ported Ruby extension to upb_msg (#8184)
* WIP.
* WIP.
* WIP.
* WIP.
* WIP.
* WIP.
* Added some missing files.
* WIP.
* WIP.
* Updated upb.
* Extension loads, but crashes immediately.
* Gets through the test suite without SEGV!
Still a lot of bugs to fix, but it is a major step!
214 tests, 378 assertions, 37 failures, 147 errors, 0 pendings, 0 omissions, 0 notifications
14.0187% passed
* Test and build for Ruby 3.0
* Fixed a few more bugs, efficient #inspect is almost done.
214 tests, 134243 assertions, 30 failures, 144 errors, 0 pendings, 0 omissions, 0 notifications
18.6916% passed
* Fixed message hash initialization and encode depth checking.
214 tests, 124651 assertions, 53 failures, 70 errors, 0 pendings, 0 omissions, 0 notifications
42.5234% passed
* A bunch of fixes to failing tests, now 70% passing.
214 tests, 202091 assertions, 41 failures, 23 errors, 0 pendings, 0 omissions, 0 notifications
70.0935% passed
* More than 80% of tests are passing now.
214 tests, 322331 assertions, 30 failures, 9 errors, 0 pendings, 0 omissions, 0 notifications
81.7757% passed
Unfortunately there is also a sporadic bug/segfault hanging around
that appears to be GC-related.
* Add linux/ruby30 and macos/ruby30
* Use rvm master for 3.0.0-preview2
* Over 90% of tests are passing!
214 tests, 349898 assertions, 15 failures, 1 errors, 0 pendings, 0 omissions, 0 notifications
92.5234% passed
* Passes all tests!
214 tests, 369388 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
* A bunch of cleanup.
1. Removed a bunch of internal-only symbols from headers.
2. Required a frozen check to get a non-const pointer to a map or array.
3. De-duplicated the code to get a type argument for Map/RepeatedField.
* Removed a bunch more stuff from protobuf.h. There is an intermittent assert failure.
Intermittent failure:
ruby: ../../../../ext/google/protobuf_c/protobuf.c:263: ObjectCache_Add: Assertion `rb_funcall(obj_cache2, (__builtin_constant_p("[]") ? __extension__ ({ static ID rb_intern_id_cache; if (!rb_intern_id_cache) rb_intern_id_cache = rb_intern2((("[]")
), (long)strlen(("[]"))); (ID) rb_intern_id_cache; }) : rb_intern("[]")), 1, key_rb) == val' failed
* Removed a few more things from protobuf.h.
* Ruby 3.0.0-preview2 to 3.0.0
* Require rake-compiler-dock >= 1.1.0
* More progress, fighting with the object cache.
* Passes on all Ruby versions!
* Updated and clarified comment regarding WeakMap.
* Fixed the wyhash compile.
* Fixed conformance tests for Ruby.
Conformance results now look like:
RUBYLIB=../ruby/lib:. ./conformance-test-runner --enforce_recommended --failure_list failure_list_ruby.txt --text_format_failure_list text_format_failure_list_ruby.txt ./conformance_ruby.rb
CONFORMANCE TEST BEGIN ====================================
CONFORMANCE SUITE PASSED: 1955 successes, 0 skipped, 58 expected failures, 0 unexpected failures.
CONFORMANCE TEST BEGIN ====================================
CONFORMANCE SUITE PASSED: 0 successes, 111 skipped, 8 expected failures, 0 unexpected failures.
Fixes include:
- Changed Ruby compiler to no longer reject proto2 maps.
- Changed Ruby compiler to emit a warning when proto2 extensions are
present instead of rejecting the .proto file completely.
- Fixed conformance tests to allow proto2 and look up message by name
instead of hardcoding a specific list of messages.
- Fixed conformance test to support the "ignore unknown" option for
JSON.
- Fixed conformance test to properly report serialization errors.
* Removed debug printf and fixed #inspect for floats.
* Fixed compatibility test to have proper semantics for #to_json.
* Updated Makefile.am with new file list.
* Don't try to copy wyhash when inside Docker.
* Fixed bug where we would forget that a sub-object is frozen in Ruby >=2.7.
* Avoid exporting unneeded symbols and refactored a bit of code.
* Some more refactoring.
* Simplified and added more comments.
* Some more comments and simplification. Added a missing license block.
Co-authored-by: Masaki Hara <hara@wantedly.com>
2021-01-13 20:16:25 +00:00
|
|
|
system "rake cross native gem RUBY_CC_VERSION=3.0.0:2.7.0:2.6.0:2.5.1:2.4.0:2.3.0"
|
2016-04-30 00:14:18 +00:00
|
|
|
end
|
|
|
|
else
|
|
|
|
task 'gem:native' => [:genproto, 'gem:windows']
|
|
|
|
end
|
2016-03-03 22:08:54 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
task :genproto => genproto_output
|
|
|
|
|
|
|
|
task :clean do
|
|
|
|
sh "rm -f #{genproto_output.join(' ')}"
|
|
|
|
end
|
|
|
|
|
2014-11-18 22:19:58 +00:00
|
|
|
Gem::PackageTask.new(spec) do |pkg|
|
|
|
|
end
|
|
|
|
|
2021-05-18 05:40:33 +00:00
|
|
|
Rake::TestTask.new(:test => [:build, :genproto]) do |t|
|
2017-08-25 19:11:15 +00:00
|
|
|
t.test_files = FileList["tests/*.rb"].exclude("tests/gc_test.rb", "tests/common_tests.rb")
|
2017-10-04 00:28:49 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
# gc_test needs to be split out to ensure the generated file hasn't been
|
|
|
|
# imported by other tests.
|
|
|
|
Rake::TestTask.new(:gc_test => :build) do |t|
|
|
|
|
t.test_files = FileList["tests/gc_test.rb"]
|
2014-12-24 14:48:41 +00:00
|
|
|
end
|
|
|
|
|
2021-05-18 05:40:33 +00:00
|
|
|
task :build => [:clean, :genproto, :compile]
|
2014-11-18 22:19:58 +00:00
|
|
|
task :default => [:build]
|
|
|
|
|
|
|
|
# vim:sw=2:et
|