-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
60 lines (48 loc) · 1.35 KB
/
Copy pathMakefile
File metadata and controls
60 lines (48 loc) · 1.35 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
### Go Variables
GOCMD=go
GOTEST=$(GOCMD) test
GOVET=$(GOCMD) vet
### Output Variables
BINARY_NAME=lol
VERSION ?= 0.0.0
OUT_DIR := ./out/bin
TARGET := $(OUT_DIR)/$(BINARY_NAME)
### TPUT Variables
GREEN := $(shell tput -Txterm setaf 2)
YELLOW := $(shell tput -Txterm setaf 3)
WHITE := $(shell tput -Txterm setaf 7)
CYAN := $(shell tput -Txterm setaf 6)
RESET := $(shell tput -Txterm sgr0)
.PHONY: all test build vendor
all: help
## Build:
build: ## Build your project and put the output binary in out/bin/
mkdir -p out/bin
$(GOCMD) build -o $(TARGET)
.PHONEY: clean
clean: ## Remove build related file
go clean
rm ${TARGET}
vendor: ## Copy of all packages needed to support builds and tests in the vendor directory
$(GOCMD) mod vendor
## Test:
test: ## Run the tests of the project
$(GOTEST) -v -race ./... $(OUTPUT_OPTIONS)
## Lint:
lint: lint-go lint-reportcard ## Run all available linters
lint-go:
go vet
golint
lint-reportcard: ## Use goreportcard-cli on your project
goreportcard-cli
## Help:
help: ## Show this help.
@echo ''
@echo 'Usage:'
@echo ' ${YELLOW}make${RESET} ${GREEN}<command>${RESET}'
@echo ''
@echo 'Targets:'
@awk 'BEGIN {FS = ":.*?## "} { \
if (/^[a-zA-Z_-]+:.*?##.*$$/) {printf " ${YELLOW}%-20s${GREEN}%s${RESET}\n", $$1, $$2} \
else if (/^## .*$$/) {printf " ${CYAN}%s${RESET}\n", substr($$1,4)} \
}' $(MAKEFILE_LIST)