-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgen_protos.sh
executable file
·66 lines (51 loc) · 1.76 KB
/
gen_protos.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
#!/bin/bash
if [ -z "$LIBRA_SRC" ]; then
echo "Please set \$LIBRA_SRC to the base directory of your libra repo."
exit 1
fi
rm -r admission_control types mempool
mkdir -p admission_control types mempool
echo "Copying libra protobufs..."
cp $LIBRA_SRC/types/src/proto/*.proto types/
cp $LIBRA_SRC/mempool/src/proto/shared/*.proto mempool/
cp $LIBRA_SRC/admission_control/admission_control_proto/src/proto/*.proto admission_control/
echo "Adding go_package option..."
for file in types/*.proto
do
sed -i '' 's/package types;/package types; option go_package = "github.com\/phlip9\/libra_example\/types";/g' $file
done
for file in mempool/*.proto
do
sed -i '' 's/package mempool;/package mempool; option go_package = "github.com\/phlip9\/libra_example\/mempool";/g' $file
done
for file in admission_control/*.proto
do
sed -i '' 's/package admission_control;/package admission_control; option go_package = "github.com\/phlip9\/libra_example\/admission_control";/g' $file
done
echo "Generating types protos..."
protoc \
-I types/ \
types/access_path.proto \
types/account_state_blob.proto \
types/events.proto \
types/get_with_proof.proto \
types/ledger_info.proto \
types/proof.proto \
types/transaction.proto \
types/transaction_info.proto \
types/validator_change.proto \
types/vm_errors.proto \
--go_out=paths=source_relative:types/
echo "Generating mempool protos..."
protoc \
-I mempool/ \
mempool/mempool_status.proto \
--go_out=paths=source_relative:mempool/
echo "Generating admission_control protos..."
protoc \
-I types/ \
-I mempool/ \
-I admission_control/ \
admission_control/admission_control.proto \
--go_out=plugins=grpc,paths=source_relative:admission_control/
echo "Done"