forked from pingcap/tidb
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
153 lines (123 loc) · 4.34 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
### Makefile for tidb
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH)
GO := GO15VENDOREXPERIMENT="1" go
ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
PACKAGES := $$(go list ./...| grep -vE 'vendor')
FILES := $$(find . -name '*.go' | grep -vE 'vendor')
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tidb/util/printer.TiDBGitHash=$(shell git rev-parse HEAD)"
TARGET = ""
.PHONY: all build install update parser clean todo test gotest interpreter server dev benchkv check
default: server buildsucc
buildsucc:
@echo Build TiDB Server successfully!
all: dev server install benchkv
dev: parser build benchkv test check
build:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) build
rm -rf vendor
install:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) install ./...
rm -rf vendor
TEMP_FILE = temp_parser_file
goyacc:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) build -o bin/goyacc parser/goyacc/main.go
rm -rf vendor
parser: goyacc
bin/goyacc -o /dev/null -xegen $(TEMP_FILE) parser/parser.y
bin/goyacc -o parser/parser.go -xe $(TEMP_FILE) parser/parser.y 2>&1 | egrep "(shift|reduce)/reduce" | awk '{print} END {if (NR > 0) {print "Find conflict in parser.y. Please check y.output for more information."; system("rm -f $(TEMP_FILE)"); exit 1;}}'
rm -f $(TEMP_FILE)
rm -f y.output
@if [ $(ARCH) = $(LINUX) ]; \
then \
sed -i -e 's|//line.*||' -e 's/yyEofCode/yyEOFCode/' parser/parser.go; \
elif [ $(ARCH) = $(MAC) ]; \
then \
/usr/bin/sed -i "" 's|//line.*||' parser/parser.go; \
/usr/bin/sed -i "" 's/yyEofCode/yyEOFCode/' parser/parser.go; \
fi
@awk 'BEGIN{print "// Code generated by goyacc"} {print $0}' parser/parser.go > tmp_parser.go && mv tmp_parser.go parser/parser.go;
check:
bash gitcookie.sh
go get github.com/golang/lint/golint
@echo "vet"
@ go tool vet $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
@echo "vet --shadow"
@ go tool vet --shadow $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
@echo "golint"
@ golint ./... 2>&1 | grep -vE 'LastInsertId|NewLexer|\.pb\.go' | awk '{print} END{if(NR>0) {exit 1}}'
@echo "gofmt (simplify)"
@ gofmt -s -l -w $(FILES) 2>&1 | awk '{print} END{if(NR>0) {exit 1}}'
errcheck:
go get github.com/kisielk/errcheck
errcheck -blank $(PACKAGES)
clean:
$(GO) clean -i ./...
rm -rf *.out
todo:
@grep -n ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* */*.go parser/parser.y || true
@grep -n TODO */*.go parser/parser.y || true
@grep -n BUG */*.go parser/parser.y || true
@grep -n println */*.go parser/parser.y || true
test: gotest
gotest:
rm -rf vendor && ln -s _vendor/vendor vendor
@export log_level=error;\
$(GO) test -cover $(PACKAGES)
rm -rf vendor
race:
rm -rf vendor && ln -s _vendor/vendor vendor
@export log_level=debug; \
dirs=`go list ./... | grep -vE 'vendor' | awk '{sub("github.com/pingcap/tidb/",""); print}'`;\
for dir in $$dirs; do \
cd $$dir;\
go test -race | awk 'END{if($$1=="FAIL") {exit 1}}' || exit 1;\
cd -;\
done;
rm -rf vendor
tikv_integration_test:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) test ./store/tikv/. -with-tikv=true
rm -rf vendor
interpreter:
rm -rf vendor && ln -s _vendor/vendor vendor
@cd interpreter && $(GO) build -ldflags '$(LDFLAGS)'
rm -rf vendor
server: parser
ifeq ($(TARGET), "")
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) build -ldflags '$(LDFLAGS)' -o bin/tidb-server tidb-server/main.go
rm -rf vendor
else
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) build -ldflags '$(LDFLAGS)' -o '$(TARGET)' tidb-server/main.go
rm -rf vendor
endif
benchkv:
rm -rf vendor && ln -s _vendor/vendor vendor
$(GO) build -ldflags '$(LDFLAGS)' -o bin/benchkv benchkv/main.go
rm -rf vendor
update:
which glide >/dev/null || curl https://glide.sh/get | sh
which glide-vc || go get -v -u github.com/sgotti/glide-vc
rm -r vendor && mv _vendor/vendor vendor || true
rm -rf _vendor
ifdef PKG
glide get -s -v --skip-test ${PKG}
else
glide update -s -v --skip-test
endif
@echo "removing test files"
glide vc --only-code --no-tests
mkdir -p _vendor
mv vendor _vendor/vendor