Skip to content

Commit

Permalink
Restructure protobuf files (#466)
Browse files Browse the repository at this point in the history
* Restructure protobuf dir and generation

* Format protobuf definitions
  • Loading branch information
alpe authored Mar 22, 2021
1 parent 547fed5 commit cfcfa64
Show file tree
Hide file tree
Showing 124 changed files with 10,441 additions and 1,176 deletions.
31 changes: 20 additions & 11 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ BINDIR ?= $(GOPATH)/bin
SIMAPP = ./app

# for dockerized protobuf tools
PROTO_CONTAINER := cosmwasm/prototools-docker:v0.1.0
DOCKER_BUF := docker run --rm -v $(shell pwd)/buf.yaml:/workspace/buf.yaml -v $(shell go list -f "{{ .Dir }}" -m github.com/cosmos/cosmos-sdk):/workspace/cosmos_sdk_dir -v $(shell pwd):/workspace/wasmd --workdir /workspace $(PROTO_CONTAINER)
DOCKER := $(shell which docker)
BUF_IMAGE=bufbuild/buf@sha256:9dc5d6645f8f8a2d5aaafc8957fbbb5ea64eada98a84cb09654e8f49d6f73b3e
DOCKER_BUF := $(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(BUF_IMAGE)
HTTPS_GIT := https://github.com/CosmWasm/wasmd.git

export GO111MODULE = on
Expand Down Expand Up @@ -157,21 +158,29 @@ format:
###############################################################################
### Protobuf ###
###############################################################################
PROTO_BUILDER_IMAGE=tendermintdev/sdk-proto-gen@sha256:372dce7be2f465123e26459973ca798fc489ff2c75aeecd814c0ca8ced24faca
PROTO_FORMATTER_IMAGE=tendermintdev/docker-build-proto@sha256:aabcfe2fc19c31c0f198d4cd26393f5e5ca9502d7ea3feafbfe972448fee7cae

proto-all: proto-gen proto-lint proto-check-breaking
.PHONY: proto-all
proto-all: proto-format proto-lint proto-gen

proto-gen: proto-lint
@docker run --rm -v $(shell go list -f "{{ .Dir }}" -m github.com/cosmos/cosmos-sdk):/workspace/cosmos_sdk_dir -v $(shell pwd):/workspace --workdir /workspace --env COSMOS_SDK_DIR=/workspace/cosmos_sdk_dir $(PROTO_CONTAINER) ./scripts/protocgen.sh
.PHONY: proto-gen
proto-gen:
@echo "Generating Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace --workdir /workspace $(PROTO_BUILDER_IMAGE) sh ./scripts/protocgen.sh

proto-format:
@echo "Formatting Protobuf files"
$(DOCKER) run --rm -v $(CURDIR):/workspace \
--workdir /workspace $(PROTO_FORMATTER_IMAGE) \
find ./ -not -path "./third_party/*" -name *.proto -exec clang-format -i {} \;

proto-swagger-gen:
@./scripts/protoc-swagger-gen.sh

proto-lint:
@$(DOCKER_BUF) buf check lint --error-format=json
.PHONY: proto-lint
@$(DOCKER_BUF) check lint --error-format=json

proto-check-breaking:
@$(DOCKER_BUF) buf check breaking --against-input $(HTTPS_GIT)#branch=master
.PHONY: proto-check-breaking
@$(DOCKER_BUF) check breaking --against-input $(HTTPS_GIT)#branch=master

.PHONY: all build-linux install install-debug \
go-mod-cache draw-deps clean build format \
Expand Down
13 changes: 8 additions & 5 deletions buf.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
version: v1beta1

build:
roots:
# Note: these are not local path. These roots are mounted into the docker container
- wasmd/
- cosmos_sdk_dir/third_party/proto/
- cosmos_sdk_dir/proto/
- proto
- third_party/proto
excludes:
# - cosmos_sdk_dir
- third_party/proto/google/protobuf
lint:
use:
- DEFAULT
Expand All @@ -20,6 +19,8 @@ lint:
- RPC_REQUEST_STANDARD_NAME
- PACKAGE_DIRECTORY_MATCH
ignore:
- cosmos
- ibc
- tendermint
- gogoproto
- cosmos_proto
Expand All @@ -29,6 +30,8 @@ breaking:
use:
- FILE
ignore:
- cosmos
- ibc
- tendermint
- gogoproto
- cosmos_proto
Expand Down
2 changes: 1 addition & 1 deletion doc/README.md → docs/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Generated doc
# Generated doc only

Tutorials and project doc is available on https://docs.cosmwasm.com/
Loading

0 comments on commit cfcfa64

Please sign in to comment.