-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathMakefile
More file actions
105 lines (78 loc) · 2.55 KB
/
Makefile
File metadata and controls
105 lines (78 loc) · 2.55 KB
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
### Makefile for tidb-binlog
.PHONY: build test check update clean pump drainer fmt diff reparo integration_test
PROJECT=tidb-binlog
# Ensure GOPATH is set before running build process.
ifeq "$(GOPATH)" ""
$(error Please set the environment variable GOPATH before running `make`)
endif
CURDIR := $(shell pwd)
path_to_add := $(addsuffix /bin,$(subst :,/bin:,$(GOPATH)))
export PATH := $(path_to_add):$(PATH)
GO := go
GOBUILD := GO111MODULE=off CGO_ENABLED=0 $(GO) build $(BUILD_FLAG)
GOTEST := GO111MODULE=off CGO_ENABLED=1 $(GO) test -p 3
ARCH := "`uname -s`"
LINUX := "Linux"
MAC := "Darwin"
PACKAGE_LIST := go list ./...| grep -vE 'vendor|cmd|test|proto|diff'
PACKAGES := $$($(PACKAGE_LIST))
PACKAGE_DIRECTORIES := $(PACKAGE_LIST) | sed 's|github.com/pingcap/$(PROJECT)/||'
FILES := $$(find . -name '*.go' -type f | grep -vE 'vendor')
LDFLAGS += -X "github.com/pingcap/tidb-binlog/pkg/version.BuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
LDFLAGS += -X "github.com/pingcap/tidb-binlog/pkg/version.GitHash=$(shell git rev-parse HEAD)"
default: build buildsucc
buildsucc:
@echo Build TiDB Binlog Utils successfully!
all: dev install
dev: check test build
build: pump drainer reparo
pump:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/pump cmd/pump/main.go
drainer:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/drainer cmd/drainer/main.go
diff:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/diff cmd/diff/main.go
reparo:
$(GOBUILD) -ldflags '$(LDFLAGS)' -o bin/reparo cmd/reparo/main.go
install:
go install ./...
test:
@export log_level=error;\
$(GOTEST) -cover $(PACKAGES)
integration_test: build
@which bin/tidb-server
@which bin/tikv-server
@which bin/pd-server
@which bin/drainer
@which bin/pump
@which bin/reparo
tests/run.sh
fmt:
go fmt ./...
@goimports -w $(FILES)
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 '\.pb\.go' | grep -vE 'vendor' | 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}}'
check-static:
gometalinter --disable-all --deadline 120s \
--enable megacheck \
--enable ineffassign \
$$($(PACKAGE_DIRECTORIES))
update: update_vendor clean_vendor
update_vendor:
rm -rf vendor/
GO111MODULE=on go mod verify
GO111MODULE=on go mod vendor
clean:
go clean -i ./...
rm -rf *.out
clean_vendor:
hack/clean_vendor.sh