Advertisement
RiccardoMontagnin

Generate Python Protobuf

Jun 28th, 2021
905
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.97 KB | None | 0 0
  1. #!/usr/bin/env bash
  2. set -eo pipefail
  3.  
  4. # Define variables
  5. OUT=./generated
  6. PROTO=proto
  7. THIRD_PARTY=third_party
  8.  
  9. # Generate the third party Protobuf implementations
  10. PROTOC="protoc --python_out=$OUT -I$THIRD_PARTY/proto"
  11. proto_dirs=$(find "$THIRD_PARTY/proto" -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
  12. for dir in $proto_dirs; do
  13.   $PROTOC -I$THIRD_PARTY/proto $(find "${dir}" -maxdepth 1 -name '*.proto')
  14. done
  15.  
  16. # Generate the Cosmos Protobuf implementation
  17. proto_dirs=$(find "$PROTO" -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
  18. for dir in $proto_dirs; do
  19.   $PROTOC -I$PROTO \
  20.   --gocosmos_out=plugins=interfacetype+grpc,\
  21. Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
  22.   $(find "${dir}" -maxdepth 1 -name '*.proto')
  23. done
  24.  
  25. # Remove all .pbserver.dart files as they are unnecessary
  26. find "$OUT" -name "*.pbserver.dart" -type f -delete
  27.  
  28. # Clean directories
  29. rm -r "github.com"
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement