-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (40 loc) · 1.4 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
.PHONY: all clean generate fmt
.PHONY: tidy get build test up
GO ?= go
GOFMT ?= gofmt
GOFMT_FLAGS = -w -l -s
GOGENERATE_FLAGS = -v
GOPATH ?= $(shell $(GO) env GOPATH)
GOBIN ?= $(GOPATH)/bin
REVIVE ?= $(GOBIN)/revive
REVIVE_CONF ?= $(CURDIR)/tools/revive.toml
REVIVE_RUN_ARGS ?= -config $(REVIVE_CONF) -formatter friendly
REVIVE_INSTALL_URL ?= github.com/mgechev/revive
V = 0
Q = $(if $(filter 1,$V),,@)
M = $(shell if [ "$$(tput colors 2> /dev/null || echo 0)" -ge 8 ]; then printf "\033[34;1m▶\033[0m"; else printf "▶"; fi)
TMPDIR ?= .tmp
all: get generate tidy build
clean: ; $(info $(M) cleaning…)
rm -rf $(TMPDIR)
fmt: ; $(info $(M) reformatting sources…)
$Q find . -name '*.go' | xargs -r $(GOFMT) $(GOFMT_FLAGS)
tidy: | fmt $(REVIVE) ; $(info $(M) tidying up…)
$Q $(GO) mod tidy
$Q $(GO) vet ./...
$Q $(REVIVE) $(REVIVE_RUN_ARGS) ./...
get: ; $(info $(M) downloading dependencies…)
$Q $(GO) get -v -tags tools ./...
$Q $(GO) install -v $(REVIVE_INSTALL_URL)
build: ; $(info $(M) building…)
$Q $(GO) build -v ./...
test: ; $(info $(M) building…)
$Q $(GO) test -v ./...
up: ; $(info $(M) updating dependencies…)
$Q $(GO) get -u -v ./...
$Q $(GO) mod tidy
$Q $(GO) install -v $(REVIVE_INSTALL_URL)
generate: ; $(info $(M) generating data…)
$Q git grep -l '^//go:generate' | sort -uV | xargs -r -n1 $(GO) generate $(GOGENERATE_FLAGS)
$(REVIVE):
$Q $(GO) install -v $(REVIVE_INSTALL_URL)