-
Notifications
You must be signed in to change notification settings - Fork 29.8k
/
unofficial.gni
394 lines (363 loc) Β· 10.9 KB
/
unofficial.gni
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
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
# This file is used by GN for building, which is NOT the build system used for
# building official binaries.
# Please take a look at node.gyp if you are making changes to build system.
import("node.gni")
import("$node_v8_path/gni/snapshot_toolchain.gni")
import("$node_v8_path/gni/v8.gni")
# The actual configurations are put inside a template in unofficial.gni to
# prevent accidental edits from contributors.
template("node_gn_build") {
config("node_features") {
defines = []
if (is_component_build) {
defines += [
"USING_UV_SHARED",
"USING_V8_SHARED",
]
}
if (node_use_openssl) {
defines += [ "HAVE_OPENSSL=1" ]
} else {
defines += [ "HAVE_OPENSSL=0" ]
}
if (node_use_amaro) {
defines += [ "HAVE_AMARO=1" ]
} else {
defines += [ "HAVE_AMARO=0" ]
}
if (node_use_v8_platform) {
defines += [ "NODE_USE_V8_PLATFORM=1" ]
} else {
defines += [ "NODE_USE_V8_PLATFORM=0" ]
}
if (node_enable_inspector) {
defines += [ "HAVE_INSPECTOR=1" ]
} else {
defines += [ "HAVE_INSPECTOR=0" ]
}
if (node_use_node_code_cache) {
defines += [ "NODE_USE_NODE_CODE_CACHE=1"]
}
if (v8_enable_i18n_support) {
defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
}
}
config("node_external_config") {
include_dirs = [
target_gen_dir,
"src",
]
defines = [
"NODE_WANT_INTERNALS=1",
"NODE_EMBEDDER_MODULE_VERSION=$node_module_version",
]
configs = [
":node_features",
"$node_v8_path:external_config",
]
}
config("node_internal_config") {
visibility = [
":*",
"src/inspector:*",
]
configs = [ ":node_external_config" ]
libs = []
cflags = [ "-Wno-microsoft-include" ]
cflags_cc = [
"-Wno-deprecated-declarations",
"-Wno-extra-semi",
"-Wno-implicit-fallthrough",
"-Wno-macro-redefined",
"-Wno-missing-braces",
"-Wno-return-type",
"-Wno-shadow",
"-Wno-sometimes-uninitialized",
"-Wno-string-plus-int",
"-Wno-string-conversion",
"-Wno-unreachable-code",
"-Wno-unreachable-code-break",
"-Wno-unreachable-code-return",
"-Wno-unused-label",
"-Wno-unused-private-field",
"-Wno-unused-variable",
"-Wno-unused-function",
]
if (current_cpu == "x86") {
node_arch = "ia32"
} else {
node_arch = current_cpu
}
if (target_os == "win") {
node_platform = "win32"
} else if (target_os == "mac") {
node_platform = "darwin"
} else {
node_platform = target_os
}
defines = [
"NODE_ARCH=\"$node_arch\"",
"NODE_PLATFORM=\"$node_platform\"",
"NODE_REPORT"
]
if (is_win) {
defines += [
"NOMINMAX",
"_UNICODE=1",
]
} else {
defines += [ "__POSIX__" ]
}
if (node_tag != "") {
defines += [ "NODE_TAG=\"$node_tag\"" ]
}
if (node_v8_options != "") {
defines += [ "NODE_V8_OPTIONS=\"$node_v8_options\"" ]
}
if (node_release_urlbase != "") {
defines += [ "NODE_RELEASE_URLBASE=\"$node_release_urlbase\"" ]
}
if (node_use_openssl) {
defines += [
"NODE_OPENSSL_SYSTEM_CERT_PATH=\"$node_openssl_system_ca_path\"",
]
}
}
gypi_values = exec_script("./tools/gypi_to_gn.py",
[ rebase_path("node.gyp"),
"--replace=<@(node_builtin_shareable_builtins)=" ],
"scope",
[ "node.gyp" ])
source_set("libnode") {
configs += [ ":node_internal_config" ]
public_configs = [
":node_external_config",
"deps/googletest:googletest_config",
]
public_deps = [
"deps/ada",
"deps/uv",
"deps/simdjson",
"$node_v8_path",
]
deps = [
":run_node_js2c",
"deps/brotli",
"deps/cares",
"deps/histogram",
"deps/llhttp",
"deps/nbytes",
"deps/nghttp2",
"deps/ngtcp2",
"deps/postject",
"deps/simdutf",
"deps/sqlite",
"deps/uvwasi",
"//third_party/zlib",
"$node_v8_path:v8_libplatform",
]
sources = [
"$target_gen_dir/node_javascript.cc",
] + gypi_values.node_sources
if (is_win) {
libs = [ "psapi.lib" ]
}
if (is_mac) {
frameworks = [ "CoreFoundation.framework" ]
}
if (is_posix) {
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
configs += [ "//build/config/gcc:symbol_visibility_default" ]
}
if (v8_enable_i18n_support) {
deps += [ "//third_party/icu" ]
}
if (node_use_openssl) {
deps += [ "deps/ncrypto" ]
public_deps += [ "$node_openssl_path" ]
sources += gypi_values.node_crypto_sources
}
if (node_enable_inspector) {
deps += [
"src/inspector:node_protocol_generated_sources",
"src/inspector:v8_inspector_compress_protocol_json",
]
include_dirs = [
"$target_gen_dir/src",
"$target_gen_dir/src/inspector",
]
node_inspector = exec_script(
"./tools/gypi_to_gn.py",
[ rebase_path("src/inspector/node_inspector.gypi"),
"--replace=<(SHARED_INTERMEDIATE_DIR)=$target_gen_dir" ],
"scope",
[ "src/inspector/node_inspector.gypi" ])
sources += node_inspector.node_inspector_sources +
node_inspector.node_inspector_generated_sources
}
}
executable(target_name) {
forward_variables_from(invoker, "*")
sources = [ "src/node_main.cc" ]
deps = [
":libnode",
"//build/win:default_exe_manifest",
]
if (node_use_node_snapshot) {
sources += [ "$target_gen_dir/node_snapshot.cc" ]
deps += [ ":run_node_mksnapshot" ]
if (is_clang || !is_win) {
cflags_cc = [
"-Wno-c++11-narrowing",
"-Wno-shadow",
]
}
} else {
sources += [ "src/node_snapshot_stub.cc" ]
}
output_name = "node"
if (is_apple) {
# Default optimization on apple adds "-dead_strip" to ldflags, which would
# strip exported V8 and NAPI symbols, has to remove it to make native
# modules work.
# There is almost no performance penalty since we are only removing
# optimization on the node_main.cc.
configs -= [ "//build/config/compiler:default_optimization" ]
}
}
if (node_use_node_snapshot) {
if (current_toolchain == v8_snapshot_toolchain) {
executable("node_mksnapshot") {
configs += [ ":node_internal_config", ":disable_icf" ]
sources = [
"src/node_snapshot_stub.cc",
"tools/snapshot/node_mksnapshot.cc",
]
deps = [ ":libnode" ]
}
# This config disables a link time optimization "ICF", which may merge
# different functions into one if the function signature and body of them are
# identical.
#
# ICF breaks 1:1 mappings of the external references for V8 snapshot, so we
# disable it while taking a V8 snapshot.
config("disable_icf") {
visibility = [ ":*" ] # Only targets in this file can depend on this.
if (is_win) {
ldflags = [ "/OPT:NOICF" ] # link.exe, but also lld-link.exe.
} else if (is_apple && !use_lld) {
ldflags = [ "-Wl,-no_deduplicate" ] # ld64.
} else if (use_gold || use_lld) {
ldflags = [ "-Wl,--icf=none" ]
}
}
}
action("run_node_mksnapshot") {
deps = [ ":node_mksnapshot($v8_snapshot_toolchain)" ]
script = "$node_v8_path/tools/run.py"
sources = []
data = []
mksnapshot_dir = get_label_info(":node_mksnapshot($v8_snapshot_toolchain)",
"root_out_dir")
outputs = [ "$target_gen_dir/node_snapshot.cc" ]
args = [
"./" + rebase_path(mksnapshot_dir + "/node_mksnapshot", root_build_dir),
rebase_path("$target_gen_dir/node_snapshot.cc", root_build_dir),
]
}
}
action("generate_config_gypi") {
deps = [ "$node_v8_path:v8_generate_features_json" ]
script = "tools/generate_config_gypi.py"
outputs = [ "$target_gen_dir/config.gypi" ]
depfile = "$target_gen_dir/$target_name.d"
args = rebase_path(outputs, root_build_dir) + [
"--out-dir", rebase_path(root_build_dir, root_build_dir),
"--dep-file", rebase_path(depfile, root_build_dir),
"--node-gn-path", node_path,
]
}
executable("node_js2c") {
deps = [
"deps/simdutf",
"deps/uv",
]
sources = [
"tools/js2c.cc",
"tools/executable_wrapper.h",
"src/embedded_data.cc",
"src/embedded_data.h",
]
include_dirs = [ "src" ]
}
action("run_node_js2c") {
script = "$node_v8_path/tools/run.py"
deps = [
":node_js2c($host_toolchain)",
":generate_config_gypi",
]
node_deps_files = gypi_values.deps_files + node_builtin_shareable_builtins
node_library_files = exec_script("./tools/search_files.py",
[ rebase_path(".", root_build_dir),
rebase_path("lib", root_build_dir),
"js" ],
"list lines")
inputs = node_library_files +
node_deps_files +
[ "$target_gen_dir/config.gypi" ]
outputs = [ "$target_gen_dir/node_javascript.cc" ]
# Get the path to node_js2c executable of the host toolchain.
if (host_os == "win") {
host_executable_suffix = ".exe"
} else {
host_executable_suffix = ""
}
node_js2c_path =
get_label_info(":node_js2c($host_toolchain)", "root_out_dir") + "/" +
get_label_info(":node_js2c($host_toolchain)", "name") +
host_executable_suffix
args = [ rebase_path(node_js2c_path),
rebase_path("$target_gen_dir/node_javascript.cc"),
"--root", rebase_path("."),
"lib", rebase_path("$target_gen_dir/config.gypi") ] +
node_deps_files
}
executable("node_cctest") {
testonly = true
configs += [ ":node_internal_config" ]
deps = [
":libnode",
"deps/googletest",
"deps/googletest:gtest_main",
"deps/nbytes",
"deps/simdutf",
]
sources = gypi_values.node_cctest_sources
if (node_use_openssl) {
deps += [ "deps/ncrypto" ]
sources += gypi_values.node_cctest_openssl_sources
}
if (node_enable_inspector) {
sources += gypi_values.node_cctest_inspector_sources
}
}
executable("node_embedtest") {
output_name = "embedtest"
testonly = true
deps = [ ":libnode" ]
include_dirs = [ "tools" ]
sources = [
"src/node_snapshot_stub.cc",
"test/embedding/embedtest.cc",
]
}
executable("overlapped_checker") {
output_name = "overlapped-checker"
testonly = true
if (is_win) {
sources = [ "test/overlapped-checker/main_win.c" ]
} else {
sources = [ "test/overlapped-checker/main_unix.c" ]
}
}
}