Skip to content

Commit

Permalink
Set up protobuf gem
Browse files Browse the repository at this point in the history
  • Loading branch information
soutaro committed Jul 7, 2020
1 parent b6d9168 commit d09b4a3
Show file tree
Hide file tree
Showing 9 changed files with 78 additions and 1,094 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
/pkg/
/spec/reports/
/tmp/
/lib/google/protobuf/descriptor_pb.rb
/lib/google/protobuf/plugin_pb.rb
/lib/google/protobuf/descriptor.pb.rb
/lib/google/protobuf/compiler/plugin.pb.rb
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ gem "rake", "~> 12.0"
gem "minitest", "~> 5.0"

gem "rbs", path: "../rbs"
gem "google-protobuf"
12 changes: 10 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ PATH
specs:
rbs_protobuf (0.1.0)
activesupport (>= 4.0)
google-protobuf (~> 3.12)
protobuf (~> 3.10.3)
rbs (~> 0.4.0)

GEM
Expand All @@ -21,11 +21,18 @@ GEM
tzinfo (~> 1.1)
zeitwerk (~> 2.2, >= 2.2.2)
concurrent-ruby (1.1.6)
google-protobuf (3.12.2)
google-protobuf (3.12.2-universal-darwin)
i18n (1.8.3)
concurrent-ruby (~> 1.0)
middleware (0.1.0)
minitest (5.14.1)
protobuf (3.10.3)
activesupport (>= 3.2)
middleware
thor
thread_safe
rake (12.3.3)
thor (1.0.1)
thread_safe (0.3.6)
tzinfo (1.2.7)
thread_safe (~> 0.1)
Expand All @@ -35,6 +42,7 @@ PLATFORMS
ruby

DEPENDENCIES
google-protobuf
minitest (~> 5.0)
rake (~> 12.0)
rbs!
Expand Down
29 changes: 29 additions & 0 deletions bin/protoc-gen-ruby
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'protoc-gen-ruby' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("protobuf", "protoc-gen-ruby")
29 changes: 29 additions & 0 deletions bin/rpc_server
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/usr/bin/env ruby
# frozen_string_literal: true

#
# This file was generated by Bundler.
#
# The application 'rpc_server' is installed as part of a gem, and
# this file is here to facilitate running it.
#

require "pathname"
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile",
Pathname.new(__FILE__).realpath)

bundle_binstub = File.expand_path("../bundle", __FILE__)

if File.file?(bundle_binstub)
if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
load(bundle_binstub)
else
abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
end
end

require "rubygems"
require "bundler/setup"

load Gem.bin_path("protobuf", "rpc_server")
8 changes: 6 additions & 2 deletions bin/setup
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,9 @@ set -vx
bundle install

mkdir -p lib/google/protobuf
protoc -Iprotos --ruby_out=lib/google/protobuf protos/descriptor.proto
protoc -Iprotos --ruby_out=lib/google/protobuf protos/plugin.proto

SCRIPT_DIR=$(cd $(dirname $0); pwd)
protoc --plugin=protoc-gen-ruby-protobuf=${SCRIPT_DIR}/protoc-gen-ruby \
--ruby-protobuf_out=lib \
-I vendor/protobuf/src \
vendor/protobuf/src/google/protobuf/compiler/plugin.proto
Loading

0 comments on commit d09b4a3

Please sign in to comment.