You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.5 KiB

  1. #!/usr/bin/env bash
  2. set -euo pipefail
  3. # By default, this script runs against the latest commit to the master branch
  4. # in the Tendermint spec repository. To use this script with a different version
  5. # of the spec repository, run it with the $VERS environment variable set to the
  6. # desired branch name or commit hash from the spec repo.
  7. : ${VERS:=master}
  8. echo "fetching proto files"
  9. # Get shortened ref of commit
  10. REF=$(curl -H "Accept: application/vnd.github.v3.sha" -qL \
  11. "https://api.github.com/repos/tendermint/spec/commits/${VERS}" \
  12. | cut -c -7)
  13. readonly OUTDIR="tendermint-spec-${REF}"
  14. curl -qL "https://api.github.com/repos/tendermint/spec/tarball/${REF}" | tar -xzf - ${OUTDIR}/
  15. cp -r ${OUTDIR}/proto/tendermint/* ./proto/tendermint
  16. cp -r ${OUTDIR}/third_party/** ./third_party
  17. MODNAME="$(go list -m)"
  18. find ./proto/tendermint -name '*.proto' -not -path "./proto/tendermint/abci/types.proto" \
  19. -exec sh ./scripts/protopackage.sh {} "$MODNAME" ';'
  20. # For historical compatibility, the abci file needs to get a slightly different import name
  21. # so that it can be moved into the ./abci/types directory.
  22. sh ./scripts/protopackage.sh ./proto/tendermint/abci/types.proto $MODNAME "abci/types"
  23. buf generate --path proto/tendermint --template ./${OUTDIR}/buf.gen.yaml --config ./${OUTDIR}/buf.yaml
  24. mv ./proto/tendermint/abci/types.pb.go ./abci/types
  25. echo "proto files have been compiled"
  26. echo "removing copied files"
  27. find ${OUTDIR}/proto/tendermint/ -name *.proto \
  28. | sed "s/$OUTDIR\/\(.*\)/\1/g" \
  29. | xargs -I {} rm {}
  30. rm -rf ${OUTDIR}