/
Makefile
275 lines (216 loc) · 6.71 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
.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
export CMAKE_BUILD_PARALLEL_LEVEL=$(NUM_THREADS)
ifeq ($(OS),Windows_NT)
GEN ?= ninja
SHELL := cmd.exe
.SHELLFLAGS := /c
endif
ifeq ($(GEN),ninja)
CMAKE_FLAGS += -G "Ninja"
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 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
# 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;postgres" \
-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;postgres" \
-DBUILD_JAVA=TRUE \
-DBUILD_NODEJS=TRUE \
-DBUILD_PYTHON=TRUE \
-DBUILD_SHELL=TRUE \
-DBUILD_TESTS=TRUE \
)
# Main tests
test:
$(call run-cmake-relwithdebinfo, -DBUILD_TESTS=TRUE -DENABLE_BACKTRACES=TRUE)
ctest --test-dir build/relwithdebinfo/test --output-on-failure -j ${TEST_JOBS}
lcov:
$(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)
rust:
ifeq ($(OS),Windows_NT)
set CFLAGS=/MDd
set CXXFLAGS=/MDd /std:c++20
set CARGO_BUILD_JOBS=$(NUM_THREADS)
else
export CARGO_BUILD_JOBS=$(NUM_THREADS)
endif
cd tools/rust_api && cargo build --all-features
# Language API tests
javatest: java
cmake -E make_directory tools/java_api/build/test
ifeq ($(OS),Windows_NT)
cd tools/java_api &&\
javac -d build/test -cp ".;build/kuzu_java.jar;third_party/junit-platform-console-standalone-1.9.3.jar" src/test/java/com/kuzudb/test/*.java &&\
java -jar third_party/junit-platform-console-standalone-1.9.3.jar -cp ".;build/kuzu_java.jar;build/test/" --scan-classpath --include-package=com.kuzudb.java_test --details=verbose
else
cd tools/java_api &&\
javac -d build/test -cp ".:build/kuzu_java.jar:third_party/junit-platform-console-standalone-1.9.3.jar" src/test/java/com/kuzudb/test/*.java &&\
java -jar third_party/junit-platform-console-standalone-1.9.3.jar -cp ".:build/kuzu_java.jar:build/test/" --scan-classpath --include-package=com.kuzudb.java_test --details=verbose
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: rust
cd tools/rust_api && cargo test --locked --all-features -- --test-threads=1
# Other misc build targets
benchmark:
$(call run-cmake-release, -DBUILD_BENCHMARK=TRUE)
example:
$(call run-cmake-release, -DBUILD_EXAMPLES=TRUE)
extension-test:
$(call run-cmake-relwithdebinfo, \
-DBUILD_EXTENSIONS="httpfs;duckdb;postgres" \
-DBUILD_EXTENSION_TESTS=TRUE \
-DENABLE_ADDRESS_SANITIZER=TRUE \
-DENABLE_BACKTRACES=TRUE \
)
ctest --test-dir build/relwithdebinfo/extension --output-on-failure -j ${TEST_JOBS}
aws s3 rm s3://kuzu-dataset-us/${RUN_ID}/ --recursive
extension-debug:
$(call run-cmake-debug, \
-DBUILD_EXTENSIONS="httpfs;duckdb;postgres" \
-DBUILD_KUZU=FALSE \
)
extension-release:
$(call run-cmake-release, \
-DBUILD_EXTENSIONS="httpfs;duckdb;postgres" \
-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)|$(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)|$(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
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