diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index 2e8ae7ef3..6ffd4fc29 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -24,7 +24,11 @@ cp -r ./tendermint-spec-"$REF"/proto/tendermint/* ./proto/tendermint cp -r ./tendermint-spec-"$REF"/third_party/** ./third_party MODNAME=$(go list -m) -find ./proto/tendermint -name *.proto -exec sh ./scripts/protopackage.sh {} $MODNAME ';' +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 +# 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 diff --git a/scripts/protopackage.sh b/scripts/protopackage.sh index 9b275516b..f1cc271c3 100755 --- a/scripts/protopackage.sh +++ b/scripts/protopackage.sh @@ -2,13 +2,17 @@ set -eo pipefail # This script appends the "option go_package" proto option to the file located at $FNAME. -# This option is not included in the proto files to allow the files to more easily -# be hosted in github.com/tendermint/spec and shared between other repos. # 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. FNAME=$1 MODNAME=$(echo $2| sed 's/\//\\\//g') PACKAGE="$(dirname $FNAME | sed 's/^\.\/\(.*\)/\1/g' | sed 's/\//\\\//g')" +if [[ ! -z "$3" ]]; then + PACKAGE="$(echo $3 | sed 's/\//\\\//g')" +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