Skip to content

Commit 93bfd6b

Browse files
authored
build,deps: replace cjs-module-lexer with merve
nodejs/node#61456
1 parent 399bbab commit 93bfd6b

7 files changed

Lines changed: 84 additions & 35 deletions

patches/chromium/build_allow_electron_to_use_exec_script.patch

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ Subject: build: allow electron to use exec_script
66
This is similar to the //build usecase so we're OK adding ourselves here
77

88
diff --git a/.gn b/.gn
9-
index ae58a0b0a64ae1fdb3f9cd8587041d71a121c6b9..0ed56526002b12deb6d29f3dd23a0d74d8e7473c 100644
9+
index ae58a0b0a64ae1fdb3f9cd8587041d71a121c6b9..f9d4e9b015ad266452dfa2a442b432ef31d09a5b 100644
1010
--- a/.gn
1111
+++ b/.gn
12-
@@ -167,4 +167,27 @@ exec_script_allowlist =
12+
@@ -167,4 +167,28 @@ exec_script_allowlist =
1313

1414
"//tools/grit/grit_rule.gni",
1515
"//tools/gritsettings/BUILD.gn",
@@ -25,6 +25,7 @@ index ae58a0b0a64ae1fdb3f9cd8587041d71a121c6b9..0ed56526002b12deb6d29f3dd23a0d74
2525
+ "//third_party/electron_node/deps/googletest/unofficial.gni",
2626
+ "//third_party/electron_node/deps/histogram/unofficial.gni",
2727
+ "//third_party/electron_node/deps/llhttp/unofficial.gni",
28+
+ "//third_party/electron_node/deps/merve/unofficial.gni",
2829
+ "//third_party/electron_node/deps/nbytes/unofficial.gni",
2930
+ "//third_party/electron_node/deps/ncrypto/unofficial.gni",
3031
+ "//third_party/electron_node/deps/nghttp2/unofficial.gni",

patches/node/build_add_gn_build_files.patch

Lines changed: 66 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,54 @@ index f31d460038db2fa2fa4c47d62be3100da959978f..209f23b04663113e4f6b3c3242c0544c
2323
# We set v8_enable_pointer_compression_shared_cage to 0 always, even when
2424
# pointer compression is enabled so that we don't accidentally enable shared
2525
# cage mode when pointer compression is on.
26+
diff --git a/deps/merve/BUILD.gn b/deps/merve/BUILD.gn
27+
new file mode 100644
28+
index 0000000000000000000000000000000000000000..7bb318f8835dba6f4a6f211d8534bb6923958747
29+
--- /dev/null
30+
+++ b/deps/merve/BUILD.gn
31+
@@ -0,0 +1,14 @@
32+
+##############################################################################
33+
+# #
34+
+# DO NOT EDIT THIS FILE! #
35+
+# #
36+
+##############################################################################
37+
+
38+
+# This file is used by GN for building, which is NOT the build system used for
39+
+# building official binaries.
40+
+# Please modify the gyp files if you are making changes to build system.
41+
+
42+
+import("unofficial.gni")
43+
+
44+
+merve_gn_build("merve") {
45+
+}
46+
diff --git a/deps/merve/unofficial.gni b/deps/merve/unofficial.gni
47+
new file mode 100644
48+
index 0000000000000000000000000000000000000000..dfb508d1d22f84accb146620ed07d89715b367e6
49+
--- /dev/null
50+
+++ b/deps/merve/unofficial.gni
51+
@@ -0,0 +1,20 @@
52+
+# This file is used by GN for building, which is NOT the build system used for
53+
+# building official binaries.
54+
+# Please edit the gyp files if you are making changes to build system.
55+
+
56+
+# The actual configurations are put inside a template in unofficial.gni to
57+
+# prevent accidental edits from contributors.
58+
+template("merve_gn_build") {
59+
+ config("merve_config") {
60+
+ include_dirs = [ "." ]
61+
+ }
62+
+ gypi_values = exec_script("../../tools/gypi_to_gn.py",
63+
+ [ rebase_path("merve.gyp") ],
64+
+ "scope",
65+
+ [ "merve.gyp" ])
66+
+ source_set(target_name) {
67+
+ forward_variables_from(invoker, "*")
68+
+ public_configs = [ ":merve_config" ]
69+
+ sources = gypi_values.merve_sources
70+
+ }
71+
+}
2672
diff --git a/node.gni b/node.gni
27-
index d4438f7fd61598afac2c1e3184721a759d22b10c..e2407027ab05e59b2f0f1c213b98ea469db7a91b 100644
73+
index d4438f7fd61598afac2c1e3184721a759d22b10c..156fee33b3813fe4d94a1c9585f217a99dbfbd5f 100644
2874
--- a/node.gni
2975
+++ b/node.gni
3076
@@ -5,10 +5,10 @@
@@ -40,7 +86,16 @@ index d4438f7fd61598afac2c1e3184721a759d22b10c..e2407027ab05e59b2f0f1c213b98ea46
4086

4187
# The location of OpenSSL - use the one from node's deps by default.
4288
node_openssl_path = "$node_path/deps/openssl"
43-
@@ -50,7 +50,7 @@ declare_args() {
89+
@@ -26,8 +26,6 @@ declare_args() {
90+
# TODO(zcbenz): This is currently copied from configure.py, we should share
91+
# the list between configure.py and GN configurations.
92+
node_builtin_shareable_builtins = [
93+
- "deps/cjs-module-lexer/lexer.js",
94+
- "deps/cjs-module-lexer/dist/lexer.js",
95+
"deps/undici/undici.js",
96+
"deps/amaro/dist/index.js",
97+
]
98+
@@ -50,7 +48,7 @@ declare_args() {
4499
node_openssl_system_ca_path = ""
45100

46101
# Initialize v8 platform during node.js startup.
@@ -49,7 +104,7 @@ index d4438f7fd61598afac2c1e3184721a759d22b10c..e2407027ab05e59b2f0f1c213b98ea46
49104

50105
# Custom build tag.
51106
node_tag = ""
52-
@@ -70,10 +70,16 @@ declare_args() {
107+
@@ -70,10 +68,16 @@ declare_args() {
53108
# TODO(zcbenz): There are few broken things for now:
54109
# 1. cross-os compilation is not supported.
55110
# 2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
@@ -251,10 +306,10 @@ index 856878c33681a73d41016729dabe48b0a6a80589..91a11852d206b65485fe90fd037a0bd1
251306
if sys.platform == 'win32':
252307
files = [ x.replace('\\', '/') for x in files ]
253308
diff --git a/unofficial.gni b/unofficial.gni
254-
index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d6d25cb03 100644
309+
index c742b62c484e9dd205eff63dcffad78c76828375..bff7b0650cfe8578a044e45d0f9e352859909695 100644
255310
--- a/unofficial.gni
256311
+++ b/unofficial.gni
257-
@@ -147,31 +147,41 @@ template("node_gn_build") {
312+
@@ -147,31 +147,42 @@ template("node_gn_build") {
258313
public_configs = [
259314
":node_external_config",
260315
"deps/googletest:googletest_config",
@@ -273,6 +328,7 @@ index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d
273328
"deps/cares",
274329
"deps/histogram",
275330
"deps/llhttp",
331+
+ "deps/merve",
276332
"deps/nbytes",
277333
"deps/nghttp2",
278334
- "deps/ngtcp2",
@@ -299,7 +355,7 @@ index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d
299355
"$target_gen_dir/node_javascript.cc",
300356
] + gypi_values.node_sources
301357

302-
@@ -194,7 +204,7 @@ template("node_gn_build") {
358+
@@ -194,7 +205,7 @@ template("node_gn_build") {
303359
}
304360
if (node_use_openssl) {
305361
deps += [ "deps/ncrypto" ]
@@ -308,7 +364,7 @@ index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d
308364
sources += gypi_values.node_crypto_sources
309365
}
310366
if (node_use_sqlite) {
311-
@@ -223,6 +233,10 @@ template("node_gn_build") {
367+
@@ -223,6 +234,10 @@ template("node_gn_build") {
312368
}
313369
}
314370

@@ -319,15 +375,15 @@ index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d
319375
executable(target_name) {
320376
forward_variables_from(invoker, "*")
321377

322-
@@ -314,6 +328,7 @@ template("node_gn_build") {
378+
@@ -314,6 +329,7 @@ template("node_gn_build") {
323379
}
324380

325381
executable("node_js2c") {
326382
+ defines = []
327383
deps = [
328384
"deps/uv",
329385
"$node_simdutf_path",
330-
@@ -324,26 +339,75 @@ template("node_gn_build") {
386+
@@ -324,26 +340,75 @@ template("node_gn_build") {
331387
"src/embedded_data.cc",
332388
"src/embedded_data.h",
333389
]
@@ -413,7 +469,7 @@ index c742b62c484e9dd205eff63dcffad78c76828375..20d2483bb16e297ab5b12aab6f56948d
413469
outputs = [ "$target_gen_dir/node_javascript.cc" ]
414470

415471
# Get the path to node_js2c executable of the host toolchain.
416-
@@ -357,11 +421,11 @@ template("node_gn_build") {
472+
@@ -357,11 +422,11 @@ template("node_gn_build") {
417473
get_label_info(":node_js2c($host_toolchain)", "name") +
418474
host_executable_suffix
419475

patches/node/build_allow_unbundling_of_node_js_dependencies.patch

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,10 @@ We don't need to do this for zlib, as the existing gn workflow uses the same
1414
Upstreamed at https://github.com/nodejs/node/pull/55903
1515

1616
diff --git a/unofficial.gni b/unofficial.gni
17-
index 20d2483bb16e297ab5b12aab6f56948d6d25cb03..253226009faf563f6db285d4b2908f308c1f96ea 100644
17+
index bff7b0650cfe8578a044e45d0f9e352859909695..4ab316e45bd84e43a53335df60f847b17fe6c2fa 100644
1818
--- a/unofficial.gni
1919
+++ b/unofficial.gni
20-
@@ -160,7 +160,6 @@ template("node_gn_build") {
21-
":run_node_js2c",
22-
"deps/cares",
23-
"deps/histogram",
24-
- "deps/llhttp",
25-
"deps/nbytes",
26-
"deps/nghttp2",
27-
"deps/postject",
28-
@@ -198,7 +197,17 @@ template("node_gn_build") {
20+
@@ -199,7 +199,17 @@ template("node_gn_build") {
2921
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
3022
configs += [ "//build/config/gcc:symbol_visibility_default" ]
3123
}
@@ -44,7 +36,7 @@ index 20d2483bb16e297ab5b12aab6f56948d6d25cb03..253226009faf563f6db285d4b2908f30
4436
if (v8_enable_i18n_support) {
4537
deps += [ "//third_party/icu" ]
4638
}
47-
@@ -231,6 +240,19 @@ template("node_gn_build") {
39+
@@ -232,6 +242,19 @@ template("node_gn_build") {
4840
sources += node_inspector.node_inspector_sources +
4941
node_inspector.node_inspector_generated_sources
5042
}

patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ JS errors and ensures embedder JS is loaded via LoadEmbedderJavaScriptSource.
1010
That method is generated by our modifications to js2c.cc in the BUILD.gn patch
1111

1212
diff --git a/lib/internal/fs/watchers.js b/lib/internal/fs/watchers.js
13-
index 605dee28cace56f2366fec9d7f18894559044ae4..15dcabb3b1682438eb6d5a681363b7ea8602b9e7 100644
13+
index a493c9579669072d97c7caa9049e846bda36f8b9..334ffaa6f2d955125ca8b427ace1442c94011e18 100644
1414
--- a/lib/internal/fs/watchers.js
1515
+++ b/lib/internal/fs/watchers.js
16-
@@ -299,12 +299,13 @@ function emitCloseNT(self) {
16+
@@ -361,12 +361,13 @@ function emitCloseNT(self) {
1717
}
1818

1919
// Legacy alias on the C++ wrapper object. This is not public API, so we may
@@ -34,17 +34,17 @@ index 605dee28cace56f2366fec9d7f18894559044ae4..15dcabb3b1682438eb6d5a681363b7ea
3434
let kResistStopPropagation;
3535

3636
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
37-
index 90fdf52d79954bf2cd86fd1d2d6da8199683d344..703ac1be06249736073f797058d170576a0db1bf 100644
37+
index 2c816bef8d64f3e0ba2993c4885641620ee64272..3377d697615ee168e49e83c4202bc227581f1aaf 100644
3838
--- a/src/node_builtins.cc
3939
+++ b/src/node_builtins.cc
4040
@@ -39,6 +39,7 @@ using v8::Value;
4141
BuiltinLoader::BuiltinLoader()
4242
: config_(GetConfig()), code_cache_(std::make_shared<BuiltinCodeCache>()) {
4343
LoadJavaScriptSource();
4444
+ LoadEmbedderJavaScriptSource();
45-
#ifdef NODE_SHARED_BUILTIN_CJS_MODULE_LEXER_LEXER_PATH
46-
AddExternalizedBuiltin(
47-
"internal/deps/cjs-module-lexer/lexer",
45+
#ifdef NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
46+
AddExternalizedBuiltin("internal/deps/undici/undici",
47+
STRINGIFY(NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH));
4848
diff --git a/src/node_builtins.h b/src/node_builtins.h
4949
index bcdd50f635757f41287c87df1db9cd3b55c4b6b9..e908f3c0e314b90ff7b6c599940ea8f4e657c709 100644
5050
--- a/src/node_builtins.h

patches/node/chore_exclude_electron_node_folder_from_exit-time-destructors.patch

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ index ab7dc27de3e304f6d912d5834da47e3b4eb25495..b6c0fd4ceee989dac55c7d54e52fef18
2020
}
2121
}
2222
diff --git a/unofficial.gni b/unofficial.gni
23-
index 253226009faf563f6db285d4b2908f308c1f96ea..dd686d2f7c8d2f6e8d6bd13a7bf2b4b140556ba9 100644
23+
index 4ab316e45bd84e43a53335df60f847b17fe6c2fa..def9a302830e493e51cc2b3588816fcbd3a1bb51 100644
2424
--- a/unofficial.gni
2525
+++ b/unofficial.gni
2626
@@ -143,7 +143,10 @@ template("node_gn_build") {
@@ -35,7 +35,7 @@ index 253226009faf563f6db285d4b2908f308c1f96ea..dd686d2f7c8d2f6e8d6bd13a7bf2b4b1
3535
public_configs = [
3636
":node_external_config",
3737
"deps/googletest:googletest_config",
38-
@@ -362,6 +365,7 @@ template("node_gn_build") {
38+
@@ -364,6 +367,7 @@ template("node_gn_build") {
3939
"src/embedded_data.h",
4040
]
4141
include_dirs = [ "src", "tools" ]

patches/node/fix_handle_boringssl_and_openssl_incompatibilities.patch

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ index 175ec8ba0f2a908ffad2ce48434aeed573b09c90..3218590ddce1e92c2a9d776f20f9fb01
9494
Cipher() = default;
9595
Cipher(const EVP_CIPHER* cipher) : cipher_(cipher) {}
9696
diff --git a/node.gni b/node.gni
97-
index e2407027ab05e59b2f0f1c213b98ea469db7a91b..c64761b730e61edcdc0e46a48699f2fd5bb1c0a6 100644
97+
index 156fee33b3813fe4d94a1c9585f217a99dbfbd5f..8239967653fee7791800ee3292e77b91bffaaef9 100644
9898
--- a/node.gni
9999
+++ b/node.gni
100100
@@ -11,7 +11,7 @@ declare_args() {

patches/node/fix_redefined_macos_sdk_header_symbols.patch

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ change, it seems to introduce an incompatibility when compiling
1010
using clang modules. Disabling them resolves the issue.
1111

1212
diff --git a/unofficial.gni b/unofficial.gni
13-
index dd686d2f7c8d2f6e8d6bd13a7bf2b4b140556ba9..97e4bcfaa8aa42a5fc2b68ccdd8128eac8886532 100644
13+
index def9a302830e493e51cc2b3588816fcbd3a1bb51..900c5e4d8a48d0725420518c923c7024518158b8 100644
1414
--- a/unofficial.gni
1515
+++ b/unofficial.gni
16-
@@ -195,6 +195,10 @@ template("node_gn_build") {
16+
@@ -197,6 +197,10 @@ template("node_gn_build") {
1717
"CoreFoundation.framework",
1818
"Security.framework",
1919
]
@@ -24,7 +24,7 @@ index dd686d2f7c8d2f6e8d6bd13a7bf2b4b140556ba9..97e4bcfaa8aa42a5fc2b68ccdd8128ea
2424
}
2525
if (is_posix) {
2626
configs -= [ "//build/config/gcc:symbol_visibility_hidden" ]
27-
@@ -367,6 +371,12 @@ template("node_gn_build") {
27+
@@ -369,6 +373,12 @@ template("node_gn_build") {
2828
include_dirs = [ "src", "tools" ]
2929
configs += [ "//build/config/compiler:no_exit_time_destructors" ]
3030

0 commit comments

Comments
 (0)