-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbinding.gyp
More file actions
375 lines (374 loc) · 13.3 KB
/
Copy pathbinding.gyp
File metadata and controls
375 lines (374 loc) · 13.3 KB
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
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
{
# ASan toggle. Read from the ROCKSDB_ASAN env var at configure time (node -p
# is cross-platform and always present under node-gyp). `-D`/`GYP_DEFINES`
# do not reliably override a target-scoped default under node-gyp's make
# generator, so an explicit env read is used instead. Enable with:
# ROCKSDB_ASAN=1 node-gyp rebuild
'variables': {
"rocksdb_asan%": "<!(node -p \"process.env.ROCKSDB_ASAN==='1'?1:0\")",
# RocksDB link libraries — the core `librocksdb` archive plus the compression
# libs the resolved prebuild actually ships — emitted as `-l` flags / `.lib`
# names (not absolute paths — see configure-rocksdb.mjs for why), resolved
# against the library search dir configured in each target's link settings.
# Older prebuilds ship only zlib; a compression-enabled prebuild adds
# snappy/lz4/zstd/bzip2. Linking exactly what is present lets both build (a
# missing lib errors "no such file"; an unlinked one the prebuild needs
# errors "undefined symbols"). The script also provisions the pinned prebuild
# first. The script path is quoted so a repo checkout under a path with
# spaces still launches it.
'rocksdb_link_libs': ['<!@(node "<(module_root_dir)/scripts/configure-rocksdb.mjs")'],
},
# Node 26's Windows headers (common.gypi) inject Clang ThinLTO options
# (-flto=thin and /opt:lldltojobs=N) into every Release target. The official
# Node Windows build is now compiled with ClangCL + ThinLTO, but this addon
# builds with MSVC (cl.exe / link.exe), which rejects those LLVM-only flags:
# link.exe aborts with "LNK1117: syntax error in option 'opt:lldltojobs=2'".
# Strip them from the MSVC tool invocations via regex exclusion (value- and
# thin/full-agnostic). This lives under msvs_settings, so it is inert on the
# Linux/macOS generators and leaves their LTO behavior untouched.
'target_defaults': {
'configurations': {
'Release': {
'msvs_settings': {
'VCCLCompilerTool': {
'AdditionalOptions/': [['exclude', 'flto'], ['exclude', 'lldltojobs']],
},
'VCLibrarianTool': {
'AdditionalOptions/': [['exclude', 'flto'], ['exclude', 'lldltojobs']],
},
'VCLinkerTool': {
'AdditionalOptions/': [['exclude', 'flto'], ['exclude', 'lldltojobs']],
},
},
},
},
},
'targets': [
{
'target_name': 'rocksdb-js',
'include_dirs': [
'deps/rocksdb/include',
'src/binding',
],
'sources': [
'src/binding/binding.cpp',
'src/binding/core/compression.cpp',
'src/binding/core/debug.cpp',
'src/binding/core/platform.cpp',
'src/binding/core/file_lock.cpp',
'src/binding/core/verification_table.cpp',
'src/binding/napi/event_emitter.cpp',
'src/binding/napi/global_events.cpp',
'src/binding/napi/helpers.cpp',
'src/binding/database/backup.cpp',
'src/binding/database/backup_disk_space.cpp',
'src/binding/database/backup_stream.cpp',
'src/binding/database/backup_transaction_logs.cpp',
'src/binding/database/checkpoint.cpp',
'src/binding/database/database.cpp',
'src/binding/database/database_events.cpp',
'src/binding/database/db_descriptor.cpp',
'src/binding/database/db_handle.cpp',
'src/binding/database/db_registry.cpp',
'src/binding/database/db_settings.cpp',
'src/binding/iterator/db_iterator.cpp',
'src/binding/iterator/db_iterator_handle.cpp',
'src/binding/transaction/transaction_handle.cpp',
'src/binding/transaction/transaction.cpp',
'src/binding/transaction_log/transaction_log.cpp',
'src/binding/transaction_log/transaction_log_file.cpp',
'src/binding/transaction_log/transaction_log_handle.cpp',
'src/binding/transaction_log/transaction_log_recovery.cpp',
'src/binding/transaction_log/transaction_log_store.cpp',
'src/binding/transaction_log/transaction_log_store_registry.cpp',
'src/binding/transaction_log/transaction_log_validation.cpp',
'src/binding/transaction_log/transaction_log_validation_napi.cpp',
],
'defines': [
# Note: node-gyp defaults to NAPI_VERSION=8 (v12.22.0+,
# v14.17.0+, v15.12.0+, 16.0.0 and all later versions)
#
# We can force NAPI_VERSION=9 (v18.17.0+, 20.3.0+, 21.0.0 and
# all later versions) by uncommenting the line below:
# 'NAPI_VERSION=9',
],
'cflags!': [ '-fno-exceptions', '-std=c++17' ],
'cflags_cc!': [ '-fno-exceptions', '-std=c++17' ],
'cflags_cc': [
'-std=c++20',
'-fexceptions'
],
'conditions': [
['OS=="win"', {
'link_settings': {
'libraries': [
'rpcrt4.lib',
'shell32.lib',
'shlwapi.lib'
]
},
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'AdditionalOptions!': ['/Zc:__cplusplus', '-std:c++17'],
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20']
},
'VCLinkerTool': {
'LinkTimeCodeGeneration': 1,
'LinkIncremental': 1
}
}
}],
['OS=="linux" or OS=="mac"', {
'cflags+': ['-fexceptions'],
'cflags_cc+': ['-fexceptions'],
'link_settings': {
# All link libraries (core librocksdb + the compression libs) come
# from configure-rocksdb.mjs as `-l` tokens, not absolute paths,
# resolved against this search dir. The search dir is module-relative
# (not <(module_root_dir)/...) so GYP rebases it to a ../-only path
# under the build dir: an absolute path carrying a spaced
# module_root_dir is emitted unquoted into LDFLAGS/LIBS and the link
# shell splits it, while a ../-relative path has no space to split
# (fixes a checkout under e.g. /tmp/rocks db).
'library_dirs': [
'deps/rocksdb/lib'
],
'libraries': [
'<@(rocksdb_link_libs)'
]
},
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET': '26.0',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++20',
}
}],
# AddressSanitizer instrumentation for diagnosing heap corruption
# in the binding. Enable with `ROCKSDB_ASAN=1 node-gyp rebuild`.
# RocksDB is linked as a non-instrumented prebuilt static lib;
# ASan's global malloc/free interceptors still catch overflows and
# use-after-free in binding-owned allocations. The .node must be
# run with the ASan runtime preloaded (Linux: LD_PRELOAD the
# libasan shared lib; macOS Node deadlocks under injected ASan, so
# use the standalone native-test target there instead).
['rocksdb_asan==1 and (OS=="mac" or OS=="linux")', {
'cflags+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'cflags_cc+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'ldflags+': ['-fsanitize=address'],
'xcode_settings': {
'OTHER_CFLAGS+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'OTHER_CPLUSPLUSFLAGS+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'OTHER_LDFLAGS+': ['-fsanitize=address'],
}
}]
],
'configurations': {
'Release': {
# 'defines': ['DEBUG'],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 0,
'ExceptionHandling': 1,
'AdditionalOptions!': [],
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20']
},
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
'<(module_root_dir)/deps/rocksdb/lib'
],
'AdditionalDependencies': [
'<@(rocksdb_link_libs)'
]
}
}
},
'Debug': {
'cflags_cc+': ['-g', '--coverage'],
'defines': ['DEBUG'],
'ldflags': ['--coverage'],
'msvs_settings': {
'VCCLCompilerTool': {
# 'RuntimeLibrary': 1,
'RuntimeLibrary': 0,
'ExceptionHandling': 1,
'AdditionalOptions!': [],
# 'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20']
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20', '/U_DEBUG']
},
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
# '<(module_root_dir)/deps/rocksdb/debug/lib',
'<(module_root_dir)/deps/rocksdb/lib'
],
'AdditionalDependencies': [
'<@(rocksdb_link_libs)'
]
}
},
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++20',
'OTHER_CFLAGS': ['-g', '--coverage'],
'OTHER_LDFLAGS': ['--coverage']
}
}
}
},
{
'target_name': 'rocksdb-js-native-tests',
'type': 'executable',
'dependencies': ['deps/gtest.gyp:gtest_main'],
'include_dirs': [
'deps/rocksdb/include',
'src/binding',
'deps/googletest/googletest/include',
'deps/googletest/googlemock/include',
],
'sources': [
'src/binding/core/compression.cpp',
'src/binding/core/debug.cpp',
'src/binding/core/platform.cpp',
'src/binding/core/file_lock.cpp',
'src/binding/core/verification_table.cpp',
'src/binding/database/backup_disk_space.cpp',
'src/binding/transaction_log/transaction_log_file.cpp',
'src/binding/transaction_log/transaction_log_recovery.cpp',
'src/binding/transaction_log/transaction_log_validation.cpp',
'test/native/event_emitter_stub.cc',
'test/native/rocksdb_version_test.cc',
'test/native/backup_disk_space_test.cc',
'test/native/compression_test.cc',
'test/native/encoding_test.cc',
'test/native/file_lock_test.cc',
'test/native/json_test.cc',
'test/native/platform_fd_limit_test.cc',
'test/native/transaction_log_madvise_test.cc',
'test/native/transaction_log_mmap_test.cc',
'test/native/transaction_log_recovery_test.cc',
'test/native/transaction_log_validation_test.cc',
'test/native/transaction_log_writev_test.cc',
'test/native/verification_table_test.cc',
],
'defines': [
'ROCKSDB_JS_NATIVE_TESTS',
'ROCKSDB_JS_WRITEV=rocksdb_js_mock_writev',
'ROCKSDB_JS_MADVISE=rocksdb_js_mock_madvise',
],
'cflags!': [ '-fno-exceptions', '-std=c++17' ],
'cflags_cc!': [ '-fno-exceptions', '-std=c++17' ],
'cflags_cc': [
'-std=c++20',
'-fexceptions'
],
'conditions': [
['OS=="win"', {
'link_settings': {
'libraries': [
'rpcrt4.lib',
'shell32.lib',
'shlwapi.lib'
]
},
'msvs_settings': {
'VCCLCompilerTool': {
'ExceptionHandling': 1,
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20']
},
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
'<(module_root_dir)/deps/rocksdb/lib'
],
'AdditionalDependencies': [
'<@(rocksdb_link_libs)'
]
}
}
}],
['OS=="linux" or OS=="mac"', {
'cflags+': ['-fexceptions'],
'cflags_cc+': ['-fexceptions'],
'link_settings': {
# All link libraries (core librocksdb + the compression libs) come
# from configure-rocksdb.mjs as `-l` tokens, not absolute paths,
# resolved against this search dir. The search dir is module-relative
# (not <(module_root_dir)/...) so GYP rebases it to a ../-only path
# under the build dir: an absolute path carrying a spaced
# module_root_dir is emitted unquoted into LDFLAGS/LIBS and the link
# shell splits it, while a ../-relative path has no space to split
# (fixes a checkout under e.g. /tmp/rocks db).
'library_dirs': [
'deps/rocksdb/lib'
],
'libraries': [
'<@(rocksdb_link_libs)'
]
},
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'MACOSX_DEPLOYMENT_TARGET': '26.0',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++20',
}
}],
# ASan for the standalone (no-Node) GoogleTest binary. Unlike the
# .node, this executable runs natively under ASan on macOS, so it
# is the local vehicle for catching corruption in the txn-log /
# recovery / encoding code paths. Enable with ROCKSDB_ASAN=1.
['rocksdb_asan==1 and (OS=="mac" or OS=="linux")', {
'cflags+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'cflags_cc+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'ldflags+': ['-fsanitize=address'],
'xcode_settings': {
'OTHER_CFLAGS+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'OTHER_CPLUSPLUSFLAGS+': ['-fsanitize=address', '-fno-omit-frame-pointer', '-g', '-O1'],
'OTHER_LDFLAGS+': ['-fsanitize=address'],
}
}]
],
'configurations': {
'Release': {
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 0,
'ExceptionHandling': 1,
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20']
},
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
'<(module_root_dir)/deps/rocksdb/lib'
],
'AdditionalDependencies': [
'<@(rocksdb_link_libs)'
]
}
}
},
'Debug': {
'cflags_cc+': ['-g', '--coverage'],
'ldflags': ['--coverage'],
'msvs_settings': {
'VCCLCompilerTool': {
'RuntimeLibrary': 0,
'ExceptionHandling': 1,
'AdditionalOptions': ['/Zc:__cplusplus', '/std:c++20', '/U_DEBUG']
},
'VCLinkerTool': {
'AdditionalLibraryDirectories': [
'<(module_root_dir)/deps/rocksdb/lib'
],
'AdditionalDependencies': [
'<@(rocksdb_link_libs)'
]
}
},
'xcode_settings': {
'GCC_ENABLE_CPP_EXCEPTIONS': 'YES',
'CLANG_CXX_LANGUAGE_STANDARD': 'c++20',
'OTHER_CFLAGS': ['-g', '--coverage'],
'OTHER_LDFLAGS': ['--coverage']
}
}
}
},
]
}