-
Notifications
You must be signed in to change notification settings - Fork 170
/
Makefile
88 lines (70 loc) · 2.02 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
PACKAGES = $(shell go list ./src/...)
.PHONY: build doc fmt lint run test vet test-cover-html test-cover-func collect-cover-data AUTHORS
## OS checking
OS := $(shell uname)
ifeq ($(OS),Darwin)
BUILD_OPTS=
else
BUILD_OPTS=CGO_ENABLED=0 GOOS=linux GOARCH=amd64
endif
# Prepend our vendor directory to the system GOPATH
# so that import path resolution will prioritize
# our third party snapshots.
export GO15VENDOREXPERIMENT=1
#GOPATH := ${PWD}/vendor:${GOPATH}
# export GOPATH
# Used to populate version variable in main package.
VERSION=$(shell git describe --always --tags)
BUILD_TIME=$(shell date -u +%Y-%m-%d:%H-%M-%S)
GO_LDFLAGS=-ldflags "-X `go list ./src/version`.Version=$(VERSION) -X `go list ./src/version`.BuildTime=$(BUILD_TIME)"
default: build
build: fmt
@echo "🐳 $@"
${BUILD_OPTS} go build ${GO_LDFLAGS} -v -o ./bin/crane ./src/
rel: fmt
@echo "🐳 $@"
${BUILD_OPTS} go build -v -o ../rel/crane ./src/
doc:
@echo "🐳 $@"
godoc -http=:6060 -index
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources
fmt:
@echo "🐳 $@"
go fmt ./src/...
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
lint:
@echo "🐳 $@"
@test -z "$$(golint ./src/... | tee /dev/stderr)"
run: build
@echo "🐳 $@"
./bin/crane
test:
@echo "🐳 $@"
go test -cover=true ./src/...
# http://godoc.org/code.google.com/p/go.tools/cmd/vet
# go get code.google.com/p/go.tools/cmd/vet
vet:
# go vet ./src/...
#
clean:
@echo "🐳 $@"
rm -rf ../bin/* ../rel/*
collect-cover-data:
@echo "🐳 $@"
@echo "mode: count" > coverage-all.out
$(foreach pkg,$(PACKAGES),\
go test -v -coverprofile=coverage.out -covermode=count $(pkg) || exit $$?;\
if [ -f coverage.out ]; then\
tail -n +2 coverage.out >> coverage-all.out;\
fi\
;)
test-cover-html:
@echo "🐳 $@"
go tool cover -html=coverage-all.out -o coverage.html
test-cover-func:
@echo "🐳 $@"
go tool cover -func=coverage-all.out
AUTHORS: .mailmap .git/HEAD
@echo "🐳 $@"
git log --format='%aN <%aE>' | LC_ALL=C.UTF-8 sort -uf > $@