-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
48 lines (41 loc) · 1.08 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
BINARY := nqueens
TEST_MODE ?= count
VERSION ?= vlatest
BIN_DIR := $(GOPATH)/bin
GOLINT=$(BIN_DIR)/golint
PACKAGES=$(shell go list ./... | grep -v /vendor/)
GOLINT_REPO=github.com/golang/lint/golint
PLATFORMS := windows linux darwin
os = $(word 1, $@)
$(GOLINT):
go get -u $(GOLINT_REPO)
.PHONY: lint
lint: $(GOLINT)
for PKG in $(PACKAGES); do \
golint -set_exit_status $$PKG || exit 1; \
done;
.PHONY: test
test: clean
echo "mode: $(TEST_MODE)" > c.out; \
for PKG in $(PACKAGES); do \
go test -v -covermode=$(TEST_MODE) -coverprofile=profile.out $$PKG; \
if [ -f profile.out ]; then \
cat profile.out | grep -v "mode:" >> c.out; \
rm profile.out; \
fi; \
done;
.PHONY: cover
cover: test
go tool cover -html=c.out -o=coverage.html; \
rm -f c.out;
.PHONY: clean
clean:
rm -f coverage.html; \
rm -f c.out; \
rm -rf release;
.PHONY: $(PLATFORMS)
$(PLATFORMS): clean
mkdir -p release; \
GOOS=$(os) GOARCH=amd64 go build -o release/$(BINARY)-$(VERSION)-$(os)-amd64;
.PHONY: release
release: windows linux darwin