-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
88 lines (67 loc) · 2.35 KB
/
makefile
File metadata and controls
88 lines (67 loc) · 2.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
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
86
87
# vim: set noexpandtab fo-=t:
# https://www.gnu.org/software/make/manual/make.html
.PHONY: default
default:
########################################################################
# boiler plate
########################################################################
SHELL=bash
current_makefile:=$(lastword $(MAKEFILE_LIST))
current_makefile_dirname:=$(dir $(current_makefile))
current_makefile_dirname_abspath:=$(dir $(abspath $(current_makefile)))
current_makefile_dirname_realpath:=$(dir $(realpath $(current_makefile)))
ifneq ($(filter all vars,$(VERBOSE)),)
dump_var=$(info var $(1)=$($(1)))
dump_vars=$(foreach var,$(1),$(call dump_var,$(var)))
else
dump_var=
dump_vars=
endif
ifneq ($(filter all targets,$(VERBOSE)),)
__ORIGINAL_SHELL:=$(SHELL)
SHELL=$(warning Building $@$(if $<, (from $<))$(if $?, ($? newer)))$(TIME) $(__ORIGINAL_SHELL)
endif
define __newline
endef
skip=
# skipable makes the targets passed to it skipable with skip=foo%
# $(1): targets that should be skipable
skipable=$(filter-out $(skip),$(1))
go_install=GOFLAGS= go install $(if $(filter all commands,$(VERBOSE)),-v) $(go_install_flags)
########################################################################
# variables
########################################################################
GOPATH:=$(shell type go >/dev/null 2>&1 && go env GOPATH)
export PATH:=$(if $(GOPATH),$(GOPATH)/bin:,)$(PATH)
########################################################################
# targets
########################################################################
.PHONY: toolchain
toolchain:
$(go_install) github.com/golangci/golangci-lint/cmd/[email protected]
.PHONY: toolchain-update
toolchain-update: go_get_flags+=-u
toolchain-update: toolchain
.PHONY: fetch-deps
fetch-deps:
go mod vendor
.PHONY: validate-static
validate-static:
golangci-lint run $(if $(filter all commands,$(VERBOSE)),-v) ./...
.PHONY: validate-fix
validate-fix:
golangci-lint run $(if $(filter all commands,$(VERBOSE)),-v) --fix ./...
.PHONY: test
test:
go test -cover -race \
-coverprofile=coverage.out -covermode=atomic \
$(if $(filter all commands,$(VERBOSE)),-v) \
$(if $(gotest_files),$(gotest_files),./...) \
$(gotest_args) \
.PHONY: view-coverage
view-coverage:
go tool cover -html=coverage.out
.PHONY: validate-dynamic
validate-dynamic: test
.PHONY: validate
validate: validate-static validate-dynamic