diff --git a/Makefile b/Makefile index 1f00ae4c..bcc4bc6b 100644 --- a/Makefile +++ b/Makefile @@ -92,3 +92,32 @@ install: go.sum build: go build $(BUILD_FLAGS) -o bin/migalood ./cmd/migalood + +############################################################################### +### Proto ### +############################################################################### + +protoVer=0.11.6 +protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer) +containerProtoGen=proto-gen-$(protoVer) +containerProtoFmt=proto-fmt-$(protoVer) + +proto-all: proto-format proto-gen + +proto-gen: + @echo "Generating Protobuf files" + @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) \ + sh ./scripts/protocgen.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 tendermintdev/docker-build-proto \ + find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi + +proto-lint: + @$(DOCKER_BUF) lint --error-format=json + +proto-check-breaking: + @$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main + +.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking \ No newline at end of file diff --git a/scripts/protocgen.sh b/scripts/protocgen.sh index b33d0a49..b04953be 100755 --- a/scripts/protocgen.sh +++ b/scripts/protocgen.sh @@ -2,14 +2,12 @@ set -eo pipefail -protoc_install_proto_gen_doc() { - echo "Installing protobuf protoc-gen-doc plugin" - (go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest 2> /dev/null) -} +# get protoc executions +go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null echo "Generating gogo proto code" cd proto -proto_dirs=$(find ./cosmwasm -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) +proto_dirs=$(find ./migaloo -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq) for dir in $proto_dirs; do for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do if grep "option go_package" $file &> /dev/null ; then @@ -18,15 +16,8 @@ for dir in $proto_dirs; do done done -protoc_install_proto_gen_doc - -echo "Generating proto docs" -buf generate --template buf.gen.doc.yml - cd .. -# move proto files to the right places -cp -r github.com/CosmWasm/wasmd/* ./ rm -rf github.com go mod tidy