docker: proto (#7893)
* migrate fully to buf * run protoc-gen-cosmos in script * migrate to docker container * Update Makefile Co-authored-by: Alessio Treglia <alessio@tendermint.com> * Update scripts/protocgen.sh Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com> Co-authored-by: Alessio Treglia <alessio@tendermint.com> Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
parent
e9f19225a9
commit
104a2031ab
5
Makefile
5
Makefile
@ -361,6 +361,11 @@ proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-swagger-g
|
||||
proto-gen:
|
||||
@./scripts/protocgen.sh
|
||||
|
||||
proto-gen-docker:
|
||||
@echo "Generating Protobuf files"
|
||||
docker run -v $(shell pwd):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh
|
||||
.PHONY: proto-gen-docker
|
||||
|
||||
proto-format:
|
||||
@echo "Formatting Protobuf files"
|
||||
docker run -v $(shell pwd):/workspace \
|
||||
|
||||
@ -6,8 +6,7 @@ DESTDIR=${DESTDIR:-}
|
||||
PREFIX=${PREFIX:-/usr/local}
|
||||
UNAME_S="$(uname -s 2>/dev/null)"
|
||||
UNAME_M="$(uname -m 2>/dev/null)"
|
||||
BUF_VERSION=0.11.0
|
||||
PROTOC_VERSION=3.13.0
|
||||
BUF_VERSION=0.30.0
|
||||
PROTOC_GRPC_GATEWAY_VERSION=1.14.7
|
||||
|
||||
f_abort() {
|
||||
@ -61,19 +60,6 @@ f_needs_install() {
|
||||
return 0
|
||||
}
|
||||
|
||||
f_install_protoc() {
|
||||
f_print_installing_with_padding proto_c
|
||||
f_needs_install "${DESTDIR}/${PREFIX}/bin/protoc" || return 0
|
||||
|
||||
pushd "${TEMPDIR}" >/dev/null
|
||||
curl -o "${PROTOC_ZIP}" -sSL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"
|
||||
unzip -q -o ${PROTOC_ZIP} -d ${DESTDIR}/${PREFIX} bin/protoc; \
|
||||
unzip -q -o ${PROTOC_ZIP} -d ${DESTDIR}/${PREFIX} 'include/*'; \
|
||||
rm -f ${PROTOC_ZIP}
|
||||
popd >/dev/null
|
||||
f_print_done
|
||||
}
|
||||
|
||||
f_install_buf() {
|
||||
f_print_installing_with_padding buf
|
||||
f_needs_install "${DESTDIR}/${PREFIX}/bin/buf" || return 0
|
||||
@ -83,18 +69,6 @@ f_install_buf() {
|
||||
f_print_done
|
||||
}
|
||||
|
||||
f_install_protoc_gen_gocosmos() {
|
||||
f_print_installing_with_padding protoc-gen-gocosmos
|
||||
|
||||
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
|
||||
echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder."
|
||||
return 1
|
||||
fi
|
||||
|
||||
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
|
||||
f_print_done
|
||||
}
|
||||
|
||||
f_install_protoc_gen_grpc_gateway() {
|
||||
f_print_installing_with_padding protoc-gen-grpc-gateway
|
||||
f_needs_install "${DESTDIR}/${PREFIX}/bin/protoc-gen-grpc-gateway" || return 0
|
||||
@ -121,7 +95,6 @@ f_install_protoc_gen_swagger() {
|
||||
|
||||
f_ensure_tools
|
||||
f_ensure_dirs
|
||||
f_install_protoc
|
||||
f_install_buf
|
||||
f_install_protoc_gen_gocosmos
|
||||
f_install_protoc_gen_grpc_gateway
|
||||
|
||||
@ -8,7 +8,7 @@ set -eo pipefail
|
||||
|
||||
go install github.com/gogo/protobuf/protoc-gen-gogotypes
|
||||
|
||||
protoc -I. --gogotypes_out=./codec/types third_party/proto/google/protobuf/any.proto
|
||||
buf protoc -I. --gogotypes_out=./codec/types third_party/proto/google/protobuf/any.proto
|
||||
mv codec/types/third_party/proto/google/protobuf/any.pb.go codec/types
|
||||
rm -rf codec/types/third_party
|
||||
|
||||
|
||||
@ -2,9 +2,20 @@
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
protoc_gen_gocosmos() {
|
||||
if ! grep "github.com/gogo/protobuf => github.com/regen-network/protobuf" go.mod &>/dev/null ; then
|
||||
echo -e "\tPlease run this command from somewhere inside the cosmos-sdk folder."
|
||||
return 1
|
||||
fi
|
||||
|
||||
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
|
||||
}
|
||||
|
||||
protoc_gen_gocosmos
|
||||
|
||||
proto_dirs=$(find ./proto -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
|
||||
for dir in $proto_dirs; do
|
||||
protoc \
|
||||
buf protoc \
|
||||
-I "proto" \
|
||||
-I "third_party/proto" \
|
||||
--gocosmos_out=plugins=interfacetype+grpc,\
|
||||
@ -12,7 +23,7 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
|
||||
$(find "${dir}" -maxdepth 1 -name '*.proto')
|
||||
|
||||
# command to generate gRPC gateway (*.pb.gw.go in respective modules) files
|
||||
protoc \
|
||||
buf protoc \
|
||||
-I "proto" \
|
||||
-I "third_party/proto" \
|
||||
--grpc-gateway_out=logtostderr=true:. \
|
||||
@ -21,7 +32,7 @@ Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. \
|
||||
done
|
||||
|
||||
# generate codec/testdata proto code
|
||||
protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
|
||||
buf protoc -I "proto" -I "third_party/proto" -I "testutil/testdata" --gocosmos_out=plugins=interfacetype+grpc,\
|
||||
Mgoogle/protobuf/any.proto=github.com/cosmos/cosmos-sdk/codec/types:. ./testutil/testdata/*.proto
|
||||
|
||||
# move proto files to the right places
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user