2021-01-15 15:44:50 +03:00
|
|
|
#!/bin/bash
|
2015-12-30 23:19:09 +03:00
|
|
|
|
2021-01-15 15:44:50 +03:00
|
|
|
set -e
|
2018-10-31 07:14:48 +03:00
|
|
|
|
2021-01-15 15:44:50 +03:00
|
|
|
# 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
|
|
|
|
}
|
2018-10-31 07:14:48 +03:00
|
|
|
|
2021-01-15 15:44:50 +03:00
|
|
|
# format formats the *.proto files with the clang-format utility.
|
|
|
|
function format() {
|
|
|
|
find . -name "*.proto" -print0 | xargs -0 clang-format --style=file -i
|
|
|
|
}
|
2020-05-06 17:43:56 +03:00
|
|
|
|
2021-01-15 15:44:50 +03:00
|
|
|
# Compile and format the lnrpc package.
|
|
|
|
pushd lnrpc
|
|
|
|
format
|
|
|
|
generate
|
|
|
|
popd
|
2021-01-15 15:44:54 +03:00
|
|
|
|
|
|
|
if [[ "$COMPILE_MOBILE" == "1" ]]; then
|
|
|
|
pushd mobile
|
|
|
|
./gen_bindings.sh $FALAFEL_VERSION
|
|
|
|
popd
|
|
|
|
fi
|