-
Notifications
You must be signed in to change notification settings - Fork 437
/
protogen.sh
executable file
·34 lines (28 loc) · 1.1 KB
/
protogen.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/bash
mkdir -p ./ts/_proto
mkdir -p ./go/_proto
if [[ "$GOBIN" == "" ]]; then
if [[ "$GOPATH" == "" ]]; then
echo "Required env var GOPATH is not set; aborting with error; see the following documentation which can be invoked via the 'go help gopath' command."
go help gopath
exit -1
fi
echo "Optional env var GOBIN is not set; using default derived from GOPATH as: \"$GOPATH/bin\""
export GOBIN="$GOPATH/bin"
fi
PROTOC=`command -v protoc`
if [[ "$PROTOC" == "" ]]; then
echo "Required "protoc" to be installed. Please visit https://github.com/protocolbuffers/protobuf/releases (3.5.0 suggested)."
exit -1
fi
# Install protoc-gen-go from the vendored protobuf package to $GOBIN
(cd ../../vendor/github.com/golang/protobuf && make install)
echo "Compiling protobuf definitions"
protoc \
--plugin=protoc-gen-ts=./node_modules/.bin/protoc-gen-ts \
--plugin=protoc-gen-go=${GOBIN}/protoc-gen-go \
-I ./proto \
--js_out=import_style=commonjs,binary:./ts/_proto \
--go_out=plugins=grpc:./go/_proto \
--ts_out=service=grpc-web:./ts/_proto \
./proto/examplecom/library/book_service.proto