From c6f53effcf0354b03a5154795da8fc2eeef52db6 Mon Sep 17 00:00:00 2001 From: "mergify[bot]" <37929162+mergify[bot]@users.noreply.github.com> Date: Wed, 28 Apr 2021 13:35:46 +0100 Subject: [PATCH] setup: reuses proto container (backport #9192) (#9203) Co-authored-by: marbar3778 Co-authored-by: Amaury <1293565+amaurym@users.noreply.github.com> (cherry picked from commit 71b7fb829ed1d320264b3bc1eb4e995fc402a6a4) Co-authored-by: Robert Zaremba --- Makefile | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index d72d69f20d2d..a8a0910f8c47 100644 --- a/Makefile +++ b/Makefile @@ -367,24 +367,33 @@ devdoc-update: ### Protobuf ### ############################################################################### +containerProtoVer=v0.2 +containerProtoImage=tendermintdev/sdk-proto-gen:$(containerProtoVer) +containerProtoGen=cosmos-sdk-proto-gen-$(containerProtoVer) +containerProtoGenSwagger=cosmos-sdk-proto-gen-swagger-$(containerProtoVer) +containerProtoFmt=cosmos-sdk-proto-fmt-$(containerProtoVer) + proto-all: proto-format proto-lint proto-gen proto-gen: @echo "Generating Protobuf files" - $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen.sh - -proto-format: - @echo "Formatting Protobuf files" - $(DOCKER) run --rm -v $(CURDIR):/workspace \ - --workdir /workspace tendermintdev/docker-build-proto \ - find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \; + @if $(DOCKER) ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGen}$$"; then $(DOCKER) start -a $(containerProtoGen); else $(DOCKER) run --name $(containerProtoGen) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \ + sh ./scripts/protocgen.sh; fi # This generates the SDK's custom wrapper for google.protobuf.Any. It should only be run manually when needed proto-gen-any: - $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace tendermintdev/sdk-proto-gen sh ./scripts/protocgen-any.sh + @echo "Generating Protobuf Any" + $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) sh ./scripts/protocgen-any.sh proto-swagger-gen: - @./scripts/protoc-swagger-gen.sh + @echo "Generating Protobuf Swagger" + @if $(DOCKER) ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoGenSwagger}$$"; then $(DOCKER) start -a $(containerProtoGenSwagger); else $(DOCKER) run --name $(containerProtoGenSwagger) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \ + sh ./scripts/protoc-swagger-gen.sh; fi + +proto-format: + @echo "Formatting Protobuf files" + @if $(DOCKER) ps -a --format '{{.Names}}' | grep -Eq "^${containerProtoFmt}$$"; then $(DOCKER) start -a $(containerProtoFmt); else $(DOCKER) run --name $(containerProtoFmt) -v $(CURDIR):/workspace --workdir /workspace $(containerProtoImage) \ + find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {}; fi proto-lint: @$(DOCKER_BUF) check lint --error-format=json @@ -392,6 +401,7 @@ proto-lint: proto-check-breaking: @$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master + TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.0-rc6/proto/tendermint GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos COSMOS_PROTO_URL = https://raw.githubusercontent.com/regen-network/cosmos-proto/master