From 27747dd79797d72adf43bd3bf985a4db417c87f6 Mon Sep 17 00:00:00 2001 From: William Banfield Date: Fri, 12 Nov 2021 12:33:04 -0500 Subject: [PATCH] scripts fixes --- scripts/protocgen.sh | 22 +++------------------- scripts/protopackage.sh | 4 ++++ 2 files changed, 7 insertions(+), 19 deletions(-) diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 6ffd4fc29..a64e642db 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -1,5 +1,5 @@ #!/usr/bin/env bash -set -euo pipefail +set -eo 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 @@ -23,7 +23,7 @@ curl -qL "https://api.github.com/repos/tendermint/spec/${URL_PATH}${REF}" | tar cp -r ./tendermint-spec-"$REF"/proto/tendermint/* ./proto/tendermint cp -r ./tendermint-spec-"$REF"/third_party/** ./third_party -MODNAME=$(go list -m) +MODNAME="$(go list -m)" find ./proto/tendermint -name *.proto -not -path "./proto/tendermint/abci/types.proto" -exec sh ./scripts/protopackage.sh {} $MODNAME ';' # For historical compatibility, the abci file needs to get a slightly different import name @@ -38,21 +38,5 @@ echo "proto files have been compiled" echo "removing copied files" -rm -rf ./proto/tendermint/abci -rm -rf ./proto/tendermint/blocksync/types.proto -rm -rf ./proto/tendermint/consensus/types.proto -rm -rf ./proto/tendermint/libs/bits/types.proto -rm -rf ./proto/tendermint/mempool/types.proto -rm -rf ./proto/tendermint/p2p/types.proto -rm -rf ./proto/tendermint/p2p/conn.proto -rm -rf ./proto/tendermint/p2p/pex.proto -rm -rf ./proto/tendermint/statesync/types.proto -rm -rf ./proto/tendermint/types/block.proto -rm -rf ./proto/tendermint/types/evidence.proto -rm -rf ./proto/tendermint/types/params.proto -rm -rf ./proto/tendermint/types/types.proto -rm -rf ./proto/tendermint/types/validator.proto -rm -rf ./proto/tendermint/version/types.proto -rm -rf ./thirdparty/proto/gogoproto/gogo.proto - +find ./tendermint-spec-"$REF"/proto/tendermint/ -name *.proto | sed "s/\.\/tendermint-spec-$REF\/\(.*\)/\1/g" | xargs -I {} rm {} rm -rf ./tendermint-spec-"$REF" diff --git a/scripts/protopackage.sh b/scripts/protopackage.sh index f1cc271c3..1f9ba4e83 100755 --- a/scripts/protopackage.sh +++ b/scripts/protopackage.sh @@ -5,6 +5,8 @@ set -eo pipefail # This option specifies what the package will be named when imported by other packages. # This option is not directly included in the proto files to allow the files to more easily # be hosted in github.com/tendermint/spec and shared between other repos. +# If the option is already specified in the file, it will be replaced using the +# arguments passed to this script. FNAME=$1 MODNAME=$(echo $2| sed 's/\//\\\//g') @@ -16,4 +18,6 @@ fi if ! `grep -q 'option\s\+go_package\s\+=\s\+.*;' $FNAME`; then sed -i "s/\(package tendermint.*\)/\1\n\noption go_package = \"$MODNAME\/$PACKAGE\";/g" $FNAME +else + sed -i "s/option\s\+go_package\s\+=\s\+.*;/option go_package = \"$MODNAME\/$PACKAGE\";/g" $FNAME fi