diff --git a/Makefile b/Makefile index 67cd872f3..e74d79b4d 100644 --- a/Makefile +++ b/Makefile @@ -83,9 +83,8 @@ proto-all: proto-gen proto-lint proto-check-breaking .PHONY: proto-all proto-gen: - @docker pull -q tendermintdev/docker-build-proto @echo "Generating Protobuf files" - @docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/docker-build-proto sh ./scripts/protocgen.sh + @$(DOCKER_PROTO_BUILDER) sh ./scripts/protocgen.sh .PHONY: proto-gen proto-lint: diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index b6d35ac66..6f5662a78 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -4,13 +4,10 @@ set -euo pipefail # By default, this script runs against the latest commit to the master branch # in the Tendermint spec repository. To use this script with a different version # of the spec repository, run it with the $VERS environment variable set to the -# desired commit in the spec repo. +# desired branch name or commit hash from the spec repo. : ${VERS:=master} URL_PATH=tarball/ -if [[ VERS -ne master ]]; then - URL_PATH=tarball/refs/tags/v -fi echo "fetching proto files" @@ -18,10 +15,13 @@ echo "fetching proto files" REF=$(curl -H "Accept: application/vnd.github.v3.sha" -qL \ "https://api.github.com/repos/tendermint/spec/commits/${VERS}" \ | cut -c -7) -curl -qL "https://api.github.com/repos/tendermint/spec/${URL_PATH}${REF}" | tar -xzf - tendermint-spec-"$REF"/ -cp -r ./tendermint-spec-"$REF"/proto/tendermint/* ./proto/tendermint -cp -r ./tendermint-spec-"$REF"/third_party/** ./third_party +readonly OUTDIR="tendermint-spec-${REF}" +curl -qL "https://api.github.com/repos/tendermint/spec/${URL_PATH}${REF}" | tar -xzf - ${OUTDIR}/ + + +cp -r ${OUTDIR}/proto/tendermint/* ./proto/tendermint +cp -r ${OUTDIR}/third_party/** ./third_party MODNAME="$(go list -m)" find ./proto/tendermint -name '*.proto' -not -path "./proto/tendermint/abci/types.proto" \ @@ -31,7 +31,7 @@ find ./proto/tendermint -name '*.proto' -not -path "./proto/tendermint/abci/type # so that it can be moved into the ./abci/types directory. sh ./scripts/protopackage.sh ./proto/tendermint/abci/types.proto $MODNAME "abci/types" -buf generate --path proto/tendermint --template ./tendermint-spec-"$REF"/proto/buf.gen.yaml --config ./tendermint-spec-"$REF"/proto/buf.yaml +buf generate --path proto/tendermint --template ./${OUTDIR}/proto/buf.gen.yaml --config ./${OUTDIR}/proto/buf.yaml mv ./proto/tendermint/abci/types.pb.go ./abci/types @@ -39,8 +39,8 @@ echo "proto files have been compiled" echo "removing copied files" -find ./tendermint-spec-"$REF"/proto/tendermint/ -name *.proto \ - | sed "s/\.\/tendermint-spec-$REF\/\(.*\)/\1/g" \ +find ${OUTDIR}/proto/tendermint/ -name *.proto \ + | sed "s/\.\/$OUTDIR\/\(.*\)/\1/g" \ | xargs -I {} rm {} -rm -rf ./tendermint-spec-"$REF" +rm -rf ${OUTDIR}