-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
73 lines (60 loc) · 2.23 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
PD_PKG := github.com/pingcap/pd
VENDOR := $(shell rm -rf _vendor/src/$(PD_PKG) &&\
ln -s `pwd` _vendor/src/$(PD_PKG) &&\
pwd)/_vendor
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.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 check test
build:
ifeq ("$(WITH_RACE)", "1")
GOPATH=$(VENDOR) ENABLE_CGO=1 go build -race -ldflags '$(LDFLAGS)' -o bin/pd-server cmd/pd-server/main.go
else
GOPATH=$(VENDOR) go build -ldflags '$(LDFLAGS)' -o bin/pd-server cmd/pd-server/main.go
endif
GOPATH=$(VENDOR) go build -ldflags '$(LDFLAGS)' -o bin/pd-ctl cmd/pd-ctl/main.go
GOPATH=$(VENDOR) go build -o bin/pd-tso-bench cmd/pd-tso-bench/main.go
GOPATH=$(VENDOR) go build -o bin/pd-recover cmd/pd-recover/main.go
test:
# testing..
@GOPATH=$(VENDOR) ENABLE_CGO=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 glide >/dev/null || curl https://glide.sh/get | sh
which glide-vc || go get -v -u github.com/sgotti/glide-vc
rm -rf vendor && mv _vendor/src vendor || true
rm -rf _vendor
ifdef PKG
glide get --strip-vendor --skip-test ${PKG}
else
glide update --strip-vendor --skip-test
endif
@echo "removing test files"
glide vc --only-code --no-tests
mkdir -p _vendor
mv vendor _vendor/src
.PHONY: update clean