Skip to content

Commit 6e86664

Browse files
committed
add protogen
1 parent 4d19263 commit 6e86664

File tree

2 files changed

+32
-12
lines changed

2 files changed

+32
-12
lines changed

Makefile

+29
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,32 @@ install: go.sum
9292

9393
build:
9494
go build $(BUILD_FLAGS) -o bin/migalood ./cmd/migalood
95+
96+
###############################################################################
97+
### Proto ###
98+
###############################################################################
99+
100+
protoVer=0.11.6
101+
protoImageName=ghcr.io/cosmos/proto-builder:$(protoVer)
102+
containerProtoGen=proto-gen-$(protoVer)
103+
containerProtoFmt=proto-fmt-$(protoVer)
104+
105+
proto-all: proto-format proto-gen
106+
107+
proto-gen:
108+
@echo "Generating Protobuf files"
109+
@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) \
110+
sh ./scripts/protocgen.sh; fi
111+
112+
proto-format:
113+
@echo "Formatting Protobuf files"
114+
@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 \
115+
find ./ -not -path "./third_party/*" -name "*.proto" -exec clang-format -i {} \; ; fi
116+
117+
proto-lint:
118+
@$(DOCKER_BUF) lint --error-format=json
119+
120+
proto-check-breaking:
121+
@$(DOCKER_BUF) breaking --against $(HTTPS_GIT)#branch=main
122+
123+
.PHONY: proto-all proto-gen proto-format proto-lint proto-check-breaking

scripts/protocgen.sh

+3-12
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
set -eo pipefail
44

5-
protoc_install_proto_gen_doc() {
6-
echo "Installing protobuf protoc-gen-doc plugin"
7-
(go install github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc@latest 2> /dev/null)
8-
}
5+
# get protoc executions
6+
go get github.com/regen-network/cosmos-proto/protoc-gen-gocosmos 2>/dev/null
97

108
echo "Generating gogo proto code"
119
cd proto
12-
proto_dirs=$(find ./cosmwasm -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
10+
proto_dirs=$(find ./migaloo -path -prune -o -name '*.proto' -print0 | xargs -0 -n1 dirname | sort | uniq)
1311
for dir in $proto_dirs; do
1412
for file in $(find "${dir}" -maxdepth 1 -name '*.proto'); do
1513
if grep "option go_package" $file &> /dev/null ; then
@@ -18,15 +16,8 @@ for dir in $proto_dirs; do
1816
done
1917
done
2018

21-
protoc_install_proto_gen_doc
22-
23-
echo "Generating proto docs"
24-
buf generate --template buf.gen.doc.yml
25-
2619
cd ..
2720

28-
# move proto files to the right places
29-
cp -r github.com/CosmWasm/wasmd/* ./
3021
rm -rf github.com
3122

3223
go mod tidy

0 commit comments

Comments
 (0)