forked from tikv/pd
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
71 lines (56 loc) · 2.03 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
PD_PKG := github.com/pingcap/pd
TEST_PKGS := $(shell find . -iname "*_test.go" -exec dirname {} \; | \
uniq | sed -e "s/^\./github.com\/pingcap\/pd/")
GOFILTER := grep -vE 'vendor|testutil'
GOCHECKER := $(GOFILTER) | awk '{ print } END { if (NR > 0) { exit 1 } }'
LDFLAGS += -X "$(PD_PKG)/server.PDReleaseVersion=$(shell git describe --tags --dirty)"
LDFLAGS += -X "$(PD_PKG)/server.PDBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "$(PD_PKG)/server.PDGitHash=$(shell git rev-parse HEAD)"
LDFLAGS += -X "$(PD_PKG)/server.PDGitBranch=$(shell git rev-parse --abbrev-ref HEAD)"
# Ignore following files's coverage.
#
# See more: https://godoc.org/path/filepath#Match
COVERIGNORE := "cmd/*/*,pdctl/*,pdctl/*/*,server/api/bindata_assetfs.go"
default: build
all: dev
dev: build simulator check test
build:
ifeq ("$(WITH_RACE)", "1")
CGO_ENABLED=1 go build -race -ldflags '$(LDFLAGS)' -o bin/pd-server cmd/pd-server/main.go
else
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o bin/pd-server cmd/pd-server/main.go
endif
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o bin/pd-ctl cmd/pd-ctl/main.go
CGO_ENABLED=0 go build -o bin/pd-tso-bench cmd/pd-tso-bench/main.go
CGO_ENABLED=0 go build -o bin/pd-recover cmd/pd-recover/main.go
test:
# testing..
CGO_ENABLED=1 go test -race -cover $(TEST_PKGS)
check:
go get github.com/golang/lint/golint
@echo "vet"
@ go tool vet . 2>&1 | $(GOCHECKER)
@ go tool vet --shadow . 2>&1 | $(GOCHECKER)
@echo "golint"
@ golint ./... 2>&1 | $(GOCHECKER)
@echo "gofmt"
@ gofmt -s -l . 2>&1 | $(GOCHECKER)
travis_coverage:
ifeq ("$(TRAVIS_COVERAGE)", "1")
GOPATH=$(VENDOR) $(HOME)/gopath/bin/goveralls -service=travis-ci -ignore $(COVERIGNORE)
else
@echo "coverage only runs in travis."
endif
update:
which dep 2>/dev/null || go get -u github.com/golang/dep/cmd/dep
ifdef PKG
dep ensure -add ${PKG}
else
dep ensure -update
endif
@echo "removing test files"
dep prune
bash ./hack/clean_vendor.sh
simulator:
CGO_ENABLED=0 go build -o bin/simulator cmd/simulator/main.go
.PHONY: update clean