-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
aofengli
authored
Feb 13, 2023
1 parent
d2e1621
commit 767e76a
Showing
135 changed files
with
5,366 additions
and
2,761 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ | |
# previous "buf.yaml" configuration. | ||
version: v1 | ||
directories: | ||
- proto | ||
- proto | ||
- third_party/proto |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,9 +15,13 @@ ifeq ($(GO),) | |
$(error could not find go. Is it in PATH? $(GO)) | ||
endif | ||
|
||
############################################################################### | ||
### Functions ### | ||
############################################################################### | ||
GOPATH ?= $(shell $(GO) env GOPATH) | ||
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com | ||
GOLANGCI_LINT_HASHSUM := 8d21cc95da8d3daf8321ac40091456fc26123c964d7c2281d339d431f2f4c840 | ||
|
||
### | ||
# Functions | ||
### | ||
|
||
go_get = $(if $(findstring Windows_NT,$(OS)),\ | ||
IF NOT EXIST $(GITHUBDIR)$(FS)$(1)$(FS) ( mkdir $(GITHUBDIR)$(FS)$(1) ) else (cd .) &\ | ||
|
@@ -31,39 +35,97 @@ cd $(GITHUBDIR)$(FS)$(1)$(FS)$(2) && git fetch origin && git checkout -q $(3) | |
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
mkfile_dir := $(shell cd $(shell dirname $(mkfile_path)); pwd) | ||
|
||
|
||
############################################################################### | ||
### Tools ### | ||
############################################################################### | ||
### | ||
# tools | ||
### | ||
|
||
PREFIX ?= /usr/local | ||
BIN ?= $(PREFIX)/bin | ||
UNAME_S ?= $(shell uname -s) | ||
UNAME_M ?= $(shell uname -m) | ||
|
||
GOPATH ?= $(shell $(GO) env GOPATH) | ||
GITHUBDIR := $(GOPATH)$(FS)src$(FS)github.com | ||
|
||
BUF_VERSION ?= 0.11.0 | ||
|
||
TOOLS_DESTDIR ?= $(GOPATH)/bin | ||
STATIK = $(TOOLS_DESTDIR)/statik | ||
|
||
GOLANGCI_LINT = $(TOOLS_DESTDIR)/golangci-lint | ||
STATIK = $(TOOLS_DESTDIR)/statik | ||
RUNSIM = $(TOOLS_DESTDIR)/runsim | ||
|
||
tools: tools-stamp | ||
tools-stamp: statik runsim | ||
# Create dummy file to satisfy dependency and avoid | ||
# rebuilding when this Makefile target is hit twice | ||
# in a row. | ||
touch $@ | ||
all: tools | ||
|
||
tools: statik golangci-lint proto-tools | ||
|
||
golangci-lint: $(GOLANGCI_LINT) | ||
$(GOLANGCI_LINT): $(mkfile_dir)/install-golangci-lint.sh | ||
@echo "Installing golangci-lint..." | ||
@bash $(mkfile_dir)/install-golangci-lint.sh $(TOOLS_DESTDIR) $(GOLANGCI_LINT_HASHSUM) | ||
|
||
# Install the runsim binary | ||
statik: $(STATIK) | ||
$(STATIK): | ||
@echo "Installing statik..." | ||
@go install github.com/rakyll/[email protected] | ||
@(cd /tmp && go get github.com/rakyll/[email protected]) | ||
|
||
PROTOC_VERSION ?= 3.13.0 | ||
PROTOC_GRPC_GATEWAY_VERSION = 1.14.7 | ||
ifeq ($(UNAME_S),Linux) | ||
PROTOC_ZIP ?= protoc-3.13.0-linux-x86_64.zip | ||
PROTOC_GRPC_GATEWAY_BIN ?= protoc-gen-grpc-gateway-v1.14.7-linux-x86_64 | ||
endif | ||
ifeq ($(UNAME_S),Darwin) | ||
PROTOC_ZIP ?= protoc-3.13.0-osx-x86_64.zip | ||
PROTOC_GRPC_GATEWAY_BIN ?= protoc-gen-grpc-gateway-v1.14.7-darwin-x86_64 | ||
endif | ||
|
||
proto-tools: buf | ||
ifeq (, $(shell which protoc)) | ||
@echo "Installing protoc compiler..." | ||
@(cd /tmp; \ | ||
curl -OL "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/${PROTOC_ZIP}"; \ | ||
unzip -o ${PROTOC_ZIP} -d $(PREFIX) bin/protoc; \ | ||
unzip -o ${PROTOC_ZIP} -d $(PREFIX) 'include/*'; \ | ||
rm -f ${PROTOC_ZIP}) | ||
else | ||
@echo "protoc already installed; skipping..." | ||
endif | ||
|
||
ifeq (, $(shell which protoc-gen-gocosmos)) | ||
@echo "Installing protoc-gen-gocosmos..." | ||
@go install github.com/regen-network/cosmos-proto/protoc-gen-gocosmos | ||
else | ||
@echo "protoc-gen-gocosmos already installed; skipping..." | ||
endif | ||
|
||
ifeq (, $(shell which protoc-gen-grpc-gateway)) | ||
@echo "Installing protoc-gen-grpc-gateway..." | ||
@curl -o "${BIN}/protoc-gen-grpc-gateway" -L "https://github.com/grpc-ecosystem/grpc-gateway/releases/download/v${PROTOC_GRPC_GATEWAY_VERSION}/${PROTOC_GRPC_GATEWAY_BIN}" | ||
@chmod +x "${BIN}/protoc-gen-grpc-gateway" | ||
else | ||
@echo "protoc-gen-grpc-gateway already installed; skipping..." | ||
endif | ||
|
||
ifeq (, $(shell which protoc-gen-swagger)) | ||
@echo "Installing protoc-gen-swagger..." | ||
@go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-swagger | ||
@npm install -g swagger-combine | ||
else | ||
@echo "protoc-gen-grpc-gateway already installed; skipping..." | ||
endif | ||
|
||
buf: buf-stamp | ||
|
||
buf-stamp: | ||
@echo "Installing buf..." | ||
@curl -sSL \ | ||
"https://github.com/bufbuild/buf/releases/download/v${BUF_VERSION}/buf-${UNAME_S}-${UNAME_M}" \ | ||
-o "${BIN}/buf" && \ | ||
chmod +x "${BIN}/buf" | ||
|
||
touch $@ | ||
|
||
# Install the runsim binary | ||
# Install the runsim binary with a temporary workaround of entering an outside | ||
# directory as the "go get" command ignores the -mod option and will polute the | ||
# go.{mod, sum} files. | ||
# | ||
# ref: https://github.com/golang/go/issues/30515 | ||
runsim: $(RUNSIM) | ||
$(RUNSIM): | ||
@echo "Installing runsim..." | ||
|
@@ -73,4 +135,4 @@ tools-clean: | |
rm -f $(STATIK) $(GOLANGCI_LINT) $(RUNSIM) | ||
rm -f tools-stamp | ||
|
||
.PHONY: tools-clean statik runsim | ||
.PHONY: tools-clean statik runsim |
Oops, something went wrong.