make+lnrpc: use docker to compile protos
This commit aims to make it easier for developers to compile our protobuf definitions. They now only need to have docker installed instead of a whole set of binaries and libraries all pinned to very specific versions.
This commit is contained in:
4 files changed
+86
-25
No files matched your search
+40
-24
@@ -1,28 +1,44 @@
|
||||
#!/bin/sh
|
||||
#!/bin/bash
|
||||
|
||||
echo "Generating root gRPC server protos"
|
||||
set -e
|
||||
|
||||
PROTOS="rpc.proto walletunlocker.proto **/*.proto"
|
||||
# generate compiles the *.pb.go stubs from the *.proto files.
|
||||
function generate() {
|
||||
echo "Generating root gRPC server protos"
|
||||
|
||||
PROTOS="rpc.proto walletunlocker.proto **/*.proto"
|
||||
|
||||
# For each of the sub-servers, we then generate their protos, but a restricted
|
||||
# set as they don't yet require REST proxies, or swagger docs.
|
||||
for file in $PROTOS; do
|
||||
DIRECTORY=$(dirname "${file}")
|
||||
echo "Generating protos from ${file}, into ${DIRECTORY}"
|
||||
|
||||
# Generate the protos.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--go_out=plugins=grpc,paths=source_relative:. \
|
||||
"${file}"
|
||||
|
||||
# Generate the REST reverse proxy.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"${file}"
|
||||
|
||||
|
||||
# Finally, generate the swagger file which describes the REST API in detail.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--swagger_out=logtostderr=true,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"${file}"
|
||||
done
|
||||
}
|
||||
|
||||
# For each of the sub-servers, we then generate their protos, but a restricted
|
||||
# set as they don't yet require REST proxies, or swagger docs.
|
||||
for file in $PROTOS; do
|
||||
DIRECTORY=$(dirname "${file}")
|
||||
echo "Generating protos from ${file}, into ${DIRECTORY}"
|
||||
# format formats the *.proto files with the clang-format utility.
|
||||
function format() {
|
||||
find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i
|
||||
}
|
||||
|
||||
# Generate the protos.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--go_out=plugins=grpc,paths=source_relative:. \
|
||||
"${file}"
|
||||
|
||||
# Generate the REST reverse proxy.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--grpc-gateway_out=logtostderr=true,paths=source_relative,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"${file}"
|
||||
|
||||
|
||||
# Finally, generate the swagger file which describes the REST API in detail.
|
||||
protoc -I/usr/local/include -I. \
|
||||
--swagger_out=logtostderr=true,grpc_api_configuration=rest-annotations.yaml:. \
|
||||
"${file}"
|
||||
done
|
||||
# Compile and format the lnrpc package.
|
||||
pushd lnrpc
|
||||
format
|
||||
generate
|
||||
popd
|
||||
Reference in new issue
Block a user