-
-
Notifications
You must be signed in to change notification settings - Fork 23
/
genprotogo.sh
executable file
·104 lines (87 loc) · 3.05 KB
/
genprotogo.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#!/usr/bin/env bash
set -eo pipefail
out_dir="protogo"
# move the vendor folder to a temp dir so that go list works properly
temp_dir="f29ea6aa861dc4b083e8e48f67cce"
if [ -d vendor ]; then
mv ./vendor ./$temp_dir
fi
# Get the path of the cosmos-sdk repo from go/pkg/mod
cosmos_sdk_dir=$(go list -f '{{ .Dir }}' -m github.com/cosmos/cosmos-sdk)
# move the vendor folder back to ./vendor
if [ -d $temp_dir ]; then
mv ./$temp_dir ./vendor
fi
proto_dirs=$(find . \( -path ./third_party -o -path ./vendor \) -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
rm -rf github.com; rm -rf cosmos; rm -rf ollo
rm -rf ${out_dir}
rm -rf cosmossdk.io
mkdir ${out_dir}
for dir in $proto_dirs; do
# generate protobuf bind
protoc \
-I "proto" \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--gocosmos_out=plugins=interfacetype+grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
$(find "${dir}" -name '*.proto')
# generate grpc gateway
protoc \
-I "proto" \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
-I "$cosmos_sdk_dir/proto" \
--grpc-gateway_out=logtostderr=true:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')
done
mv ollo ${out_dir}/ollo
for dir in $(find third_party/proto/cosmos -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
echo "Generating $file"
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--gocosmos_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. $file
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--grpc-gateway_out=logtostderr=true:. $file
done
done
rm -rf cosmossdk.io
rm -rf cosmos
mv github.com/cosmos/cosmos-sdk ${out_dir}/cosmos
for dir in $(find third_party/proto/cosmwasm -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
echo "Generating $file"
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--gocosmos_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. $file
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--grpc-gateway_out=logtostderr=true:. $file
done
done
mv github.com/CosmWasm/wasmd ${out_dir}/cosmwasm
for dir in $(find third_party/proto/ibc -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq); do
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
echo "Generating $file"
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--gocosmos_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. $file
protoc \
-I "third_party/proto" \
-I "$cosmos_sdk_dir/third_party/proto" \
--grpc-gateway_out=logtostderr=true:. $file
done
done
mv github.com/cosmos/ibc-go ${out_dir}/ibc
rm -rf github.com