-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
76 lines (55 loc) · 1.68 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
.PHONY: dist test clean all
ifeq ($(GO_CMD),)
GO_CMD:=go
endif
VERSION := $(shell git describe --always)
GO_BUILD := CGO_ENABLED=0 $(GO_CMD) build -ldflags "-X main.version=$(VERSION)"
TARGETS=\
go-split
SRCS_OTHER := $(shell find . \
-type d -name cmd -prune -o \
-type f -name "*.go" -print) go.mod
DIR_BIN := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))/bin
TOOL_STRINGER = $(DIR_BIN)/stringer
TOOL_STATICCHECK = $(DIR_BIN)/staticcheck
TOOLS = \
$(TOOL_STRINGER) \
$(TOOL_STATICCHECK)
all: $(TARGETS)
@echo "$@ done." 1>&2
clean:
/bin/rm -f $(TARGETS)
@echo "$@ done." 1>&2
test:
$(GO_CMD) test -covermode atomic -cover `$(GO_CMD) list ./... | egrep -v '/cmd/'`
@echo "$@ done." 1>&2
.PHONY: test-detail
test-detail:
$(GO_CMD) test -coverprofile=reports/coverage.out -json `$(GO_CMD) list ./... | egrep -v '/cmd/'` > reports/test.json
@echo "$@ done." 1>&2
.PHONY: sonar
sonar: test-detail
./gradlew sonar
@echo "$@ done." 1>&2
.PHONY: tools
tools: $(TOOLS)
@echo "$@ done." 1>&2
.PHONY: lint
lint: $(TOOL_STATICCHECK)
$(TOOL_STATICCHECK) ./...
$(TOOL_STATICCHECK): export GOBIN=$(DIR_BIN)
$(TOOL_STATICCHECK): $(TOOLS_DEP)
@echo "### `basename $@` install destination=$(GOBIN)" 1>&2
CGO_ENABLED=0 $(GO_CMD) install honnef.co/go/tools/cmd/staticcheck@v0.4.7
$(TOOL_STRINGER): export GOBIN=$(DIR_BIN)
$(TOOL_STRINGER): Makefile
@echo "### `basename $@` install destination=$(GOBIN)" 1>&2
CGO_ENABLED=0 $(GO_CMD) install golang.org/x/tools/cmd/stringer@v0.21.0
.PHONY: gen
TMP_PATH := $(DIR_BIN):$(PATH)
gen: export PATH=$(TMP_PATH)
gen: tools
$(GO_CMD) generate ./...
@echo "$@ done." 1>&2
go-split: cmd/go-split/* $(SRCS_OTHER)
$(GO_BUILD) -o $@ ./cmd/go-split/