forked from pingcap/dm
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-dm.sh
executable file
·39 lines (30 loc) · 1.11 KB
/
generate-dm.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
#!/usr/bin/env bash
cd dm/proto
echo "generate dm protobuf code..."
GOGO_ROOT=${GOPATH}/src/github.com/gogo/protobuf
if [ ! -d $GOGO_ROOT ]; then
echo "please use the following command to get gogo."
echo "go get -u github.com/gogo/protobuf/protoc-gen-gogofaster"
exit 1
fi
which protoc-gen-grpc-gateway
if [ $? -ne 0 ]; then
echo "please use the following command to get grpc-gateway."
echo "go get -u github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway"
exit 1
fi
GOOGLE_API_ROOT=${GOPATH}/src/github.com/googleapis/googleapis
if [ ! -d $GOOGLE_API_ROOT ]; then
echo "please use the following command to get google apis."
echo "go get -u github.com/googleapis/googleapis/google/api"
exit 1
fi
cp -r ${GOPATH}/src/github.com/googleapis/googleapis/google ./
protoc -I.:${GOGO_ROOT}:${GOGO_ROOT}/protobuf --gogofaster_out=plugins=grpc:../pb/ *.proto
protoc -I.:${GOGO_ROOT}:${GOGO_ROOT}/protobuf --grpc-gateway_out=logtostderr=true:../pb/ dmmaster.proto
rm -r ./google
cd ../pb
sed -i.bak -E 's/import _ \"gogoproto\"//g' *.pb.go
sed -i.bak -E 's/import fmt \"fmt\"//g' *.pb.go
rm -f *.bak
goimports -w *.pb.go