@@ -13,7 +13,8 @@ SIMAPP = ./testing/simapp
1313MOCKS_DIR = $(CURDIR ) /tests/mocks
1414HTTPS_GIT := https://github.com/cosmos/ibc-go.git
1515DOCKER := $(shell which docker)
16- DOCKER_BUF := $(DOCKER ) run --rm -v $(CURDIR ) :/workspace --workdir /workspace bufbuild/buf:1.0.0-rc8
16+ DOCKER_BUF := $(DOCKER ) run --rm -v $(CURDIR ) :/workspace --workdir /workspace bufbuild/buf:1.9.0
17+ PROJECT_NAME = $(shell git remote get-url origin | xargs basename -s .git)
1718
1819export GO111MODULE = on
1920
@@ -302,90 +303,37 @@ format:
302303# ## Protobuf ###
303304# ##############################################################################
304305
305- containerProtoVer =v0.2
306- containerProtoImage =tendermintdev/sdk-proto-gen:$(containerProtoVer )
307- containerProtoGen =cosmos-sdk- proto-gen-$(containerProtoVer )
308- containerProtoGenSwagger =cosmos-sdk- proto-gen-swagger-$(containerProtoVer )
309- containerProtoFmt =cosmos-sdk- proto-fmt-$(containerProtoVer )
306+ protoVer =v0.7
307+ protoImageName =tendermintdev/sdk-proto-gen:$(protoVer )
308+ containerProtoGen =$( PROJECT_NAME ) - proto-gen-$(protoVer )
309+ containerProtoGenSwagger =$( PROJECT_NAME ) - proto-gen-swagger-$(protoVer )
310+ containerProtoFmt =$( PROJECT_NAME ) - proto-fmt-$(protoVer )
310311
311312proto-all : proto-format proto-lint proto-gen
312313
314+ proto-format :
315+ @echo " Formatting Protobuf files"
316+ @if docker ps -a --format ' {{.Names}}' | grep -Eq " ^${containerProtoFmt} $$ " ; then docker start -a $(containerProtoFmt ) ; else docker run --name $(containerProtoFmt ) -v $(CURDIR ) :/workspace --workdir /workspace $(protoImageName ) \
317+ find ./ -name " *.proto" -exec clang-format -i {} \; ; fi
318+
319+ proto-lint :
320+ @$(DOCKER_BUF ) lint --error-format=json
321+
313322proto-gen :
314323 @echo " Generating Protobuf files"
315- @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 ) \
324+ @if docker ps -a --format ' {{.Names}}' | grep -Eq " ^${containerProtoGen} $$ " ; then docker start -a $(containerProtoGen ) ; else docker run --name $(containerProtoGen ) -v $(CURDIR ) :/workspace --workdir /workspace $(protoImageName ) \
316325 sh ./scripts/protocgen.sh; fi
317326
318- proto-format :
319- @echo " Formatting Protobuf files"
320- @if docker ps -a --format ' {{.Names}}' | grep -Eq " ^${containerProtoFmt} $$ " ; then docker start -a $(containerProtoFmt ) ; else docker run --name $(containerProtoFmt ) -v $(CURDIR ) :/workspace --workdir /workspace tendermintdev/docker-build-proto \
321- find ./ -not -path " ./third_party/*" -name " *.proto" -exec clang-format -i {} \; ; fi
322-
323327proto-swagger-gen :
324328 @echo " Generating Protobuf Swagger"
325- @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 ) \
329+ @if docker ps -a --format ' {{.Names}}' | grep -Eq " ^${containerProtoGenSwagger} $$ " ; then docker start -a $(containerProtoGenSwagger ) ; else docker run --name $(containerProtoGenSwagger ) -v $(CURDIR ) :/workspace --workdir /workspace $(protoImageName ) \
326330 sh ./scripts/protoc-swagger-gen.sh; fi
327331
328- proto-lint :
329- @$(DOCKER_BUF ) lint --error-format=json
330-
331332proto-check-breaking :
332333 @$(DOCKER_BUF ) breaking --against $(HTTPS_GIT ) # branch=main
333334
334- TM_URL = https://raw.githubusercontent.com/tendermint/tendermint/v0.34.20/proto/tendermint
335- GOGO_PROTO_URL = https://raw.githubusercontent.com/regen-network/protobuf/cosmos
336- CONFIO_URL = https://raw.githubusercontent.com/confio/ics23/v0.7.1
337- SDK_PROTO_URL = https://raw.githubusercontent.com/cosmos/cosmos-sdk/v0.46.0/proto/cosmos
338-
339- TM_CRYPTO_TYPES = third_party/proto/tendermint/crypto
340- TM_ABCI_TYPES = third_party/proto/tendermint/abci
341- TM_TYPES = third_party/proto/tendermint/types
342- TM_VERSION = third_party/proto/tendermint/version
343- TM_LIBS = third_party/proto/tendermint/libs/bits
344- TM_P2P = third_party/proto/tendermint/p2p
345-
346- SDK_QUERY = third_party/proto/cosmos/base/query/v1beta1
347- SDK_BASE = third_party/proto/cosmos/base/v1beta1
348- SDK_UPGRADE = third_party/proto/cosmos/upgrade
349-
350- GOGO_PROTO_TYPES = third_party/proto/gogoproto
351- CONFIO_TYPES = third_party/proto
352-
353335proto-update-deps :
354- @mkdir -p $(GOGO_PROTO_TYPES )
355- @curl -sSL $(GOGO_PROTO_URL ) /gogoproto/gogo.proto > $(GOGO_PROTO_TYPES ) /gogo.proto
356-
357- @mkdir -p $(SDK_QUERY)
358- @curl -sSL $(SDK_PROTO_URL)/base/query/v1beta1/pagination.proto > $(SDK_QUERY)/pagination.proto
359-
360- @mkdir -p $(SDK_BASE)
361- @curl -sSL $(SDK_PROTO_URL)/base/v1beta1/coin.proto > $(SDK_BASE)/coin.proto
362-
363- @mkdir -p $(SDK_UPGRADE)
364- @curl -sSL $(SDK_PROTO_URL)/upgrade/v1beta1/upgrade.proto > $(SDK_UPGRADE)/v1beta1/upgrade.proto
365-
366- # # Importing of tendermint protobuf definitions currently requires the
367- # # use of `sed` in order to build properly with cosmos-sdk's proto file layout
368- # # (which is the standard Buf.build FILE_LAYOUT)
369- # # Issue link: https://github.com/tendermint/tendermint/issues/5021
370- @mkdir -p $(TM_TYPES)
371- @curl -sSL $(TM_URL)/types/types.proto > $(TM_TYPES)/types.proto
372- @curl -sSL $(TM_URL)/types/validator.proto > $(TM_TYPES)/validator.proto
373-
374- @mkdir -p $(TM_VERSION)
375- @curl -sSL $(TM_URL)/version/types.proto > $(TM_VERSION)/types.proto
376-
377- @mkdir -p $(TM_LIBS)
378- @curl -sSL $(TM_URL)/libs/bits/types.proto > $(TM_LIBS)/types.proto
379-
380- @mkdir -p $(TM_CRYPTO_TYPES)
381- @curl -sSL $(TM_URL)/crypto/proof.proto > $(TM_CRYPTO_TYPES)/proof.proto
382- @curl -sSL $(TM_URL)/crypto/keys.proto > $(TM_CRYPTO_TYPES)/keys.proto
383-
384- @mkdir -p $(CONFIO_TYPES)
385- @curl -sSL $(CONFIO_URL)/proofs.proto > $(CONFIO_TYPES)/proofs.proto
386-
387- # # insert go package option into proofs.proto file
388- # # Issue link: https://github.com/confio/ics23/issues/32
389- @perl -lp -i -e 'print q(option go_package = "github.com/confio/ics23/go";) if $$. == 4' $(CONFIO_TYPES)/proofs.proto
336+ @echo " Updating Protobuf dependencies"
337+ @cd proto && buf mod update
390338
391339.PHONY : proto-all proto-gen proto-gen-any proto-swagger-gen proto-format proto-lint proto-check-breaking proto-update-deps
0 commit comments