-
Notifications
You must be signed in to change notification settings - Fork 99
/
Makefile
307 lines (243 loc) · 7.62 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
.PHONY: \
release debug all alldebug \
test lcov \
java nodejs python rust \
javatest nodejstest pytest rusttest \
benchmark example \
clangd tidy clangd-diagnostics \
install \
clean-extension clean-python-api clean-java clean \
extension-test shell-test
.ONESHELL:
.SHELLFLAGS = -ec
CLANGD_DIAGNOSTIC_INSTANCES ?= 4
NUM_THREADS ?= 1
PREFIX ?= install
TEST_JOBS ?= 10
EXTENSION_TEST_EXCLUDE_FILTER ?= ""
export CMAKE_BUILD_PARALLEL_LEVEL=$(NUM_THREADS)
ifeq ($(OS),Windows_NT)
GEN ?= Ninja
SHELL := cmd.exe
.SHELLFLAGS := /c
endif
ifdef GEN
CMAKE_FLAGS += -G "$(GEN)"
endif
ifdef ASAN
CMAKE_FLAGS += -DENABLE_ADDRESS_SANITIZER=$(ASAN)
endif
ifdef TSAN
CMAKE_FLAGS += -DENABLE_THREAD_SANITIZER=$(TSAN)
endif
ifdef UBSAN
CMAKE_FLAGS += -DENABLE_UBSAN=$(UBSAN)
endif
ifdef ENABLE_DESER_DEBUG
CMAKE_FLAGS += -DENABLE_DESER_DEBUG=$(ENABLE_DESER_DEBUG)
endif
ifdef RUNTIME_CHECKS
CMAKE_FLAGS += -DENABLE_RUNTIME_CHECKS=$(RUNTIME_CHECKS)
endif
ifdef WERROR
CMAKE_FLAGS += -DENABLE_WERROR=$(WERROR)
endif
ifdef LTO
CMAKE_FLAGS += -DENABLE_LTO=$(LTO)
endif
ifdef SKIP_SINGLE_FILE_HEADER
CMAKE_FLAGS += -DBUILD_SINGLE_FILE_HEADER=FALSE
endif
ifdef PAGE_SIZE_LOG2
CMAKE_FLAGS += -DPAGE_SIZE_LOG2=$(PAGE_SIZE_LOG2)
endif
ifdef VECTOR_CAPACITY_LOG2
CMAKE_FLAGS += -DVECTOR_CAPACITY_LOG2=$(VECTOR_CAPACITY_LOG2)
endif
ifdef SINGLE_THREADED
CMAKE_FLAGS += -DSINGLE_THREADED=$(SINGLE_THREADED)
endif
# Must be first in the Makefile so that it is the default target.
release:
$(call run-cmake-release,)
relwithdebinfo:
$(call run-cmake-relwithdebinfo,)
debug:
$(call run-cmake-debug,)
allconfig:
$(call config-cmake-release, \
-DBUILD_BENCHMARK=TRUE \
-DBUILD_EXAMPLES=TRUE \
-DBUILD_EXTENSIONS="httpfs;duckdb;json;postgres;sqlite;fts" \
-DBUILD_JAVA=TRUE \
-DBUILD_NODEJS=TRUE \
-DBUILD_PYTHON=TRUE \
-DBUILD_SHELL=TRUE \
-DBUILD_TESTS=TRUE \
)
all: allconfig
$(call build-cmake-release)
alldebug:
$(call run-cmake-debug, \
-DBUILD_BENCHMARK=TRUE \
-DBUILD_EXAMPLES=TRUE \
-DBUILD_EXTENSIONS="httpfs;duckdb;json;postgres;sqlite;fts" \
-DBUILD_JAVA=TRUE \
-DBUILD_NODEJS=TRUE \
-DBUILD_PYTHON=TRUE \
-DBUILD_SHELL=TRUE \
-DBUILD_TESTS=TRUE \
)
# Main tests
test:
python3 dataset/ldbc-1/download_data.py
$(call run-cmake-relwithdebinfo, -DBUILD_TESTS=TRUE -DENABLE_BACKTRACES=TRUE)
ctest --test-dir build/relwithdebinfo/test --output-on-failure -j ${TEST_JOBS}
lcov:
python3 dataset/ldbc-1/download_data.py
$(call run-cmake-release, -DBUILD_TESTS=TRUE -DBUILD_LCOV=TRUE)
ctest --test-dir build/release/test --output-on-failure -j ${TEST_JOBS}
# Language APIs
# Required for clangd-related tools.
java_native_header:
cmake --build build/release --target kuzu_java
java:
$(call run-cmake-release, -DBUILD_JAVA=TRUE)
nodejs:
$(call run-cmake-release, -DBUILD_NODEJS=TRUE)
python:
$(call run-cmake-release, -DBUILD_PYTHON=TRUE)
python-debug:
$(call run-cmake-debug, -DBUILD_PYTHON=TRUE)
# Language API tests
javatest:
ifeq ($(OS),Windows_NT)
cd tools/java_api &&\
gradlew.bat test -i
else
cd tools/java_api &&\
./gradlew test -i
endif
nodejstest: nodejs
cd tools/nodejs_api && npm test
pytest: python
cmake -E env PYTHONPATH=tools/python_api/build python3 -m pytest -vv tools/python_api/test
pytest-debug: python-debug
cmake -E env PYTHONPATH=tools/python_api/build python3 -m pytest -vv tools/python_api/test
rusttest:
ifeq ($(OS),Windows_NT)
set CARGO_BUILD_JOBS=$(NUM_THREADS)
else
export CARGO_BUILD_JOBS=$(NUM_THREADS)
endif
export CARGO_BUILD_JOBS=$(NUM_THREADS)
# Note that the number of test threads has a hard limit (unlike with ctest)
# since they are all run in the same process and most tests create a database
# (requiring mmapping 8TB of virtual memory). This quickly exhausts the process' virtual memory.
cd tools/rust_api && cargo test --profile=relwithdebinfo --locked --all-features -- --test-threads=12
wasmtest:
mkdir -p build/wasm && cd build/wasm &&\
emcmake cmake $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=Release -DBUILD_WASM=TRUE -DBUILD_BENCHMARK=FALSE -DBUILD_TESTS=TRUE -DBUILD_SHELL=FALSE ../.. && \
cmake --build . --config Release -j $(NUM_THREADS) &&\
cd ../.. && ctest --test-dir build/wasm/test/ --output-on-failure -j ${TEST_JOBS} --timeout 600
# Other misc build targets
benchmark:
$(call run-cmake-release, -DBUILD_BENCHMARK=TRUE)
example:
$(call run-cmake-release, -DBUILD_EXAMPLES=TRUE)
extension-test-build:
$(call run-cmake-release, \
-DBUILD_EXTENSIONS="httpfs;duckdb;json;postgres;sqlite;fts" \
-DBUILD_EXTENSION_TESTS=TRUE \
)
extension-json-test-build:
$(call run-cmake-release, \
-DBUILD_EXTENSIONS="json" \
-DBUILD_EXTENSION_TESTS=TRUE \
-DENABLE_ADDRESS_SANITIZER=TRUE \
)
extension-test: extension-test-build
ctest --test-dir build/release/extension --output-on-failure -j ${TEST_JOBS} --exclude-regex "${EXTENSION_TEST_EXCLUDE_FILTER}"
aws s3 rm s3://kuzu-dataset-us/${RUN_ID}/ --recursive
extension-json-test: extension-json-test-build
ctest --test-dir build/release/extension --output-on-failure -j ${TEST_JOBS} -R json
aws s3 rm s3://kuzu-dataset-us/${RUN_ID}/ --recursive
extension-debug:
$(call run-cmake-debug, \
-DBUILD_EXTENSIONS="httpfs;duckdb;json;postgres;sqlite;fts" \
-DBUILD_KUZU=FALSE \
)
extension-release:
$(call run-cmake-release, \
-DBUILD_EXTENSIONS="httpfs;duckdb;json;postgres;sqlite;fts" \
-DBUILD_KUZU=FALSE \
)
shell-test:
$(call run-cmake-relwithdebinfo, \
-DBUILD_SHELL=TRUE \
)
cd tools/shell/test && python3 -m pytest -v
# Clang-related tools and checks
# Must build the java native header to avoid missing includes. Pipe character
# `|` ensures these targets build in this order, even in the presence of
# parallelism.
tidy: | allconfig java_native_header
run-clang-tidy -p build/release -quiet -j $(NUM_THREADS) \
"^$(realpath src)|$(realpath extension)/(?!fts/third_party/snowball/)|$(realpath tools)/(?!shell/linenoise.cpp)"
tidy-analyzer: | allconfig java_native_header
run-clang-tidy -config-file .clang-tidy-analyzer -p build/release -quiet -j $(NUM_THREADS) \
"^$(realpath src)|$(realpath extension)/(?!fts/third_party/snowball/)|$(realpath tools)/(?!shell/linenoise.cpp)"
clangd-diagnostics: | allconfig java_native_header
find src -name *.h -or -name *.cpp | xargs \
./scripts/get-clangd-diagnostics.py --compile-commands-dir build/release \
-j $(NUM_THREADS) --instances $(CLANGD_DIAGNOSTIC_INSTANCES)
# Installation
install:
cmake --install build/release --prefix $(PREFIX)
# Cleaning
clean-extension:
cmake -E rm -rf extension/httpfs/build
cmake -E rm -rf extension/duckdb/build
cmake -E rm -rf extension/postgres/build
cmake -E rm -rf extension/sqlite/build
cmake -E rm -rf extension/fts/build
clean-python-api:
cmake -E rm -rf tools/python_api/build
clean-java:
cmake -E rm -rf tools/java_api/build
clean: clean-extension clean-python-api clean-java
cmake -E rm -rf build
# Utils
define config-cmake
cmake -B build/$1 $(CMAKE_FLAGS) -DCMAKE_BUILD_TYPE=$2 $3 .
endef
define build-cmake
cmake --build build/$1 --config $2
endef
define run-cmake
$(call config-cmake,$1,$2,$3)
$(call build-cmake,$1,$2)
endef
define run-cmake-debug
$(call run-cmake,debug,Debug,$1)
endef
define build-cmake-release
$(call build-cmake,release,Release,$1)
endef
define build-cmake-relwithdebinfo
$(call build-cmake,relwithdebinfo,RelWithDebInfo,$1)
endef
define config-cmake-release
$(call config-cmake,release,Release,$1)
endef
define config-cmake-relwithdebinfo
$(call config-cmake,relwithdebinfo,RelWithDebInfo,$1)
endef
define run-cmake-release
$(call config-cmake-release,$1)
$(call build-cmake-release,$1)
endef
define run-cmake-relwithdebinfo
$(call config-cmake-relwithdebinfo,$1)
$(call build-cmake-relwithdebinfo,$1)
endef