Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docker: proto #7893

Merged
merged 9 commits into from
Nov 12, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,11 @@ proto-all: proto-tools proto-gen proto-lint proto-check-breaking proto-swagger-g
proto-gen:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we still need this target then?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't remove it because some people may want to not use docker. I can remove it though. Dont have a preference.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i might still use this one.

@./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 \
Expand Down
29 changes: 1 addition & 28 deletions contrib/devtools/proto-tools-installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion scripts/protocgen-any.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 14 additions & 3 deletions scripts/protocgen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,28 @@

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,\
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:. \
Expand All @@ -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
Expand Down
Loading