-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
63 lines (57 loc) · 2.52 KB
/
generate.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# This script helps us generate the Go source code from protocol buffer files where the
# protocol buffers are stored in the github.com/rotationalio/ensign repository. If the
# script cannot find the repository it exits without error after printing a warning that
# the other repository must be cloned first.
# Find the rotationalio/ensign repository using the $GOPATH or a path relative to the
# generate.sh script if $GOPATH is not set.
if [[ -z "${GOPATH}" ]]; then
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
PROTOS=$(realpath "$DIR/../ensign/proto")
else
PROTOS="${GOPATH}/src/github.com/rotationalio/ensign/proto"
fi
# If the protos directory does not exist, exit with a warning
if [[ ! -d $PROTOS ]]; then
echo "cannot find ${PROTOS}"
echo "must clone the github.com/rotationalio/ensign repo before generating protocol buffers"
exit 0
fi
MODULE="github.com/rotationalio/go-ensign"
APIMOD="github.com/rotationalio/go-ensign/api/v1beta1;api"
MMEMOD="github.com/rotationalio/go-ensign/mimetype/v1beta1;mimetype"
REGMOD="github.com/rotationalio/go-ensign/region/v1beta1;region"
# Generate the protocol buffers
protoc -I ${PROTOS} \
--go_out=. \
--go_opt=module="${MODULE}" \
--go_opt=Mmimetype/v1beta1/mimetype.proto="${MMEMOD}" \
mimetype/v1beta1/mimetype.proto
protoc -I ${PROTOS} \
--go_out=. \
--go_opt=module="${MODULE}" \
--go_opt=Mregion/v1beta1/region.proto="${REGMOD}" \
region/v1beta1/region.proto
protoc -I ${PROTOS} \
--go_out=. --go-grpc_out=. \
--go_opt=module="${MODULE}" \
--go_opt=Mmimetype/v1beta1/mimetype.proto="${MMEMOD}" \
--go_opt=Mregion/v1beta1/region.proto="${REGMOD}" \
--go_opt=Mapi/v1beta1/ensign.proto="${APIMOD}" \
--go_opt=Mapi/v1beta1/event.proto="${APIMOD}" \
--go_opt=Mapi/v1beta1/topic.proto="${APIMOD}" \
--go_opt=Mapi/v1beta1/groups.proto="${APIMOD}" \
--go_opt=Mapi/v1beta1/query.proto="${APIMOD}" \
--go-grpc_opt=module="${MODULE}" \
--go-grpc_opt=Mmimetype/v1beta1/mimetype.proto="${MMEMOD}" \
--go-grpc_opt=Mregion/v1beta1/region.proto="${REGMOD}" \
--go-grpc_opt=Mapi/v1beta1/ensign.proto="${APIMOD}" \
--go-grpc_opt=Mapi/v1beta1/event.proto="${APIMOD}" \
--go-grpc_opt=Mapi/v1beta1/topic.proto="${APIMOD}" \
--go-grpc_opt=Mapi/v1beta1/groups.proto="${APIMOD}" \
--go-grpc_opt=Mapi/v1beta1/query.proto="${APIMOD}" \
api/v1beta1/ensign.proto \
api/v1beta1/event.proto \
api/v1beta1/topic.proto \
api/v1beta1/groups.proto \
api/v1beta1/query.proto