2020-04-22 19:26:01 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
set -eo pipefail
|
|
|
|
|
2021-01-07 21:45:32 +00:00
|
|
|
protoc_gen_gocosmos() {
|
|
|
|
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
|
2021-04-17 10:00:07 +00:00
|
|
|
echo -e "\tPlease run this command from somewhere inside the sommelier folder."
|
2021-01-07 21:45:32 +00:00
|
|
|
return 1
|
|
|
|
fi
|
|
|
|
|
|
|
|
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
protoc_gen_doc() {
|
|
|
|
go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc 2>/dev/null
|
|
|
|
}
|
|
|
|
|
2021-01-07 21:45:32 +00:00
|
|
|
protoc_gen_gocosmos
|
2021-04-17 10:00:07 +00:00
|
|
|
protoc_gen_doc
|
2021-01-07 21:45:32 +00:00
|
|
|
|
|
|
|
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
|
2020-04-22 19:26:01 +00:00
|
|
|
for dir in $proto_dirs; do
|
2021-01-07 21:45:32 +00:00
|
|
|
buf protoc \
|
|
|
|
-I "proto" \
|
|
|
|
-I "third_party/proto" \
|
2021-07-05 16:39:08 +00:00
|
|
|
--gocosmos_out=plugins=interfacetype+grpc,\
|
|
|
|
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
|
2021-01-07 21:45:32 +00:00
|
|
|
--grpc-gateway_out=logtostderr=true:. \
|
|
|
|
$(find "${dir}" -maxdepth 1 -name '*.proto')
|
|
|
|
|
2020-04-22 19:26:01 +00:00
|
|
|
done
|
2021-01-07 21:45:32 +00:00
|
|
|
|
2021-04-17 10:00:07 +00:00
|
|
|
# command to generate docs using protoc-gen-doc
|
|
|
|
buf protoc \
|
|
|
|
-I "proto" \
|
|
|
|
-I "third_party/proto" \
|
2021-08-09 21:21:21 +00:00
|
|
|
--doc_out=./docs/api \
|
2021-04-17 10:00:07 +00:00
|
|
|
--doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \
|
|
|
|
$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')
|
2021-07-05 16:39:08 +00:00
|
|
|
# go mod tidy
|
2021-01-07 21:45:32 +00:00
|
|
|
|
|
|
|
# move proto files to the right places
|
2022-06-19 09:43:41 +00:00
|
|
|
cp -r github.com/evmos/ethermint/* ./
|
2021-01-07 21:45:32 +00:00
|
|
|
rm -rf github.com
|