forked from Dataman-Cloud/crane
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (51 loc) · 1.6 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
.PHONY: build doc fmt lint run test vet test-cover-html test-cover-func collect-cover-data
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
default: build
build: fmt
${BUILD_OPTS} go build -ldflags "-X github.com/Dataman-Cloud/crane/src/version.BuildTime=`date -u +%Y-%m-%d:%H-%M-%S` -X github.com/Dataman-Cloud/crane/src/version.Version 1.0.0-`git rev-parse --short HEAD`" -v -o ./bin/crane ./src/
rel: fmt
${BUILD_OPTS} go build -v -o ../rel/crane ./src/
doc:
godoc -http=:6060 -index
# http://golang.org/cmd/go/#hdr-Run_gofmt_on_package_sources
fmt:
go fmt ./src/...
# https://github.com/golang/lint
# go get github.com/golang/lint/golint
lint:
golint ./src/
run: build
./bin/crane
test:
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:
rm -rf ../bin/* ../rel/*
PACKAGES = $(shell find ./src/ -type d -not -path '*/\.*')
collect-cover-data:
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:
go tool cover -html=coverage-all.out -o coverage.html
test-cover-func:
go tool cover -func=coverage-all.out