From fbf38c255eeef1c96f63bc52ceccea430a7474b8 Mon Sep 17 00:00:00 2001 From: Michael Bumann Date: Fri, 28 Aug 2020 14:37:57 +0200 Subject: [PATCH] Add script to generate LND ruby GRPC service files --- README.md | 16 +++------------- generate-grpc-service-files.sh | 30 ++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 13 deletions(-) create mode 100755 generate-grpc-service-files.sh diff --git a/README.md b/README.md index 3ca5cd7..263eaa6 100644 --- a/README.md +++ b/README.md @@ -159,21 +159,11 @@ see [rubygems](https://rubygems.org/gems/lnrpc) for all available releases. ### Update service definitions -1. Generate `prc_pb.rb` and `rpc_services_pb.rb` +The script `generate-grpc-service-files.sh` can be used to generate the GRPC ruby files. +The files will be stored in `lib/grpc_services` - $ grpc_tools_ruby_protoc -I/usr/local/include -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis --ruby_out=plugins=grpc,paths=source_relative:. --grpc_out=. rpc.proto + $ ./generate-grpc-service-files.sh -2. Copy `rpc.proto`, `rpc_pb.rb` and `rpc_services_pb.rb` to `lib` - -3. Update `rpc_services_pb.rb` to use `require_relative` to load `rpc_pb` - -4. Generate `router_pb.rb` and `router_services_pb.rb` - - $ grpc_tools_ruby_protoc -I/usr/local/include -I. -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis -I$GOPATH/src/github.com/lightningnetwork/lnd/lnrpc --ruby_out=plugins=grpc,paths=source_relative:. --grpc_out=. router.proto - -5. Copy `router.proto`, `router_pb.rb` and `router_services_pb.rb` to `lib` - -6. Update `router_services_pb.rb` to use `require_relative` to load `router_pb` ## Other resources diff --git a/generate-grpc-service-files.sh b/generate-grpc-service-files.sh new file mode 100755 index 0000000..787ffa2 --- /dev/null +++ b/generate-grpc-service-files.sh @@ -0,0 +1,30 @@ +#!/bin/sh +set -o xtrace + +FULL_PATH=$(realpath $0) +GEM_DIR=$(dirname $FULL_PATH) +LNRPC_TARGET_DIR="$GEM_DIR/lib/grpc_services" +CURRENT_DIR=$(pwd) +echo $CURRENT_DIR +cd $GOPATH/src/github.com/lightningnetwork/lnd/lnrpc + +echo "Generating Ruby GRPC Service Files" + +PROTOS="rpc.proto walletunlocker.proto **/*.proto" + +# generate files for each proto +for file in $PROTOS; do + DIRECTORY=$(dirname "${file}") + echo "Generating protos from ${file}, into ${LNRPC_TARGET_DIR}/${DIRECTORY}" + + # writes all ruby files in the ruby directory + grpc_tools_ruby_protoc -I/usr/local/include \ + -I. \ + -I$GOPATH/src/github.com/grpc-ecosystem/grpc-gateway/third_party/googleapis \ + -I$GOPATH/src/github.com/lightningnetwork/lnd/lnrpc \ + --ruby_out=plugins=grpc,paths=source_relative:${LNRPC_TARGET_DIR} \ + --grpc_out=${LNRPC_TARGET_DIR} "${file}" + +done + +cd $CURRENT_DIR