|
| 1 | +SHELL:=/usr/bin/env bash |
| 2 | + |
| 3 | +.DEFAULT_GOAL:=help |
| 4 | + |
| 5 | +Srv ?= push |
| 6 | +BinPath ?= bin/service.goim.$(Srv) |
| 7 | +CmdPath ?= apps/$(Srv)/cmd/main.go |
| 8 | +CfgPath ?= apps/$(Srv)/configs |
| 9 | +IMAGE ?= goim/$(Srv) |
| 10 | +VERSION ?= $(shell git describe --exact-match --tags 2> /dev/null || git rev-parse --abbrev-ref HEAD) |
| 11 | + |
| 12 | +## env |
| 13 | +export ROCKETMQ_GO_LOG_LEVEL=warn |
| 14 | + |
| 15 | +## jwt |
| 16 | +export JWT_SECRET="goim" |
| 17 | + |
| 18 | +## enable config center |
| 19 | +export ENABLE_CONFIG_CENTER=true |
| 20 | + |
| 21 | +################################################## |
| 22 | +# Development # |
| 23 | +################################################## |
| 24 | + |
| 25 | +##@ Development |
| 26 | + |
| 27 | +.PHONY: lint |
| 28 | +lint: ## Run go lint against code. |
| 29 | + golangci-lint run ./... -v |
| 30 | + |
| 31 | +.PHONY: vet |
| 32 | +vet: ## Run go vet against code. |
| 33 | + go vet -v ./... |
| 34 | + |
| 35 | +.PHONEY: test |
| 36 | +test: ## Run test against code. |
| 37 | + go test -v ./... |
| 38 | + |
| 39 | +################################################## |
| 40 | +# Generate # |
| 41 | +################################################## |
| 42 | + |
| 43 | +##@ Generate |
| 44 | + |
| 45 | +.PHONY: gen-protoc |
| 46 | +gen-protoc: ## Run protoc command to generate pb code. |
| 47 | + # call gen_proto.sh |
| 48 | + ./gen_proto.sh . |
| 49 | + |
| 50 | +.PHONY: tools-install |
| 51 | +tools-install: ## Install tools. |
| 52 | + go get -u github.com/golang/protobuf/protoc-gen-go |
| 53 | + |
| 54 | +.PHONY: generate |
| 55 | +generate: ## generate code by run go generate |
| 56 | + go generate ./... |
| 57 | + |
| 58 | +################################################## |
| 59 | +# General # |
| 60 | +################################################## |
| 61 | + |
| 62 | +##@ General |
| 63 | + |
| 64 | +# The help target prints out all targets with their descriptions organized |
| 65 | +# beneath their categories. The categories are represented by '##@' and the |
| 66 | +# target descriptions by '##'. The awk commands is responsible for reading the |
| 67 | +# entire set of makefiles included in this invocation, looking for lines of the |
| 68 | +# file as xyz: ## something, and then pretty-format the target and help. Then, |
| 69 | +# if there's a line with ##@ something, that gets pretty-printed as a category. |
| 70 | +# More info on the usage of ANSI control characters for terminal formatting: |
| 71 | +# https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_parameters |
| 72 | +# More info on the awk command: |
| 73 | +# http://linuxcommand.org/lc3_adv_awk.php |
| 74 | + |
| 75 | +help: ## Display this help. |
| 76 | + @awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST) |
0 commit comments