![electron-roller[bot]](/assets/img/avatar_default.png)
* chore: bump node in DEPS to v22.11.0 * src: move evp stuff to ncrypto https://github.com/nodejs/node/pull/54911 * crypto: add Date fields for validTo and validFrom https://github.com/nodejs/node/pull/54159 * module: fix discrepancy between .ts and .js https://github.com/nodejs/node/pull/54461 * esm: do not interpret "main" as a URL https://github.com/nodejs/node/pull/55003 * src: modernize likely/unlikely hints https://github.com/nodejs/node/pull/55155 * chore: update patch indices * crypto: add validFromDate and validToDate fields to X509Certificate https://github.com/nodejs/node/pull/54159 * chore: fixup perfetto patch * fix: clang warning in simdjson * src: add receiver to fast api callback methods https://github.com/nodejs/node/pull/54408 * chore: fixup revert patch * fixup! esm: do not interpret "main" as a URL * fixup! crypto: add Date fields for validTo and validFrom * fix: move ArrayBuffer test patch * src: fixup Error.stackTraceLimit during snapshot building https://github.com/nodejs/node/pull/55121 * fix: bad rebase * chore: fixup amaro * chore: address feedback from review * src: revert filesystem::path changes https://github.com/nodejs/node/pull/55015 --------- Co-authored-by: electron-roller[bot] <84116207+electron-roller[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
471 lines
16 KiB
Diff
471 lines
16 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Jeremy Apthorp <nornagon@nornagon.net>
|
|
Date: Tue, 26 Feb 2019 17:07:45 -0800
|
|
Subject: build: add GN build files
|
|
|
|
This adds GN build files for Node, so we don't have to build with GYP.
|
|
|
|
Note that there always GN files in upstream Node in 20/21 branches,
|
|
however those files were cherry-picked from main branch and do not
|
|
really in 20/21. We have to wait until 22 is released to be able to
|
|
build with upstream GN files.
|
|
|
|
diff --git a/deps/simdjson/unofficial.gni b/deps/simdjson/unofficial.gni
|
|
index d6909b95886f4de3f0b953c2a2992f69066b7434..972955f9144aafcd3a3fe278b7aaad401cadddda 100644
|
|
--- a/deps/simdjson/unofficial.gni
|
|
+++ b/deps/simdjson/unofficial.gni
|
|
@@ -18,5 +18,6 @@ template("simdjson_gn_build") {
|
|
forward_variables_from(invoker, "*")
|
|
public_configs = [ ":simdjson_config" ]
|
|
sources = gypi_values.simdjson_sources
|
|
+ cflags_c = [ "-Wdeprecated-literal-operator" ]
|
|
}
|
|
}
|
|
diff --git a/deps/sqlite/unofficial.gni b/deps/sqlite/unofficial.gni
|
|
index ebb3ffcd6d42b4c16b6865a91ccf4428cffe864b..00225afa1fb4205f1e02d9f185aeb97d642b3fd9 100644
|
|
--- a/deps/sqlite/unofficial.gni
|
|
+++ b/deps/sqlite/unofficial.gni
|
|
@@ -18,8 +18,14 @@ template("sqlite_gn_build") {
|
|
forward_variables_from(invoker, "*")
|
|
public_configs = [ ":sqlite_config" ]
|
|
sources = gypi_values.sqlite_sources
|
|
+ cflags_c = [
|
|
+ "-Wno-implicit-fallthrough",
|
|
+ "-Wno-unreachable-code-break",
|
|
+ "-Wno-unreachable-code-return",
|
|
+ "-Wno-unreachable-code",
|
|
+ ]
|
|
if (is_win) {
|
|
- cflags_c = [
|
|
+ cflags_c += [
|
|
"-Wno-sign-compare",
|
|
"-Wno-unused-but-set-variable",
|
|
"-Wno-unused-function",
|
|
diff --git a/node.gni b/node.gni
|
|
index 9dca810decebd75aab427e306b3cc37c80fb55c9..852f64fa9cfb50fe6e9ce7aa46be336d3196d5b8 100644
|
|
--- a/node.gni
|
|
+++ b/node.gni
|
|
@@ -5,10 +5,10 @@
|
|
# Embedder options.
|
|
declare_args() {
|
|
# The location of Node.js in source code tree.
|
|
- node_path = "//node"
|
|
+ node_path = "//third_party/electron_node"
|
|
|
|
# The location of V8, use the one from node's deps by default.
|
|
- node_v8_path = "$node_path/deps/v8"
|
|
+ node_v8_path = "//v8"
|
|
|
|
# The NODE_MODULE_VERSION defined in node_version.h.
|
|
node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
|
|
@@ -38,7 +38,7 @@ declare_args() {
|
|
node_openssl_system_ca_path = ""
|
|
|
|
# Initialize v8 platform during node.js startup.
|
|
- node_use_v8_platform = true
|
|
+ node_use_v8_platform = false
|
|
|
|
# Custom build tag.
|
|
node_tag = ""
|
|
@@ -58,7 +58,16 @@ declare_args() {
|
|
# TODO(zcbenz): There are few broken things for now:
|
|
# 1. cross-os compilation is not supported.
|
|
# 2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
|
|
- node_use_node_snapshot = (host_os == target_os) && !(host_cpu == "arm64" && target_cpu == "x64")
|
|
+ node_use_node_snapshot = false
|
|
+
|
|
+ # Build with Amaro (TypeScript utils).
|
|
+ node_use_amaro = true
|
|
+
|
|
+ # Allows downstream packagers (eg. Linux distributions) to build against system shared libraries.
|
|
+ use_system_cares = false
|
|
+ use_system_nghttp2 = false
|
|
+ use_system_llhttp = false
|
|
+ use_system_histogram = false
|
|
}
|
|
|
|
assert(!node_enable_inspector || node_use_openssl,
|
|
diff --git a/src/node_builtins.cc b/src/node_builtins.cc
|
|
index 1bec44f6f29b0b652e92d2bb336fdb74b85eee30..599b59873dbb17ae5e7463403859e088ffb86cda 100644
|
|
--- a/src/node_builtins.cc
|
|
+++ b/src/node_builtins.cc
|
|
@@ -778,6 +778,7 @@ void BuiltinLoader::RegisterExternalReferences(
|
|
registry->Register(GetNatives);
|
|
|
|
RegisterExternalReferencesForInternalizedBuiltinCode(registry);
|
|
+ EmbedderRegisterExternalReferencesForInternalizedBuiltinCode(registry);
|
|
}
|
|
|
|
} // namespace builtins
|
|
diff --git a/src/node_builtins.h b/src/node_builtins.h
|
|
index 1cb85b9058d06555382e565dc32192a9fa48ed9f..cec9be01abd107e8612f70daf19b4834e118ffcf 100644
|
|
--- a/src/node_builtins.h
|
|
+++ b/src/node_builtins.h
|
|
@@ -74,6 +74,8 @@ using BuiltinCodeCacheMap =
|
|
// Generated by tools/js2c.py as node_javascript.cc
|
|
void RegisterExternalReferencesForInternalizedBuiltinCode(
|
|
ExternalReferenceRegistry* registry);
|
|
+void EmbedderRegisterExternalReferencesForInternalizedBuiltinCode(
|
|
+ ExternalReferenceRegistry* registry);
|
|
|
|
// Handles compilation and caching of built-in JavaScript modules and
|
|
// bootstrap scripts, whose source are bundled into the binary as static data.
|
|
diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py
|
|
index 45b3ac5006140fb55aad0e6b78084b753a947a76..35cce2ea8fd85f21582962115ac455918d4c4553 100755
|
|
--- a/tools/generate_config_gypi.py
|
|
+++ b/tools/generate_config_gypi.py
|
|
@@ -21,7 +21,7 @@ import getnapibuildversion
|
|
GN_RE = re.compile(r'(\w+)\s+=\s+(.*?)$', re.MULTILINE)
|
|
|
|
if sys.platform == 'win32':
|
|
- GN = 'gn.exe'
|
|
+ GN = 'gn.bat'
|
|
else:
|
|
GN = 'gn'
|
|
|
|
@@ -65,6 +65,7 @@ def translate_config(out_dir, config, v8_config):
|
|
eval(config['node_builtin_shareable_builtins']),
|
|
'node_module_version': int(config['node_module_version']),
|
|
'node_use_openssl': config['node_use_openssl'],
|
|
+ 'node_use_amaro': config['node_use_amaro'],
|
|
'node_use_node_code_cache': config['node_use_node_code_cache'],
|
|
'node_use_node_snapshot': config['node_use_node_snapshot'],
|
|
'v8_enable_inspector': # this is actually a node misnomer
|
|
diff --git a/tools/install.py b/tools/install.py
|
|
index bf54249b66c0d4e179deaae5a9fd55568e694fe0..31b94d2e4b532d3b8202b512e2d2f41d29a2a546 100755
|
|
--- a/tools/install.py
|
|
+++ b/tools/install.py
|
|
@@ -285,6 +285,7 @@ def headers(options, action):
|
|
'include/v8-promise.h',
|
|
'include/v8-proxy.h',
|
|
'include/v8-regexp.h',
|
|
+ 'include/v8-sandbox.h',
|
|
'include/v8-script.h',
|
|
'include/v8-snapshot.h',
|
|
'include/v8-source-location.h',
|
|
diff --git a/tools/js2c.cc b/tools/js2c.cc
|
|
old mode 100644
|
|
new mode 100755
|
|
index 21992cbe894a880e3223c379326b62db22f2f12d..1296a5457422099035ba34f2b02624f2e9dfb0f0
|
|
--- a/tools/js2c.cc
|
|
+++ b/tools/js2c.cc
|
|
@@ -28,6 +28,7 @@ namespace js2c {
|
|
int Main(int argc, char* argv[]);
|
|
|
|
static bool is_verbose = false;
|
|
+static bool only_js = false;
|
|
|
|
void Debug(const char* format, ...) {
|
|
va_list arguments;
|
|
@@ -175,6 +176,7 @@ const char* kTemplate = R"(
|
|
#include "node_builtins.h"
|
|
#include "node_external_reference.h"
|
|
#include "node_internals.h"
|
|
+#include "node_threadsafe_cow-inl.h"
|
|
|
|
namespace node {
|
|
|
|
@@ -190,7 +192,11 @@ const ThreadsafeCopyOnWrite<BuiltinSourceMap> global_source_map {
|
|
} // anonymous namespace
|
|
|
|
void BuiltinLoader::LoadJavaScriptSource() {
|
|
- source_ = global_source_map;
|
|
+ BuiltinSourceMap map = *source_.read();
|
|
+ BuiltinSourceMap new_map = *global_source_map.read();
|
|
+
|
|
+ map.merge(new_map);
|
|
+ source_ = ThreadsafeCopyOnWrite<BuiltinSourceMap>(map);
|
|
}
|
|
|
|
void RegisterExternalReferencesForInternalizedBuiltinCode(
|
|
@@ -207,6 +213,45 @@ UnionBytes BuiltinLoader::GetConfig() {
|
|
} // namespace node
|
|
)";
|
|
|
|
+const char* kEmbedderTemplate = R"(
|
|
+#include "env-inl.h"
|
|
+#include "node_builtins.h"
|
|
+#include "node_external_reference.h"
|
|
+#include "node_internals.h"
|
|
+#include "node_threadsafe_cow-inl.h"
|
|
+
|
|
+namespace node {
|
|
+
|
|
+namespace builtins {
|
|
+
|
|
+%.*s
|
|
+namespace {
|
|
+const ThreadsafeCopyOnWrite<BuiltinSourceMap> global_source_map {
|
|
+ BuiltinSourceMap {
|
|
+%.*s
|
|
+ } // BuiltinSourceMap
|
|
+
|
|
+}; // ThreadsafeCopyOnWrite
|
|
+} // anonymous namespace
|
|
+
|
|
+void BuiltinLoader::LoadEmbedderJavaScriptSource() {
|
|
+ BuiltinSourceMap map = *source_.read();
|
|
+ BuiltinSourceMap new_map = *global_source_map.read();
|
|
+
|
|
+ map.merge(new_map);
|
|
+ source_ = ThreadsafeCopyOnWrite<BuiltinSourceMap>(map);
|
|
+}
|
|
+
|
|
+void EmbedderRegisterExternalReferencesForInternalizedBuiltinCode(
|
|
+ ExternalReferenceRegistry* registry) {
|
|
+%.*s
|
|
+}
|
|
+
|
|
+} // namespace builtins
|
|
+
|
|
+} // namespace node
|
|
+)";
|
|
+
|
|
Fragment Format(const Fragments& definitions,
|
|
const Fragments& initializers,
|
|
const Fragments& registrations) {
|
|
@@ -216,13 +261,12 @@ Fragment Format(const Fragments& definitions,
|
|
size_t init_size = init_buf.size();
|
|
std::vector<char> reg_buf = Join(registrations, "\n");
|
|
size_t reg_size = reg_buf.size();
|
|
-
|
|
- size_t result_size =
|
|
- def_size + init_size + reg_size + strlen(kTemplate) + 100;
|
|
+ size_t result_size = def_size + init_size + reg_size +
|
|
+ strlen(only_js ? kEmbedderTemplate: kTemplate) + 300;
|
|
std::vector<char> result(result_size, 0);
|
|
int r = snprintf(result.data(),
|
|
result_size,
|
|
- kTemplate,
|
|
+ only_js ? kEmbedderTemplate: kTemplate,
|
|
static_cast<int>(def_buf.size()),
|
|
def_buf.data(),
|
|
static_cast<int>(init_buf.size()),
|
|
@@ -846,12 +890,15 @@ int JS2C(const FileList& js_files,
|
|
}
|
|
}
|
|
|
|
+ if (!only_js) {
|
|
assert(FilenameIsConfigGypi(config));
|
|
// "config.gypi" -> config_raw.
|
|
int r = AddGypi("config", config, &definitions);
|
|
if (r != 0) {
|
|
return r;
|
|
}
|
|
+ }
|
|
+
|
|
Fragment out = Format(definitions, initializers, registrations);
|
|
return WriteIfChanged(out, dest);
|
|
}
|
|
@@ -877,6 +924,8 @@ int Main(int argc, char* argv[]) {
|
|
std::string arg(argv[i]);
|
|
if (arg == "--verbose") {
|
|
is_verbose = true;
|
|
+ } else if (arg == "--only-js") {
|
|
+ only_js = true;
|
|
} else if (arg == "--root") {
|
|
if (i == argc - 1) {
|
|
fprintf(stderr, "--root must be followed by a path\n");
|
|
@@ -925,6 +974,14 @@ int Main(int argc, char* argv[]) {
|
|
}
|
|
}
|
|
|
|
+ if (only_js) {
|
|
+ auto js_it = file_map.find(".js");
|
|
+
|
|
+ assert(file_map.size() == 1);
|
|
+ assert(js_it != file_map.end());
|
|
+
|
|
+ return JS2C(js_it->second, FileList(), std::string(), output);
|
|
+ } else {
|
|
// Should have exactly 3 types: `.js`, `.mjs` and `.gypi`.
|
|
assert(file_map.size() == 3);
|
|
auto gypi_it = file_map.find(".gypi");
|
|
@@ -951,6 +1008,7 @@ int Main(int argc, char* argv[]) {
|
|
std::sort(mjs_it->second.begin(), mjs_it->second.end());
|
|
|
|
return JS2C(js_it->second, mjs_it->second, gypi_it->second[0], output);
|
|
+ }
|
|
}
|
|
} // namespace js2c
|
|
} // namespace node
|
|
diff --git a/tools/search_files.py b/tools/search_files.py
|
|
index 65d0e1be42f0a85418491ebb548278cf431aa6a0..d4a31342f1c6107b029394c6e1d00a1d1e877e03 100755
|
|
--- a/tools/search_files.py
|
|
+++ b/tools/search_files.py
|
|
@@ -14,6 +14,7 @@ if __name__ == '__main__':
|
|
try:
|
|
files = SearchFiles(*sys.argv[2:])
|
|
files = [ os.path.relpath(x, sys.argv[1]) for x in files ]
|
|
+ files = [os.path.normpath(x).replace(os.sep, '/') for x in files]
|
|
print('\n'.join(files))
|
|
except Exception as e:
|
|
print(str(e))
|
|
diff --git a/unofficial.gni b/unofficial.gni
|
|
index c3b311e4a7f5444b07d4d7028d4621806959804e..f6793b8bf22d6ac911a1977edaa881b6dbbe7ac7 100644
|
|
--- a/unofficial.gni
|
|
+++ b/unofficial.gni
|
|
@@ -22,6 +22,11 @@ template("node_gn_build") {
|
|
} 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 {
|
|
@@ -139,6 +144,7 @@ template("node_gn_build") {
|
|
public_deps = [
|
|
"deps/ada",
|
|
"deps/uv",
|
|
+ "//electron:electron_js2c",
|
|
"deps/simdjson",
|
|
"$node_v8_path",
|
|
]
|
|
@@ -150,7 +156,6 @@ template("node_gn_build") {
|
|
"deps/llhttp",
|
|
"deps/nbytes",
|
|
"deps/nghttp2",
|
|
- "deps/ngtcp2",
|
|
"deps/postject",
|
|
"deps/simdutf",
|
|
"deps/sqlite",
|
|
@@ -159,7 +164,11 @@ template("node_gn_build") {
|
|
"$node_v8_path:v8_libplatform",
|
|
]
|
|
|
|
+ cflags_cc = [ "-Wno-unguarded-availability-new" ]
|
|
+
|
|
sources = [
|
|
+ "src/node_snapshot_stub.cc",
|
|
+ "$root_gen_dir/electron_natives.cc",
|
|
"$target_gen_dir/node_javascript.cc",
|
|
] + gypi_values.node_sources
|
|
|
|
@@ -178,8 +187,10 @@ template("node_gn_build") {
|
|
deps += [ "//third_party/icu" ]
|
|
}
|
|
if (node_use_openssl) {
|
|
- deps += [ "deps/ncrypto" ]
|
|
- public_deps += [ "deps/openssl" ]
|
|
+ deps += [
|
|
+ "deps/ncrypto",
|
|
+ "//third_party/boringssl"
|
|
+ ]
|
|
sources += gypi_values.node_crypto_sources
|
|
}
|
|
if (node_enable_inspector) {
|
|
@@ -276,6 +287,7 @@ template("node_gn_build") {
|
|
}
|
|
|
|
executable("node_js2c") {
|
|
+ defines = []
|
|
deps = [
|
|
"deps/simdutf",
|
|
"deps/uv",
|
|
@@ -286,26 +298,75 @@ template("node_gn_build") {
|
|
"src/embedded_data.cc",
|
|
"src/embedded_data.h",
|
|
]
|
|
- include_dirs = [ "src" ]
|
|
+ include_dirs = [ "src", "tools" ]
|
|
+
|
|
+ if (!is_win) {
|
|
+ defines += [ "NODE_JS2C_USE_STRING_LITERALS" ]
|
|
+ }
|
|
+ }
|
|
+
|
|
+ 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")
|
|
+
|
|
+ fs_files = [
|
|
+ "lib/internal/fs/cp/cp-sync.js",
|
|
+ "lib/internal/fs/cp/cp.js",
|
|
+ "lib/internal/fs/dir.js",
|
|
+ "lib/internal/fs/glob.js",
|
|
+ "lib/internal/fs/promises.js",
|
|
+ "lib/internal/fs/read/context.js",
|
|
+ "lib/internal/fs/recursive_watch.js",
|
|
+ "lib/internal/fs/rimraf.js",
|
|
+ "lib/internal/fs/streams.js",
|
|
+ "lib/internal/fs/sync_write_stream.js",
|
|
+ "lib/internal/fs/utils.js",
|
|
+ "lib/internal/fs/watchers.js",
|
|
+ "lib/fs.js",
|
|
+ "lib/fs/promises.js"
|
|
+ ]
|
|
+
|
|
+ original_fs_files = []
|
|
+ foreach(file, fs_files) {
|
|
+ original_fs_files += [string_replace(string_replace(string_replace(file, "internal/fs/", "internal/original-fs/"), "lib/fs.js", "lib/original-fs.js"), "lib/fs/", "lib/original-fs/")]
|
|
+ }
|
|
+
|
|
+ copy("node_js2c_inputs") {
|
|
+ sources = node_deps_files + node_library_files
|
|
+ outputs = [
|
|
+ "$target_gen_dir/js2c_inputs/{{source_target_relative}}",
|
|
+ ]
|
|
+ }
|
|
+
|
|
+ action("node_js2c_original_fs") {
|
|
+ script = "//electron/script/node/generate_original_fs.py"
|
|
+ inputs = fs_files
|
|
+ deps = [ ":node_js2c_inputs" ]
|
|
+
|
|
+ outputs = []
|
|
+ foreach(file, original_fs_files) {
|
|
+ outputs += ["$target_gen_dir/js2c_inputs/$file"]
|
|
+ }
|
|
+
|
|
+ args = [rebase_path("$target_gen_dir/js2c_inputs")] + fs_files
|
|
}
|
|
|
|
action("run_node_js2c") {
|
|
- script = "$node_v8_path/tools/run.py"
|
|
+ script = "//electron/build/run-in-dir.py"
|
|
deps = [
|
|
+ ":node_js2c_original_fs",
|
|
":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")
|
|
-
|
|
+ config_gypi = [ "$target_gen_dir/config.gypi" ]
|
|
inputs = node_library_files +
|
|
node_deps_files +
|
|
- [ "$target_gen_dir/config.gypi" ]
|
|
+ get_target_outputs(":node_js2c_original_fs") +
|
|
+ config_gypi
|
|
outputs = [ "$target_gen_dir/node_javascript.cc" ]
|
|
|
|
# Get the path to node_js2c executable of the host toolchain.
|
|
@@ -319,11 +380,11 @@ template("node_gn_build") {
|
|
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
|
|
+ args = [ rebase_path("$target_gen_dir/js2c_inputs"),
|
|
+ rebase_path(node_js2c_path),
|
|
+ rebase_path("$target_gen_dir/node_javascript.cc")] +
|
|
+ rebase_path(config_gypi) + node_deps_files +
|
|
+ original_fs_files + node_library_files
|
|
}
|
|
|
|
executable("node_cctest") {
|