-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
85 lines (64 loc) · 1.55 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
-include config.mak
GO ?= go
GO_FLAGS ?=
STATICCHECK ?= staticcheck
STATICCHECK_FLAGS ?=
GO_PACKAGES ?= ./...
GO_TEST_FLAGS ?=
GODOC ?= godoc
GODOC_FLAGS ?= -http=:6060
ifeq ($(OS),Windows_NT)
LIST_TOOLS ?= if exist tools.go (for /f tokens^=2^ delims^=^" %%a in ('findstr /r "^[\t ]*_" tools.go') do echo %%a)
else
LIST_TOOLS ?= [ ! -e tools.go ] || grep -E '^[ ]*_' tools.go | cut -d '"' -f 2
endif
.PHONY: all
all: lint build test
.PHONY: clean
clean:
.PHONY: lint
lint: vet staticcheck
.PHONY: build
build:
$(GO) build $(GO_FLAGS) $(GO_PACKAGES)
.PHONY: test
test: test-cover test-race
.PHONY: test-cover
test-cover: build
$(GO) test $(GO_FLAGS) $(GO_TEST_FLAGS) -cover $(GO_PACKAGES)
.PHONY: test-race
test-race: build
$(GO) test $(GO_FLAGS) $(GO_TEST_FLAGS) -race $(GO_PACKAGES)
.PHONY: vet
vet:
$(GO) vet $(GO_FLAGS) $(GO_PACKAGES)
.PHONY: staticcheck
staticcheck:
$(STATICCHECK) $(STATICCHECK_FLAGS) $(GO_PACKAGES)
.PHONY: fmt
fmt:
$(GO) fmt $(GO_PACKAGES)
.PHONY: godoc
godoc:
@echo 'Running godoc, the default URL is http://localhost:6060/pkg/github.com/joeycumines/sesame/'
$(GODOC) $(GODOC_FLAGS)
.PHONY: update
update: GO_TOOLS := $(shell $(LIST_TOOLS))
update:
$(GO) get -u -t ./...
$(foreach tool,$(GO_TOOLS),$(update__TEMPLATE))
$(GO) mod tidy
define update__TEMPLATE =
$(GO) get -u $(tool)
endef
.PHONY: tools
tools: GO_TOOLS := $(shell $(LIST_TOOLS))
tools:
$(foreach tool,$(GO_TOOLS),$(tools__TEMPLATE))
define tools__TEMPLATE =
$(GO) install $(tool)
endef
# this won't work on all systems
.PHONY: generate
generate:
hack/generate.sh