Skip to content

Commit

Permalink
feat: Use google-protobuf instead of third-party protobuf library (#999)
Browse files Browse the repository at this point in the history
  • Loading branch information
dazuma committed Dec 3, 2023
1 parent 63d010d commit a52af95
Show file tree
Hide file tree
Showing 121 changed files with 2,110 additions and 3,592 deletions.
27 changes: 14 additions & 13 deletions gapic-generator-ads/Gemfile.lock
Expand Up @@ -3,15 +3,17 @@ PATH
specs:
gapic-generator (0.25.1)
actionpack (~> 5.2)
protobuf (~> 3.8)
google-cloud-common (~> 1.2)
google-protobuf (~> 3.25, >= 3.25.1)
googleapis-common-protos-types (~> 1.8)

PATH
remote: .
specs:
gapic-generator-ads (0.25.1)
actionpack (~> 5.2)
gapic-generator (= 0.25.1)
protobuf (~> 3.8)
google-protobuf (~> 3.25, >= 3.25.1)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -40,34 +42,34 @@ GEM
concurrent-ruby (1.2.2)
crass (1.0.6)
erubi (1.12.0)
google-cloud-common (1.3.0)
google-protobuf (~> 3.18)
googleapis-common-protos-types (~> 1.7)
google-protobuf (3.25.1)
google-style (1.26.3)
rubocop (~> 1.31)
grpc-tools (1.58.0)
googleapis-common-protos-types (1.10.0)
google-protobuf (~> 3.18)
grpc-tools (1.59.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
loofah (2.21.4)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
method_source (1.0.0)
middleware (0.1.0)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest-focus (1.4.0)
minitest (>= 4, < 6)
nokogiri (1.15.4)
nokogiri (1.15.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
protobuf (3.10.7)
activesupport (>= 3.2)
middleware
thor
thread_safe
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -100,7 +102,6 @@ GEM
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
thor (1.3.0)
thread_safe (0.3.6)
tzinfo (1.2.11)
thread_safe (~> 0.1)
Expand All @@ -114,7 +115,7 @@ DEPENDENCIES
gapic-generator!
gapic-generator-ads!
google-style (~> 1.26.1)
grpc-tools (~> 1.58.0)
grpc-tools (~> 1.59.2)
minitest (~> 5.16)
minitest-focus (~> 1.0)
pry (>= 0.14)
Expand Down
4 changes: 2 additions & 2 deletions gapic-generator-ads/bin/protoc-gen-bazel_ruby_ads
Expand Up @@ -20,7 +20,7 @@ $LOAD_PATH.unshift ::File.expand_path("../../gapic-generator/lib", __dir__)

require "gapic/generator/version"
require "gapic/runner"
require "google/protobuf/compiler/plugin.pb"
require "google/protobuf/compiler/plugin_pb"

# Ensure that no encoding conversions are done on STDIN and STDOUT
# since we are passing binary data back and forth. Otherwise these
Expand All @@ -33,4 +33,4 @@ request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode $stdin.read
# Run the request, specifying the ads generator
response = Gapic::Runner.run request, generator: :ads

$stdout.print response.serialize
$stdout.print Google::Protobuf::Compiler::CodeGeneratorResponse.encode response
4 changes: 2 additions & 2 deletions gapic-generator-ads/bin/protoc-gen-ruby_ads
Expand Up @@ -19,7 +19,7 @@ $LOAD_PATH.unshift ::File.expand_path("../lib", __dir__)
gem "gapic-generator"
require "gapic/generator/version"
require "gapic/runner"
require "google/protobuf/compiler/plugin.pb"
require "google/protobuf/compiler/plugin_pb"

# Ensure that no encoding conversions are done on STDIN and STDOUT
# since we are passing binary data back and forth. Otherwise these
Expand All @@ -32,4 +32,4 @@ request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode $stdin.read
# Run the request, specifying the ads generator
response = Gapic::Runner.run request, generator: :ads

$stdout.print response.serialize
$stdout.print Google::Protobuf::Compiler::CodeGeneratorResponse.encode response
4 changes: 2 additions & 2 deletions gapic-generator-ads/gapic-generator-ads.gemspec
Expand Up @@ -43,10 +43,10 @@ Gem::Specification.new do |spec|

spec.add_dependency "actionpack", "~> 5.2"
spec.add_dependency "gapic-generator", "= #{Gapic::Generator::Ads::VERSION}"
spec.add_dependency "protobuf", "~> 3.8"
spec.add_dependency "google-protobuf", "~> 3.25", ">= 3.25.1"

spec.add_development_dependency "google-style", "~> 1.26.1"
spec.add_development_dependency "grpc-tools", "~> 1.58.0"
spec.add_development_dependency "grpc-tools", "~> 1.59.2"
spec.add_development_dependency "minitest", "~> 5.16"
spec.add_development_dependency "minitest-focus", "~> 1.0"
spec.add_development_dependency "pry", ">= 0.14"
Expand Down
27 changes: 14 additions & 13 deletions gapic-generator-cloud/Gemfile.lock
Expand Up @@ -3,16 +3,18 @@ PATH
specs:
gapic-generator (0.25.1)
actionpack (~> 5.2)
protobuf (~> 3.8)
google-cloud-common (~> 1.2)
google-protobuf (~> 3.25, >= 3.25.1)
googleapis-common-protos-types (~> 1.8)

PATH
remote: .
specs:
gapic-generator-cloud (0.25.1)
actionpack (~> 5.2)
gapic-generator (= 0.25.1)
google-protobuf (~> 3.25, >= 3.25.1)
google-style (~> 1.26.1)
protobuf (~> 3.8)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -41,18 +43,23 @@ GEM
concurrent-ruby (1.2.2)
crass (1.0.6)
erubi (1.12.0)
google-cloud-common (1.3.0)
google-protobuf (~> 3.18)
googleapis-common-protos-types (~> 1.7)
google-protobuf (3.25.1)
google-style (1.26.3)
rubocop (~> 1.31)
grpc-tools (1.58.0)
googleapis-common-protos-types (1.10.0)
google-protobuf (~> 3.18)
grpc-tools (1.59.2)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
json (2.6.3)
language_server-protocol (3.17.0.3)
loofah (2.21.4)
loofah (2.22.0)
crass (~> 1.0.2)
nokogiri (>= 1.12.0)
method_source (1.0.0)
middleware (0.1.0)
mini_portile2 (2.8.5)
minitest (5.20.0)
minitest-autotest (1.1.1)
Expand All @@ -62,19 +69,14 @@ GEM
minitest (>= 4, < 6)
minitest-server (1.0.7)
minitest (~> 5.16)
nokogiri (1.15.4)
nokogiri (1.15.5)
mini_portile2 (~> 2.8.2)
racc (~> 1.4)
parallel (1.23.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
path_expander (1.1.1)
protobuf (3.10.7)
activesupport (>= 3.2)
middleware
thor
thread_safe
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
Expand Down Expand Up @@ -107,7 +109,6 @@ GEM
rubocop-ast (1.30.0)
parser (>= 3.2.1.0)
ruby-progressbar (1.13.0)
thor (1.3.0)
thread_safe (0.3.6)
tzinfo (1.2.11)
thread_safe (~> 0.1)
Expand All @@ -120,7 +121,7 @@ PLATFORMS
DEPENDENCIES
gapic-generator!
gapic-generator-cloud!
grpc-tools (~> 1.58.0)
grpc-tools (~> 1.59.2)
minitest (~> 5.16)
minitest-autotest (~> 1.0)
minitest-focus (~> 1.0)
Expand Down
4 changes: 2 additions & 2 deletions gapic-generator-cloud/bin/protoc-gen-bazel_ruby_cloud
Expand Up @@ -19,7 +19,7 @@ $LOAD_PATH.unshift ::File.expand_path("../lib", __dir__)
$LOAD_PATH.unshift ::File.expand_path("../../gapic-generator/lib", __dir__)

require "gapic/runner"
require "google/protobuf/compiler/plugin.pb"
require "google/protobuf/compiler/plugin_pb"

# Ensure that no encoding conversions are done on STDIN and STDOUT
# since we are passing binary data back and forth. Otherwise these
Expand All @@ -32,4 +32,4 @@ request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode STDIN.read
# Run the request, specifying the cloud generator
response = Gapic::Runner.run request, generator: :cloud

STDOUT.print response.serialize
STDOUT.print Google::Protobuf::Compiler::CodeGeneratorResponse.encode response
4 changes: 2 additions & 2 deletions gapic-generator-cloud/bin/protoc-gen-ruby_cloud
Expand Up @@ -18,7 +18,7 @@
$LOAD_PATH.unshift ::File.expand_path("../lib", __dir__)
gem "gapic-generator"
require "gapic/runner"
require "google/protobuf/compiler/plugin.pb"
require "google/protobuf/compiler/plugin_pb"

# Ensure that no encoding conversions are done on STDIN and STDOUT
# since we are passing binary data back and forth. Otherwise these
Expand All @@ -31,4 +31,4 @@ request = Google::Protobuf::Compiler::CodeGeneratorRequest.decode STDIN.read
# Run the request, specifying the cloud generator
response = Gapic::Runner.run request, generator: :cloud

STDOUT.print response.serialize
STDOUT.print Google::Protobuf::Compiler::CodeGeneratorResponse.encode response
4 changes: 2 additions & 2 deletions gapic-generator-cloud/gapic-generator-cloud.gemspec
Expand Up @@ -42,10 +42,10 @@ Gem::Specification.new do |spec|

spec.add_dependency "actionpack", "~> 5.2"
spec.add_dependency "gapic-generator", "= #{Gapic::Generator::Cloud::VERSION}"
spec.add_dependency "google-protobuf", "~> 3.25", ">= 3.25.1"
spec.add_dependency "google-style", "~> 1.26.1"
spec.add_dependency "protobuf", "~> 3.8"

spec.add_development_dependency "grpc-tools", "~> 1.58.0"
spec.add_development_dependency "grpc-tools", "~> 1.59.2"
spec.add_development_dependency "minitest", "~> 5.16"
spec.add_development_dependency "minitest-autotest", "~> 1.0"
spec.add_development_dependency "minitest-focus", "~> 1.0"
Expand Down
11 changes: 6 additions & 5 deletions gapic-generator/.rubocop.yml
Expand Up @@ -3,7 +3,7 @@ inherit_gem:

AllCops:
Exclude:
- lib/**/*.pb.rb
- lib/**/*_pb.rb
- expected_output/**/*
- test/gapic/annotations/**/*
- test/gapic/presenters/**/*
Expand All @@ -24,6 +24,9 @@ Metrics/ClassLength:
- test/gapic/routing_headers/**/*_test.rb
Max: 200

Metrics/CyclomaticComplexity:
Max: 15

Metrics/MethodLength:
Exclude:
- lib/gapic/ruby_info.rb
Expand All @@ -32,12 +35,10 @@ Metrics/MethodLength:
- test/gapic/routing_headers/**/*_test.rb

Metrics/ModuleLength:
Exclude:
- lib/gapic/grpc_service_config/parser.rb
Max: 200

Metrics/PerceivedComplexity:
Exclude:
- test/gapic/routing_headers/explicit_routing_headers_input_match_test.rb
Max: 15

Style/Documentation:
Exclude:
Expand Down
30 changes: 30 additions & 0 deletions gapic-generator/.toys/generate-protos.rb
@@ -0,0 +1,30 @@
# frozen_string_literal: true

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

include :gems
include :exec, e: true

def run
gem "grpc-tools", "~> 1.57"
exec [
"grpc_tools_ruby_protoc",
"--ruby_out=lib",
"-I", "./protos",
"google/protobuf/compiler/plugin.proto",
"google/cloud/tools/snippetgen/configlanguage/v1/snippet_config_language.proto",
"google/cloud/tools/snippetgen/snippetindex/v1/snippet_index.proto",
]
end

0 comments on commit a52af95

Please sign in to comment.