forked from selectdb/ccr-syncer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (131 loc) · 4.36 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
154
155
156
157
158
159
160
161
162
163
# set makefile echo back
ifdef VERBOSE
V :=
else
V := @
endif
tag := $(shell git describe --abbrev=0 --always --dirty --tags)
sha := $(shell git rev-parse --short HEAD)
git_tag_sha := $(tag):$(sha)
ifeq ($(shell uname -i),x86_64)
# Make them happy
platform := x64
else
platform := arm64
endif
tarball_suffix := $(tag)-$(platform)
LDFLAGS="-X 'github.com/selectdb/ccr_syncer/pkg/version.GitTagSha=$(git_tag_sha)'"
GOFLAGS=
GOFORMAT := gofmt -l -d -w
# COVERAGE=ON make
ifeq ($(COVERAGE),ON)
GOFLAGS += -cover
endif
.PHONY: flag_coverage
## COVERAGE=ON : Set coverage flag
.PHONY: default
## default: Build ccr_syncer
default: ccr_syncer
.PHONY: build
## build : Build binary
build: ccr_syncer get_binlog ingest_binlog get_meta snapshot_op get_master_token spec_checker rows_parse
.PHONY: bin
## bin : Create bin directory
bin:
@mkdir -p bin
.PHONY: lint
## lint : Lint codespace
# TODO(Drogon): add golang lint
lint:
$(V)golangci-lint run
.PHONY: fmt
## fmt : Format all code
fmt:
$(V)$(GOFORMAT) .
.PHONY: test
## test : Run test
test:
$(V)go test $(shell go list ./... | grep -v github.com/selectdb/ccr_syncer/cmd | grep -v github.com/selectdb/ccr_syncer/pkg/rpc/kitex_gen/)
.PHONY: help
## help : Print help message
help: Makefile
@sed -n 's/^##//p' $< | awk 'BEGIN {FS = ":"} {printf "\033[36m%-23s\033[0m %s\n", $$1, $$2}'
# --------------- ------------------ ---------------
# --------------- User Defined Tasks ---------------
.PHONY: cloc
## cloc : Count lines of code
cloc:
$(V)tokei -C . -e pkg/rpc/kitex_gen -e pkg/rpc/thrift
.PHONY: gen_mock
## gen_mock : Generate mock
gen_mock:
$(V)mockgen -source=pkg/rpc/fe.go -destination=pkg/ccr/fe_mock.go -package=ccr
$(V)mockgen -source=pkg/ccr/metaer.go -destination=pkg/ccr/metaer_mock.go -package=ccr
$(V)mockgen -source=pkg/ccr/metaer_factory.go -destination=pkg/ccr/metaer_factory_mock.go -package=ccr
$(V)mockgen -source=pkg/rpc/rpc_factory.go -destination=pkg/ccr/rpc_factory_mock.go -package=ccr
.PHONY: ccr_syncer
## ccr_syncer : Build ccr_syncer binary
ccr_syncer: bin
$(V)go build ${GOFLAGS} -ldflags ${LDFLAGS} -o bin/ccr_syncer ./cmd/ccr_syncer
.PHONY: get_binlog
## get_binlog : Build get_binlog binary
get_binlog: bin
$(V)go build -o bin/get_binlog ./cmd/get_binlog
## run_get_binlog : Run get_binlog binary
run_get_binlog: get_binlog
$(V)bin/get_binlog
.PHONY: sync_thrift
## sync_thrift : Sync thrift
sync_thrift:
$(V)rsync -avc $(THRIFT_DIR)/ pkg/rpc/thrift/
$(V)$(MAKE) -C pkg/rpc/ gen_thrift
.PHONY: ingest_binlog
## ingest_binlog : Build ingest_binlog binary
ingest_binlog: bin
$(V)go build -o bin/ingest_binlog ./cmd/ingest_binlog
.PHONY: get_meta
## get_meta : Build get_meta binary
get_meta: bin
$(V)go build -o bin/get_meta ./cmd/get_meta
.PHONY: snapshot_op
## snapshot_op : Build snapshot_op binary
snapshot_op: bin
$(V)go build -o bin/snapshot_op ./cmd/snapshot_op
.PHONY: get_master_token
## get_master_token : Build get_master_token binary
get_master_token: bin
$(V)go build -o bin/get_master_token ./cmd/get_master_token
.PHONY: spec_checker
## spec_checker : Build spec_checker binary
spec_checker: bin
$(V)go build -o bin/spec_checker ./cmd/spec_checker
.PHONY: get_lag
## get_lag : Build get_lag binary
get_lag: bin
$(V)go build -o bin/get_lag ./cmd/get_lag
.PHONY: rows_parse
## rows_parse : Build rows_parse binary
rows_parse: bin
$(V)go build -o bin/rows_parse ./cmd/rows_parse
.PHONY: thrift_get_meta
## thrift_get_meta : Build thrift_get_meta binary
thrift_get_meta: bin
$(V)go build -o bin/thrift_get_meta ./cmd/thrift_get_meta
.PHONY: metrics
## metrics : Build metrics binary
metrics: bin
$(V)go build -o bin/metrics ./cmd/metrics
.PHONY: todos
## todos : Print all todos
todos:
$(V)grep -rnw . -e "TODO" | grep -v '^./pkg/rpc/thrift' | grep -v '^./.git'
.PHONY: tarball
## tarball : Archive files and release ccr-syncer-$(version)-$(platform).tar.xz
tarball: default
$(V)mkdir -p tarball/ccr-syncer-$(tarball_suffix)/{bin,db,doc,log}
$(V)cp CHANGELOG.md README.md LICENSE tarball/ccr-syncer-$(tarball_suffix)/
$(V)cp bin/ccr_syncer tarball/ccr-syncer-$(tarball_suffix)/bin/
$(V)cp shell/{enable_db_binlog.sh,start_syncer.sh,stop_syncer.sh} tarball/ccr-syncer-$(tarball_suffix)/bin/
$(V)cp -r doc/* tarball/ccr-syncer-$(tarball_suffix)/doc/
$(V)cd tarball/ && tar cfJ ccr-syncer-$(tarball_suffix).tar.xz ccr-syncer-$(tarball_suffix)
$(V)echo archive: tarball/ccr-syncer-$(tarball_suffix).tar.xz