-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
71 lines (56 loc) · 1.36 KB
/
Makefile
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
61
62
63
64
65
66
67
68
69
70
71
# set makefile echo back
ifdef VERBOSE
V :=
else
V := @
endif
tag := $(shell git describe --abbrev=0 --always --dirty --tags)
sha := $(shell git rev-parse --short HEAD)
git_tag_sha := $(tag):$(sha)
LDFLAGS="-X 'github.com/JackDrogon/project/pkg/version.GitTagSha=$(git_tag_sha)'"
GOFLAGS=
# COVERAGE=ON to enable coverage
ifeq ($(COVERAGE),ON)
GOFLAGS += -cover
endif
.PHONY: default
## default: Build project
default: project
.PHONY: build
## build : Build binaries
build: project
.PHONY: bin
## bin : Create bin directory
bin:
$(V)mkdir -p bin
.PHONY: lint
## lint : Lint codespace
# TODO(Drogon): add golang lint
lint:
$(V)golangci-lint run
.PHONY: fmt
## fmt : Format all code
fmt:
$(V)go fmt ./...
.PHONY: test
## test : Run test
test:
$(V)go test (shell go list ./...) | grep -F -v '[no test files]'
.PHONY: cloc
## cloc : Count lines of code
cloc:
$(V)tokei -C .
.PHONY: todos
## todos : Print all todos
todos:
$(V)grep -rnw . -e "TODO" | grep -v '^./pkg/rpc/thrift' | grep -v '^./.git'
.PHONY: help
## help : Print help message
help: Makefile
@sed -n 's/^##//p' $< | awk 'BEGIN {FS = ":"} {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}'
# --------------- ------------------ ---------------
# --------------- User Defined Tasks ---------------
.PHONY: project
## project : Build project
project: bin
$(V)go build -ldflags $(LDFLAGS) -o bin/project ./cmd/project