Browse Source

Add script to generate LND ruby GRPC service files

feature/payment-response-wrapper
bumi 2 years ago
parent
commit
fbf38c255e
  1. 16
      README.md
  2. 30
      generate-grpc-service-files.sh

16
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

30
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
Loading…
Cancel
Save