|
2 | 2 |
|
3 | 3 | set -eo pipefail
|
4 | 4 |
|
5 |
| -protoc_gen_gocosmos() { |
6 |
| - if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then |
7 |
| - echo -e "\tPlease run this command from somewhere inside the sommelier folder." |
8 |
| - return 1 |
9 |
| - fi |
10 |
| - |
11 |
| - go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null |
12 |
| -} |
13 |
| - |
14 |
| -echo "verifying protoc gocosmos" |
15 |
| -protoc_gen_gocosmos |
| 5 | +ROOT=$(git rev-parse --show-toplevel 2>/dev/null) |
16 | 6 |
|
| 7 | +cd $ROOT/proto |
17 | 8 | echo "generating proto and gRPC gateway files..."
|
| 9 | +buf generate --template buf.gen.gogo.yaml |
| 10 | +cd .. |
18 | 11 |
|
19 |
| -proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) |
20 |
| -for dir in $proto_dirs; do |
21 |
| - buf protoc \ |
22 |
| - -I "proto" \ |
23 |
| - -I "third_party/proto" \ |
24 |
| - --gocosmos_out=plugins=interfacetype+grpc,\ |
25 |
| -Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \ |
26 |
| - --grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \ |
27 |
| - $(find "${dir}" -maxdepth 1 -name '*.proto') |
28 |
| - |
29 |
| -done |
| 12 | +# move proto files to the right places |
| 13 | +xpath=$(head -n 1 go.mod | sed 's/^module //') |
| 14 | +cp -r $xpath/* ./ |
30 | 15 |
|
31 |
| -echo "generating proto docs..." |
32 |
| -# command to generate docs using protoc-gen-doc |
33 |
| -buf protoc \ |
34 |
| --I "proto" \ |
35 |
| --I "third_party/proto" \ |
36 |
| ---doc_out=./docs/core \ |
37 |
| ---doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \ |
38 |
| -$(find "$(pwd)/proto" -maxdepth 5 -name '*.proto') |
| 16 | +echo "cleaning up..." |
39 | 17 | go mod tidy
|
40 |
| - |
41 |
| -echo "(re)moving proto files.." |
42 |
| -# move proto files to the right places |
43 |
| -cp -r github.com/peggyjv/sommelier/* ./ |
44 | 18 | rm -rf github.com
|
45 | 19 |
|
46 | 20 | echo "done"
|
0 commit comments