Skip to content

Commit

Permalink
refactor(proto): remove protobuf tools
Browse files Browse the repository at this point in the history
protobuf codegeneration is done within
https://github.com/akash-network/akash-api

Signed-off-by: Artur Troian <[email protected]>
  • Loading branch information
troian committed Apr 25, 2023
1 parent 857cc59 commit 751b39d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 77 deletions.
20 changes: 1 addition & 19 deletions make/codegen.mk
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,5 @@ mocks: $(MOCKERY) modvendor
$(MOCKERY) --case=underscore --dir x/escrow/keeper --output x/escrow/keeper/mocks --name BankKeeper
$(MOCKERY) --case=underscore --dir x/deployment/handler --output x/deployment/handler/mocks --name AuthzKeeper

.PHONY: proto-gen
proto-gen: $(PROTOC) $(GRPC_GATEWAY) $(PROTOC_GEN_GOCOSMOS) modvendor
./script/protocgen.sh

.PHONY: proto-swagger-gen
proto-swagger-gen: $(PROTOC) $(PROTOC_SWAGGER_GEN) $(SWAGGER_COMBINE) modvendor
./script/protoc-swagger-gen.sh

.PHONY: update-swagger-docs
update-swagger-docs: $(STATIK) proto-swagger-gen
$(STATIK) -src=client/docs/swagger-ui -dest=client/docs -f -m
@if [ -n "$(git status --porcelain)" ]; then \
echo "\033[91mSwagger docs are out of sync!!!\033[0m"; \
exit 1; \
else \
echo "\033[92mSwagger docs are in sync\033[0m"; \
fi

.PHONY: codegen
codegen: generate proto-gen update-swagger-docs mocks
codegen: generate
21 changes: 5 additions & 16 deletions make/init.mk
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
UNAME_OS := $(shell uname -s)
UNAME_ARCH := $(shell uname -m)

ifeq (, $(shell which direnv))
$(warning "No direnv in $(PATH), consider installing. https://direnv.net")
endif
Expand All @@ -17,9 +20,9 @@ endif
GO_MIN_REQUIRED := $(shell echo $(GOLANG_VERSION) | cut -f1-2 -d ".")
DETECTED_GO_VERSION := $(shell go version | cut -d ' ' -f 3 | sed 's/go*//' | cut -f1-2 -d ".")
STRIPPED_GO_VERSION := $(shell echo $(DETECTED_GO_VERSION) | cut -f1-2 -d ".")
__IS_GO_UPTODATE := $(shell ./script/semver.sh compare $(STRIPPED_GO_VERSION) $(GO_MIN_REQUIRED) && echo $?)
__IS_GO_UPTODATE := $(shell $(ROOT_DIR)/script/semver.sh compare $(STRIPPED_GO_VERSION) $(GO_MIN_REQUIRED) && echo $?)
GO_MOD_VERSION := $(shell go mod edit -json | jq -r .Go | cut -f1-2 -d ".")
__IS_GO_MOD_MATCHING := $(shell ./script/semver.sh compare $(GO_MOD_VERSION) $(GO_MIN_REQUIRED) && echo $?)
__IS_GO_MOD_MATCHING := $(shell $(ROOT_DIR)/script/semver.sh compare $(GO_MOD_VERSION) $(GO_MIN_REQUIRED) && echo $?)

ifneq (0, $(__IS_GO_MOD_MATCHING))
$(error go version $(GO_MOD_VERSION) from go.mod does not match GO_MIN_REQUIRED=$(GO_MIN_REQUIRED))
Expand All @@ -39,10 +42,6 @@ GO_MOD_NAME := $(shell go list -m 2>/dev/null)
# ==== Build tools versions ====
# Format <TOOL>_VERSION
BUF_VERSION ?= 0.35.1
PROTOC_VERSION ?= 3.13.0
PROTOC_GEN_GOCOSMOS_VERSION ?= v0.3.1
GRPC_GATEWAY_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway)
PROTOC_SWAGGER_GEN_VERSION := $(GRPC_GATEWAY_VERSION)
GOLANGCI_LINT_VERSION ?= v1.51.2
GOLANG_VERSION ?= 1.16.1
STATIK_VERSION ?= v0.1.7
Expand All @@ -53,23 +52,13 @@ MOCKERY_VERSION ?= 2.20.2
# ==== Build tools version tracking ====
# <TOOL>_VERSION_FILE points to the marker file for the installed version.
# If <TOOL>_VERSION_FILE is changed, the binary will be re-downloaded.
PROTOC_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc/$(PROTOC_VERSION)
GRPC_GATEWAY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-grpc-gateway/$(GRPC_GATEWAY_VERSION)
PROTOC_GEN_GOCOSMOS_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/protoc-gen-gocosmos/$(PROTOC_GEN_GOCOSMOS_VERSION)
STATIK_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/statik/$(STATIK_VERSION)
MODVENDOR_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/modvendor/$(MODVENDOR_VERSION)
GIT_CHGLOG_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/git-chglog/$(GIT_CHGLOG_VERSION)
MOCKERY_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/mockery/v$(MOCKERY_VERSION)
GOLANGCI_LINT_VERSION_FILE := $(AKASH_DEVCACHE_VERSIONS)/golangci-lint/$(GOLANGCI_LINT_VERSION)

# ==== Build tools executables ====
MODVENDOR := $(AKASH_DEVCACHE_BIN)/modvendor
SWAGGER_COMBINE := $(AKASH_DEVCACHE_NODE_BIN)/swagger-combine
PROTOC_SWAGGER_GEN := $(AKASH_DEVCACHE_BIN)/protoc-swagger-gen
PROTOC := $(AKASH_DEVCACHE_BIN)/protoc
STATIK := $(AKASH_DEVCACHE_BIN)/statik
PROTOC_GEN_GOCOSMOS := $(AKASH_DEVCACHE_BIN)/protoc-gen-gocosmos
GRPC_GATEWAY := $(AKASH_DEVCACHE_BIN)/protoc-gen-grpc-gateway
GIT_CHGLOG := $(AKASH_DEVCACHE_BIN)/git-chglog
MOCKERY := $(AKASH_DEVCACHE_BIN)/mockery
NPM := npm
Expand Down
42 changes: 0 additions & 42 deletions make/setup-cache.mk
Original file line number Diff line number Diff line change
Expand Up @@ -8,48 +8,6 @@ $(AKASH_DEVCACHE):
mkdir -p $(AKASH_DEVCACHE)/run
cache: $(AKASH_DEVCACHE)

$(PROTOC_VERSION_FILE): $(AKASH_DEVCACHE)
@echo "installing protoc compiler v$(PROTOC_VERSION) ..."
rm -f $(PROTOC)
()(cd /tmp; \
curl -sOL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"; \
unzip -oq ${PROTOC_ZIP} -d $(AKASH_DEVCACHE) bin/protoc; \
unzip -oq ${PROTOC_ZIP} -d $(AKASH_DEVCACHE) 'include/*'; \
rm -f ${PROTOC_ZIP})
rm -rf "$(dir $@)"
mkdir -p "$(dir $@)"
touch $@
$(PROTOC): $(PROTOC_VERSION_FILE)

$(PROTOC_GEN_GOCOSMOS_VERSION_FILE): $(AKASH_DEVCACHE) modvendor
@echo "installing protoc-gen-gocosmos $(PROTOC_GEN_GOCOSMOS_VERSION) ..."
rm -f $(PROTOC_GEN_GOCOSMOS)
GOBIN=$(AKASH_DEVCACHE_BIN) $(GO) install $(ROOT_DIR)/vendor/github.com/regen-network/cosmos-proto/protoc-gen-gocosmos
rm -rf "$(dir $@)"
mkdir -p "$(dir $@)"
touch $@
$(PROTOC_GEN_GOCOSMOS): $(PROTOC_GEN_GOCOSMOS_VERSION_FILE)

$(GRPC_GATEWAY_VERSION_FILE): $(AKASH_DEVCACHE)
@echo "Installing protoc-gen-grpc-gateway $(GRPC_GATEWAY_VERSION) ..."
rm -f $(GRPC_GATEWAY)
curl -o "${AKASH_DEVCACHE_BIN}/protoc-gen-grpc-gateway" -L \
"https://github.com/grpc-ecosystem/grpc-gateway/releases/download/${GRPC_GATEWAY_VERSION}/${GRPC_GATEWAY_BIN}"
chmod +x "$(AKASH_DEVCACHE_BIN)/protoc-gen-grpc-gateway"
rm -rf "$(dir $@)"
mkdir -p "$(dir $@)"
touch $@
$(GRPC_GATEWAY): $(GRPC_GATEWAY_VERSION_FILE)

$(STATIK_VERSION_FILE): $(AKASH_DEVCACHE)
@echo "Installing statik $(STATIK_VERSION) ..."
rm -f $(STATIK)
GOBIN=$(AKASH_DEVCACHE_BIN) $(GO) install github.com/rakyll/statik@$(STATIK_VERSION)
rm -rf "$(dir $@)"
mkdir -p "$(dir $@)"
touch $@
$(STATIK): $(STATIK_VERSION_FILE)

$(MODVENDOR_VERSION_FILE): $(AKASH_DEVCACHE)
@echo "installing modvendor $(MODVENDOR_VERSION) ..."
rm -f $(MODVENDOR)
Expand Down

0 comments on commit 751b39d

Please sign in to comment.