forked from SUSE/linux-security-sensor
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_proto.sh
executable file
·67 lines (52 loc) · 2.29 KB
/
make_proto.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
64
65
66
67
#!/bin/bash
# Used to regenrate proto bindings. This script should be run if any
# of the .proto files are modified.
# This script requires protoc 3.6 +
set -e
CWD=$PWD
if [ -z "$GOPATH" ]; then
GOPATH="$HOME/go"
fi
GOOGLEAPIS_PATH=$CWD/googleapis/
GOOGLEAPIS_COMMIT="82a542279"
if [ ! -d "$GOOGLEAPIS_PATH" ]; then
git clone --shallow-since 2021-12-15 https://github.com/googleapis/googleapis/ $GOOGLEAPIS_PATH
(cd googleapis && git checkout $GOOGLEAPIS_COMMIT)
fi
if ! command -v protoc-gen-go > /dev/null; then
go install google.golang.org/protobuf/cmd/protoc-gen-go
fi
if ! command -v protoc-gen-go-grpc > /dev/null; then
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc
fi
if ! command -v protoc-gen-grpc-gateway > /dev/null; then
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway
fi
for i in $CWD/proto/ $CWD/crypto/proto/ \
$CWD/artifacts/proto/ \
$CWD/actions/proto/ \
$CWD/services/frontend/proto/ \
$CWD/config/proto/ \
$CWD/timelines/proto/ \
$CWD/acls/proto/ \
$CWD/flows/proto/ ; do
echo Building protos in $i
echo protoc -I$i -I$GOPATH/src/ -I/usr/local/include/ -I$GOOGLEAPIS_PATH -I$CWD --go_out=paths=source_relative:$i $i/*.proto
protoc -I$i -I$GOPATH/src/ -I/usr/local/include/ -I$GOOGLEAPIS_PATH -I$CWD --go_out=paths=source_relative:$i $i/*.proto
done
# Build GRPC servers.
for i in $CWD/api/proto/ ; do
echo Building protos in $i
echo protoc -I$i -I. -I$GOPATH/src/ -I/usr/local/include/ \
-I$GOOGLEAPIS_PATH \
-I$CWD $i/*.proto --go-grpc_out=paths=source_relative:$i --go_out=paths=source_relative:$i
protoc -I$i -I. -I$GOPATH/src/ -I/usr/local/include/ \
-I$GOOGLEAPIS_PATH \
-I$CWD $i/*.proto --go-grpc_out=paths=source_relative:$i --go_out=paths=source_relative:$i
echo protoc -I$i -I. -I$GOPATH/src/ -I/usr/local/include/ \
-I$GOOGLEAPIS_PATH \
--grpc-gateway_out=paths=source_relative,logtostderr=true:$i $i/*.proto
protoc -I$i -I. -I$GOPATH/src/ -I/usr/local/include/ \
-I$GOOGLEAPIS_PATH \
--grpc-gateway_out=paths=source_relative,logtostderr=true:$i $i/*.proto
done