-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
82 lines (64 loc) · 1.35 KB
/
Makefile
File metadata and controls
82 lines (64 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
.DEFAULT_GOAL = test
.PHONY: FORCE
# enable consistent Go 1.12/1.13 GOPROXY behavior.
export GOPROXY = https://proxy.golang.org
BINARY = dmt
ifeq ($(OS),Windows_NT)
BINARY := $(BINARY).exe
endif
# Build
build: $(BINARY)
.PHONY: build
build_race:
go build -race -o $(BINARY) ./cmd/dmt
.PHONY: build_race
clean:
rm -f $(BINARY)
.PHONY: clean
# Test
test:
go test -v -race ./...
.PHONY: test
# Linting
lint:
golangci-lint run
.PHONY: lint
lint-fast:
golangci-lint run --fast-only
.PHONY: lint-fast
lint-fix:
golangci-lint run --fix
.PHONY: lint-fix
lint-fix-fast:
golangci-lint run --fast-only --fix
.PHONY: lint-fix-fast
# Git hooks setup
setup-hooks:
./scripts/setup-hooks.sh
.PHONY: setup-hooks
# Mock generation
generate-mocks:
go generate ./pkg/module.go
.PHONY: generate-mocks
# Non-PHONY targets (real files)
$(BINARY): FORCE
go build -o $@ ./cmd/dmt
go.mod: FORCE
go mod tidy
go mod verify
go.sum: go.mod
# Functions
# Check that given variables are set and all have non-empty values,
# die with an error otherwise.
#
# Params:
# 1. Variable name(s) to test.
# 2. (optional) Error message to print.
#
# https://stackoverflow.com/a/10858332/8228109
check_defined = \
$(strip $(foreach 1,$1, \
$(call __check_defined,$1,$(strip $(value 2)))))
__check_defined = \
$(if $(value $1),, \
$(error Undefined $1$(if $2, ($2))))