forked from Decentr-net/decentr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
protocgen.sh
executable file
·32 lines (24 loc) · 1018 Bytes
/
protocgen.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
#!/usr/bin/env bash
# Adapted from https://github.com/cosmos/cosmos-sdk/blob/master/scripts/protocgen.sh
set -eo pipefail
protoc_gen_gocosmos() {
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
echo -e "\tPlease run this command from somewhere inside the root of decentr folder."
return 1
fi
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null
}
protoc_gen_gocosmos
proto_dirs=$(find ./proto -path ./proto/3rdparty -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
for dir in $proto_dirs; do
buf protoc \
-I "proto/decentr" \
-I "proto/3rdparty" \
--gocosmos_out=plugins=grpc,\
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
--grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
$(find "${dir}" -maxdepth 1 -name '*.proto')
done
# move proto files to the right places
cp -r github.com/Decentr-net/decentr/* ./
rm -rf github.com