-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
44 lines (31 loc) · 952 Bytes
/
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
GO ?= go
goBuildFlags ?= -race -x
goBuildDir ?= bin
goAppName ?= dontpad-cli
installDir ?= /usr/local/bin
reportDir ?= report
packages := $(shell $(GO) list ./...)
.PHONY: all build pre-build clean install uninstall test
all: build
build: pre-build
$(GO) build $(goBuildFlags) -o $(goBuildDir)/$(goAppName) app.go
pre-build: clean
mkdir $(goBuildDir)
clean:
rm -rf $(goBuildDir)
install:
ln -s $(shell pwd)/$(goBuildDir)/$(goAppName) $(installDir)
uninstall:
rm -f $(installDir)/$(goAppName)
test: pre-test
echo "mode: count" > $(reportDir)/coverage-all.out
$(foreach pkg,$(packages),\
touch $(reportDir)/coverage.out;\
$(GO) test -coverprofile=$(reportDir)/coverage.out -covermode=count $(pkg);\
tail -n +2 $(reportDir)/coverage.out >> $(reportDir)/coverage-all.out;\
)
mv -f $(reportDir)/coverage-all.out $(reportDir)/coverage.out
pre-test: clean-old-reports
mkdir -p $(reportDir)
clean-old-reports:
rm -rf $(reportDir)