forked from RedisBloom/RedisBloom
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
356 lines (254 loc) · 9.44 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
ROOT=.
include $(ROOT)/deps/readies/mk/main
MK_ALL_TARGETS=bindirs deps build
#----------------------------------------------------------------------------------------------
# export T_DIGEST_C_BINDIR=$(ROOT)/bin/$(FULL_VARIANT.release)/t-digest-c
export T_DIGEST_C_BINDIR=$(ROOT)/bin/$(FULL_VARIANT)/t-digest-c
include $(ROOT)/build/t-digest-c/Makefile.defs
#----------------------------------------------------------------------------------------------
define HELPTEXT
make setup # install packages required for build
make fetch # download and prepare dependant modules
make build
DEBUG=1 # build debug variant
VARIANT=name # use a build variant 'name'
PROFILE=1 # enable profiling compile flags (and debug symbols) for release type
# You can consider this as build type release with debug symbols and -fno-omit-frame-pointer
DEPS=1 # also build dependant modules
COV=1 # perform coverage analysis (implies debug build)
make clean # remove binary files
ALL=1 # remove binary directories
DEPS=1 # also clean dependant modules
make deps # build dependant modules
make all # build all libraries and packages
make run # run redis-server with module
make test # run all tests
make unit-tests # run unit tests
make flow-tests # run tests
TEST=name # run test matching 'name'
TEST_ARGS="..." # RLTest arguments
QUICK=1 # shortcut for GEN=1 AOF=0 SLAVES=0 OSS_CLUSTER=0
GEN=1 # run general tests on a standalone Redis topology
AOF=1 # run AOF persistency tests on a standalone Redis topology
SLAVES=1 # run replication tests on standalone Redis topology
OSS_CLUSTER=1 # run general tests on an OSS Cluster topology
SHARDS=num # run OSS cluster with `num` shards (default: 3)
RLEC=1 # flow tests on RLEC
COV=1 # perform coverage analysis
VALGRIND|VG=1 # run specified tests with Valgrind
EXT=1 # run tests with existing redis-server running
make pack # build packages (ramp & dependencies)
make upload-artifacts # copy snapshot packages to S3
OSNICK=nick # copy snapshots for specific OSNICK
make upload-release # copy release packages to S3
common options for upload operations:
STAGING=1 # copy to staging lab area (for validation)
FORCE=1 # allow operation outside CI environment
VERBOSE=1 # show more details
NOP=1 # do not copy, just print commands
make coverage # perform coverage analysis
make show-cov # show coverage analysis results (implies COV=1)
make upload-cov # upload coverage analysis results to codecov.io (implies COV=1)
make docker # build for specific Linux distribution
OSNICK=nick # Linux distribution to build for
REDIS_VER=ver # use Redis version `ver`
TEST=1 # test aftar build
PACK=1 # create packages
ARTIFACTS=1 # copy artifacts from docker image
PUBLISH=1 # publish (i.e. docker push) after build
make static-analysis # Perform static analysis via fbinter
make benchmarks # run all benchmarks
BENCHMARK=file # run benchmark specified by `file`
BENCH_ARGS="..." # redisbench_admin extra arguments
endef
#----------------------------------------------------------------------------------------------
MK_CUSTOM_CLEAN=1
BINDIR=$(BINROOT)
SRCDIR=.
#----------------------------------------------------------------------------------------------
TARGET=$(BINROOT)/redisbloom.so
CC_C_STD=gnu99
CC_COMMON_H=$(SRCDIR)/src/common.h
define CC_DEFS +=
_GNU_SOURCE
REDIS_MODULE_TARGET
REDISMODULE_SDK_RLEC
endef
define CC_INCLUDES +=
.
src
$(ROOT)/deps/RedisModulesSDK
$(ROOT)/deps
$(ROOT)/deps/murmur2
$(ROOT)/deps/t-digest-c/src
endef
LD_LIBS += $(T_DIGEST_C)
ifeq ($(VG),1)
CC_DEFS += _VALGRIND
endif
ifeq ($(PROFILE),1)
SO_LD_FLAGS += -flto
endif
ifneq ($(DEBUG),1)
SO_LD_FLAGS += -flto
endif
_SOURCES=\
deps/bloom/bloom.c \
deps/murmur2/MurmurHash2.c \
deps/rmutil/util.c \
src/rebloom.c \
src/sb.c \
src/cf.c \
src/rm_topk.c \
src/rm_tdigest.c \
src/topk.c \
src/rm_cms.c \
src/cms.c
ifeq ($(DEBUG),1)
_SOURCES += deps/readies/cetara/diag/gdb.c
endif
SOURCES=$(addprefix $(SRCDIR)/,$(_SOURCES))
HEADERS=$(sort $(wildcard src/*.h $(patsubst %.c,%.h,$(SOURCES))))
OBJECTS=$(patsubst $(SRCDIR)/%.c,$(BINDIR)/%.o,$(SOURCES))
CC_DEPS = $(patsubst $(SRCDIR)/%.c, $(BINDIR)/%.d, $(SOURCES) $(TEST_SOURCES))
include $(MK)/defs
#----------------------------------------------------------------------------------------------
MISSING_DEPS:=
ifeq ($(wildcard $(T_DIGEST_C)),)
MISSING_DEPS += $(T_DIGEST_C)
endif
ifneq ($(MISSING_DEPS),)
DEPS=1
endif
DEPENDENCIES=t-digest-c
ifneq ($(filter all deps $(DEPENDENCIES) pack,$(MAKECMDGOALS)),)
DEPS=1
endif
.PHONY: deps $(DEPENDENCIES)
#----------------------------------------------------------------------------------------------
.PHONY: all deps clean lint format pack run tests unit-tests flow-tests docker bindirs
all: bindirs $(TARGET)
include $(MK)/rules
#----------------------------------------------------------------------------------------------
ifeq ($(DEPS),1)
.PHONY: t-digest-c
deps: $(T_DIGEST_C)
t-digest-c: $(T_DIGEST_C)
$(T_DIGEST_C):
@echo Building $@ ...
$(SHOW)$(MAKE) --no-print-directory -C $(ROOT)/build/t-digest-c
#----------------------------------------------------------------------------------------------
else
deps: ;
endif # DEPS
#----------------------------------------------------------------------------------------------
clean:
ifeq ($(ALL),1)
-$(SHOW)rm -rf $(BINDIR) $(TARGET)
else
-$(SHOW)[ -e $(BINDIR) ] && find $(BINDIR) -name '*.[oadh]' -type f -delete
-$(SHOW)rm -f $(TARGET)
endif
ifdef ($(DEPS),1)
-$(SHOW)$(MAKE) --no-print-directory -C $(ROOT)/build/t-digest-c clean
endif
-include $(CC_DEPS)
$(BINDIR)/%.o: $(SRCDIR)/%.c
@echo Compiling $<...
$(SHOW)$(CC) $(CC_FLAGS) -c $< -o $@
$(TARGET): $(BIN_DIRS) $(MISSING_DEPS) $(OBJECTS)
@echo Linking $@...
$(SHOW)$(CC) $(SO_LD_FLAGS) $(LD_FLAGS) -o $@ $(OBJECTS) $(LD_LIBS)
#----------------------------------------------------------------------------------------------
NO_LINT_PATTERNS=./deps/
LINT_SOURCES=$(call filter-out2,$(NO_LINT_PATTERNS),$(SOURCES) $(HEADERS))
lint:
$(SHOW)clang-format -Werror -n $(LINT_SOURCES)
format:
$(SHOW)clang-format -i $(LINT_SOURCES)
#----------------------------------------------------------------------------------------------
run: $(TARGET)
$(SHOW)redis-server --loadmodule $(realpath $(TARGET))
#----------------------------------------------------------------------------------------------
test: unit-tests flow-tests
#----------------------------------------------------------------------------------------------
unit-tests: $(TARGET)
@echo Running unit tests...
$(SHOW)$(MAKE) -C tests/unit build test
#----------------------------------------------------------------------------------------------
ifeq ($(QUICK),1)
export GEN=1
export SLAVES=0
export AOF=0
export OSS_CLUSTER=0
else
export GEN ?= 1
export SLAVES ?= 1
export AOF ?= 1
export OSS_CLUSTER ?= 1
endif
ifneq ($(RLEC),1)
flow-tests: #$(TARGET)
$(SHOW)\
MODULE=$(realpath $(TARGET)) \
GEN=$(GEN) AOF=$(AOF) SLAVES=$(SLAVES) OSS_CLUSTER=$(OSS_CLUSTER) \
VALGRIND=$(VALGRIND) \
TEST=$(TEST) \
$(ROOT)/tests/flow/tests.sh
else # RLEC
flow-tests: #$(TARGET)
$(SHOW)RLEC=1 $(ROOT)/tests/flow/tests.sh
endif # RLEC
#----------------------------------------------------------------------------------------------
ifneq ($(REMOTE),1)
BENCHMARK_ARGS=run-local
else
BENCHMARK_ARGS=run-remote
endif
BENCHMARK_ARGS += \
--module_path $(realpath $(TARGET)) \
--required-module bf \
--dso $(realpath $(TARGET))
ifneq ($(BENCHMARK),)
BENCHMARK_ARGS += --test $(BENCHMARK)
endif
ifneq ($(BENCH_ARGS),)
BENCHMARK_ARGS += $(BENCH_ARGS)
endif
benchmark: $(TARGET)
$(SHOW)set -e; cd $(ROOT)/tests/benchmarks; redisbench-admin $(BENCHMARK_ARGS)
.PHONY: benchmark
#----------------------------------------------------------------------------------------------
pack: $(TARGET)
@echo Creating packages...
$(SHOW)MODULE=$(realpath $(TARGET)) BINDIR=$(BINDIR) $(ROOT)/sbin/pack.sh
upload-release:
$(SHOW)RELEASE=1 ./sbin/upload-artifacts
upload-artifacts:
$(SHOW)SNAPSHOT=1 ./sbin/upload-artifacts
.PHONY: pack upload-artifacts upload-release
#----------------------------------------------------------------------------------------------
INFER=infer
INFER_DOCKER=redisbench/infer-linux64:1.0.0
static-analysis: #$(TARGET)
ifeq ($(DOCKER),1)
$(SHOW)docker run -v $(ROOT)/:/RedisBloom/ --user "$(username):$(usergroup)" $(INFER_DOCKER) \
bash -c "cd RedisBloom && CC=clang infer run --fail-on-issue --biabduction --skip-analysis-in-path -- make"
else
$(SHOW)CC=clang $(INFER) run --fail-on-issue --biabduction --skip-analysis-in-path -- $(MAKE) VARIANT=infer
endif
#----------------------------------------------------------------------------------------------
coverage:
$(SHOW)$(MAKE) build COV=1
$(SHOW)$(COVERAGE_RESET)
$(SHOW)$(MAKE) test COV=1
$(SHOW)$(COVERAGE_COLLECT_REPORT)
.PHONY: coverage
#----------------------------------------------------------------------------------------------
docker:
$(SHOW)$(MAKE) -C build/docker
ifeq ($(PUBLISH),1)
$(SHOW)make -C build/docker publish
endif
.PHONY: docker
#----------------------------------------------------------------------------------------------