github.com/Finschia/finschia-sdk@v0.48.1/scripts/protocgen.sh (about)

     1  #!/usr/bin/env bash
     2  
     3  set -eo pipefail
     4  
     5  # TODO ebony
     6  apk add --no-cache git
     7  
     8  protoc_gen_gocosmos() {
     9    if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
    10      echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder."
    11      return 1
    12    fi
    13  
    14    go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos@latest 2>/dev/null
    15  }
    16  
    17  protoc_gen_gocosmos
    18  
    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/Finschia/finschia-sdk/codec/types:. \
    26    --grpc-gateway_out=logtostderr=true,allow_colon_final_segments=true:. \
    27    $(find "${dir}" -maxdepth 1 -name '*.proto')
    28  
    29  done
    30  
    31  # command to generate docs using protoc-gen-doc
    32  buf protoc \
    33    -I "proto" \
    34    -I "third_party/proto" \
    35    --doc_out=./docs/core \
    36    --doc_opt=./docs/protodoc-markdown.tmpl,proto-docs.md \
    37    $(find "$(pwd)/proto" -maxdepth 5 -name '*.proto')
    38  go mod tidy
    39  
    40  # generate codec/testdata proto code
    41  buf protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
    42  Mgoogle/protobuf/any.proto=github.com/Finschia/finschia-sdk/codec/types:. ./testutil/testdata/*.proto
    43  
    44  # move proto files to the right places
    45  cp -r github.com/Finschia/finschia-sdk/* ./
    46  rm -rf github.com