forked from RedisJSON/RedisJSON
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
229 lines (163 loc) · 5.33 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
ROOT=.
MK.pyver:=3
ifeq ($(wildcard $(ROOT)/deps/readies/mk),)
$(error Submodules not present. Please run 'git submodule update --init --recursive')
endif
include $(ROOT)/deps/readies/mk/main
ifneq ($(SAN),)
override DEBUG:=1
ifeq ($(SAN),mem)
else ifeq ($(SAN),memory)
else ifeq ($(SAN),addr)
else ifeq ($(SAN),address)
else ifeq ($(SAN),leak)
else ifeq ($(SAN),thread)
else
$(error SAN=mem|addr|leak|thread)
endif
endif
#----------------------------------------------------------------------------------------------
define HELP
make setup # install prerequisites
make build
DEBUG=1 # build debug variant
SAN=type # build with LLVM sanitizer (type=address|memory|leak|thread)
VALGRIND|VG=1 # build for testing with Valgrind
make clean # remove binary files
ALL=1 # remove binary directories
make all # build all libraries and packages
make pytest # run tests
TEST=name # run test matching 'name'
TEST_ARGS="..." # RLTest arguments
GEN=0|1 # run general tests on a standalone Redis topology
AOF=0|1 # run AOF persistency tests on a standalone Redis topology
SLAVES=0|1 # run replication tests on standalone Redis topology
CLUSTER=0|1 # run general tests on a OSS Redis Cluster topology
VALGRIND|VG=1 # run specified tests with Valgrind
make pack # build package (RAMP file)
make docker
make docker_push
make platform # 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 builddocs
make localdocs
make deploydocs
make nightly # set rust default to nightly
make stable # set rust default to stable
endef
#----------------------------------------------------------------------------------------------
MK_CUSTOM_CLEAN=1
BINDIR=$(BINROOT)
include $(MK)/defs
include $(MK)/rules
#----------------------------------------------------------------------------------------------
MODULE_NAME=rejson.so
RUST_TARGET:=$(shell eval $$(rustc --print cfg | grep =); echo $$target_arch-$$target_vendor-$$target_os-$$target_env)
CARGO_TOOLCHAIN=
CARGO_FLAGS=
ifeq ($(DEBUG),1)
ifeq ($(SAN),)
TARGET_DIR=target/debug
else
TARGET_DIR=target/$(RUST_TARGET)/debug
CARGO_TOOLCHAIN = +nightly
CARGO_FLAGS += -Zbuild-std
endif
else
CARGO_FLAGS += --release
TARGET_DIR=target/release
endif
ifeq ($(PROFILE),1)
RUSTFLAGS += " -g -C force-frame-pointers=yes"
endif
TARGET=$(TARGET_DIR)/$(MODULE_NAME)
#----------------------------------------------------------------------------------------------
all: build
.PHONY: all
#----------------------------------------------------------------------------------------------
setup:
./deps/readies/bin/getpy3
./system-setup.py
.PHONY: setup
#----------------------------------------------------------------------------------------------
lint:
cargo fmt -- --check
.PHONY: lint
#----------------------------------------------------------------------------------------------
RUST_SOEXT.linux=so
RUST_SOEXT.freebsd=so
RUST_SOEXT.macos=dylib
build:
ifeq ($(SAN),)
export RUSTFLAGS=$(RUSTFLAGS) ;\
cargo build --all --all-targets $(CARGO_FLAGS)
else
export RUSTFLAGS=-Zsanitizer=$(SAN) ;\
export RUSTDOCFLAGS=-Zsanitizer=$(SAN) ;\
cargo $(CARGO_TOOLCHAIN) build --target $(RUST_TARGET) $(CARGO_FLAGS)
endif
cp $(TARGET_DIR)/librejson.$(RUST_SOEXT.$(OS)) $(TARGET)
clean:
ifneq ($(ALL),1)
cargo clean
else
rm -rf target
endif
.PHONY: build clean
#----------------------------------------------------------------------------------------------
test: pytest
pytest:
MODULE=$(abspath $(TARGET)) ./tests/pytest/tests.sh
cargo_test:
cargo $(CARGO_TOOLCHAIN) test --features test --all
.PHONY: pytest cargo_test
#----------------------------------------------------------------------------------------------
ifneq ($(REMOTE),)
BENCHMARK_ARGS = run-remote
else
BENCHMARK_ARGS = run-local
endif
BENCHMARK_ARGS += --module_path $(realpath $(TARGET)) --required-module ReJSON
ifneq ($(BENCHMARK),)
BENCHMARK_ARGS += --test $(BENCHMARK)
endif
bench benchmark: $(TARGET)
cd ./tests/benchmarks ;\
redisbench-admin $(BENCHMARK_ARGS)
.PHONY: bench benchmark
#----------------------------------------------------------------------------------------------
pack:
./sbin/pack.sh
.PHONY: pack
#----------------------------------------------------------------------------------------------
docker:
@make -C build/platforms build
docker_push:
@make -C build/platforms publish
.PHONY: docker docker_push
#----------------------------------------------------------------------------------------------
platform:
@make -C build/platforms build
ifeq ($(PUBLISH),1)
@make -C build/platforms publish
endif
#----------------------------------------------------------------------------------------------
builddocs:
mkdocs build
localdocs: builddocs
mkdocs serve
deploydocs: builddocs
mkdocs gh-deploy
.PHONY: builddocs localdocs deploydocs
#----------------------------------------------------------------------------------------------
nightly:
rustup default nightly
rustup component add rust-src
stable:
rustup default stable
.PHONY: nightly stable