From 834e684eb1a9615d33ac4a5a626af0ab8884c2a6 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Mon, 13 Apr 2020 12:11:15 +0200 Subject: [PATCH 1/6] Load correct versions of pry and pry-byebug on older Rubies This does two things: - Move complex dependency logic out of the gemspec. The gemspec logic is only evaluated at build time, so keeping Ruby version dependendent logic in there causes different gems to be published depending on the source machine. - Load slightly older pry versions on Ruby 2.3 and lower, so they work with the pry-byebug version that supports those older Ruby versions. --- Gemfile | 23 +++++++++++++++++++++++ protobuf.gemspec | 19 ------------------- 2 files changed, 23 insertions(+), 19 deletions(-) diff --git a/Gemfile b/Gemfile index fa75df15..a19bf744 100644 --- a/Gemfile +++ b/Gemfile @@ -1,3 +1,26 @@ source 'https://rubygems.org' gemspec + +group :development do + # debuggers only work in MRI + if RUBY_ENGINE.to_sym == :ruby + if RUBY_VERSION < '2.0.0' + gem 'pry-debugger' + elsif RUBY_VERSION < '2.4.0' + gem 'pry-byebug' + gem 'pry', '~> 0.12.0' + else + gem 'pry-byebug', '~> 3.9.0' + gem 'pry', '~> 0.13.0' + end + + gem 'pry-stack_explorer' + + gem 'varint' + gem 'ruby-prof' + elsif RUBY_PLATFORM =~ /java/i + gem 'fast_blank_java' + gem 'pry' + end +end diff --git a/protobuf.gemspec b/protobuf.gemspec index 4f182c4e..9cad244b 100644 --- a/protobuf.gemspec +++ b/protobuf.gemspec @@ -35,23 +35,4 @@ require "protobuf/version" s.add_development_dependency 'simplecov' s.add_development_dependency 'timecop' s.add_development_dependency 'yard' - - # debuggers only work in MRI - if RUBY_ENGINE.to_sym == :ruby - # we don't support MRI < 1.9.3 - pry_debugger = if RUBY_VERSION < '2.0.0' - 'pry-debugger' - else - 'pry-byebug' - end - - s.add_development_dependency pry_debugger - s.add_development_dependency 'pry-stack_explorer' - - s.add_development_dependency 'varint' - s.add_development_dependency 'ruby-prof' - elsif RUBY_PLATFORM =~ /java/i - s.add_development_dependency 'fast_blank_java' - s.add_development_dependency 'pry' - end end From 5b4892fb271fa2d23ce9fd01cde71ae6f3233842 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sat, 30 Nov 2019 08:56:02 +0100 Subject: [PATCH 2/6] Fix code generation in spec task to work with proto3 Taken from 8e7c96a820ac42783611a1e72ada6adc93fade7d by Garret Thornburg --- Rakefile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Rakefile b/Rakefile index 8df9895f..590ad9fe 100644 --- a/Rakefile +++ b/Rakefile @@ -22,7 +22,7 @@ namespace :compile do task :spec do proto_path = ::File.expand_path('../spec/support/', __FILE__) proto_files = Dir[File.join(proto_path, '**', '*.proto')] - cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{proto_path} -I #{proto_path} #{proto_files.join(' ')}) + cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{proto_path} -I #{proto_path} #{proto_files.join(' ')}) puts cmd system(cmd) @@ -35,7 +35,7 @@ namespace :compile do output_dir = ::File.expand_path('../tmp/rpc', __FILE__) ::FileUtils.mkdir_p(output_dir) - cmd = %(protoc --plugin=./bin/protoc-gen-ruby --ruby_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')}) + cmd = %(protoc --plugin=protoc-gen-ruby-protobuf=./bin/protoc-gen-ruby --ruby-protobuf_out=#{output_dir} -I #{proto_path} #{proto_files.join(' ')}) puts cmd system(cmd) From f6be22e33ba72122a923f97f67308a4eeed0f0a4 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Dec 2019 11:44:47 +0100 Subject: [PATCH 3/6] Do not allow build failures with protobuf 3.0.0 --- .travis.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f89eb2e6..329eb381 100644 --- a/.travis.yml +++ b/.travis.yml @@ -30,7 +30,6 @@ env: matrix: allow_failures: - rvm: rbx-2 - - env: PROTOBUF_VERSION=3.0.0-alpha-2 notifications: webhooks: urls: From 113345b00351755a90133ba0b335200ae219dd66 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Dec 2019 11:43:58 +0100 Subject: [PATCH 4/6] Build with released version of protobuf 3.0.0 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 329eb381..9781b12c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -26,7 +26,7 @@ rvm: - rbx-2 env: - PROTOBUF_VERSION=2.6.1 - - PROTOBUF_VERSION=3.0.0-alpha-2 + - PROTOBUF_VERSION=3.0.0 matrix: allow_failures: - rvm: rbx-2 From 617f1dcef66b42f68bc0b983744cdae690f94cf4 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Dec 2019 11:49:02 +0100 Subject: [PATCH 5/6] Build with a larger selection of protobuf versions --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index 9781b12c..138fe888 100644 --- a/.travis.yml +++ b/.travis.yml @@ -27,6 +27,8 @@ rvm: env: - PROTOBUF_VERSION=2.6.1 - PROTOBUF_VERSION=3.0.0 + - PROTOBUF_VERSION=3.6.0 + - PROTOBUF_VERSION=3.11.0 matrix: allow_failures: - rvm: rbx-2 From f1449b3dcb121dae4d34991559551e4582d92da3 Mon Sep 17 00:00:00 2001 From: Matijs van Zuijlen Date: Sun, 1 Dec 2019 12:09:12 +0100 Subject: [PATCH 6/6] Make RuboCop ignore Ruby files in downloaded protobuf source --- .rubocop.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.rubocop.yml b/.rubocop.yml index 310aa0c8..f1df78d3 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -5,6 +5,7 @@ AllCops: Exclude: - 'spec/support/protos/*.pb.rb' - 'varint_prof.rb' + - 'protobuf-*/**/*.rb' Lint/EndAlignment: AlignWith: keyword