Browse Source

build: simplify node patches (#19286)

* build: collapse all BUILD.gn modifications into the original GN file patch

* build: collapse all the js2c.py changes into a single patch with a good explanation
Samuel Attard 5 years ago
parent
commit
3ded946686

+ 1 - 11
patches/node/.patches

@@ -14,7 +14,6 @@ fix_add_default_values_for_enable_lto_and_build_v8_with_gn_in.patch
 feat_add_new_built_with_electron_variable_to_config_gypi.patch
 feat_add_flags_for_low-level_hooks_and_exceptions.patch
 export_environment_knodecontexttagptr.patch
-fix_export_libuv_symbols_73.patch
 fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch
 fix_use_bssl_bn_bn2bin_padded_for_ossl_s_bn_bn2binpad.patch
 pass_all_globals_through_require.patch
@@ -28,8 +27,7 @@ fix_make_it_possible_to_change_nobrowserglobals_at_runtime.patch
 fix_key_gen_apis_are_not_available_in_boringssl.patch
 fix_do_not_define_debugoptions_s_constructors_in_header.patch
 src_disable_node_use_v8_platform_in_node_options.patch
-feat_add_original-fs_module.patch
-build_allow_embedders_to_override_the_node_module_version_define.patch
+build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch
 refactor_allow_embedder_overriding_of_internal_fs_calls.patch
 chore_add_ability_to_prevent_warn_non_context-aware_native_modules.patch
 fsevents_fix_file_event_reporting.patch
@@ -37,18 +35,10 @@ src_only_run_preloadmodules_if_the_preload_array_is_not_empty.patch
 src_read_break_node_first_line_from_the_inspect_options.patch
 chore_allow_the_node_entrypoint_to_be_a_builtin_module.patch
 inherit_electron_crashpad_pipe_name_in_child_process.patch
-allow_embedder_to_insert_js_data_into_nativemoduleloader.patch
-chore_update_gn_files_for_file_movement.patch
 fixme_revert_crypto_add_support_for_rsa-pss_keys.patch
-build_fix_gn_build_scripts_and_js2c_for_node_12_4_and_embedder_use.patch
 chore_re-add_compileandcall_this_should_be_added_as_a_helper_in.patch
 chore_remove_unused_private_runtimeagent_member_env.patch
 src_add_missing_option_parser_template_for_the_debugoptionsparser.patch
 src_expose_maybeinitializecontext_to_allow_existing_contexts.patch
-fix_don_t_define_building_v8_shared_in_component_builds_109.patch
-chore_fix_js2c_hacks_for_original-fs.patch
-chore_remove_sysinfo-memory_from_build_files.patch
-fix_make_js2c_normalize_paths_before_splitting_on_separaters.patch
 fix_extern_the_nativemoduleenv_and_options_parser_for_debug_builds.patch
-fix_ensure_js2c_maps_internal-fs_streams.patch
 chore_read_nobrowserglobals_from_global_not_process.patch

+ 0 - 30
patches/node/allow_embedder_to_insert_js_data_into_nativemoduleloader.patch

@@ -1,30 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: deepak1556 <[email protected]>
-Date: Tue, 26 Feb 2019 17:04:14 -0800
-Subject: Allow embedder to insert JS data into NativeModuleLoader
-
-
-diff --git a/src/node_native_module.cc b/src/node_native_module.cc
-index 814adb620dcf8a459bbede11714e9ccd7f4e0b3e..04a706d15f2ab682f8d4ae972abee8986494f7a7 100644
---- a/src/node_native_module.cc
-+++ b/src/node_native_module.cc
-@@ -23,6 +23,7 @@ NativeModuleLoader NativeModuleLoader::instance_;
- 
- NativeModuleLoader::NativeModuleLoader() : config_(GetConfig()) {
-   LoadJavaScriptSource();
-+  LoadEmbedderJavaScriptSource();
- }
- 
- NativeModuleLoader* NativeModuleLoader::GetInstance() {
-diff --git a/src/node_native_module.h b/src/node_native_module.h
-index fabaea75686161f488a03349e07049a513b98fad..5a6b01dc12fb77d5f8c26a1153ead2a1b2a8d061 100644
---- a/src/node_native_module.h
-+++ b/src/node_native_module.h
-@@ -44,6 +44,7 @@ class NativeModuleLoader {
- 
-   // Generated by tools/js2c.py as node_javascript.cc
-   void LoadJavaScriptSource();  // Loads data into source_
-+  void LoadEmbedderJavaScriptSource();  // Loads embedder data into source_
-   UnionBytes GetConfig();       // Return data for config.gypi
- 
-   bool Exists(const char* id);

+ 111 - 41
patches/node/build_add_gn_build_files.patch

@@ -6,10 +6,10 @@ Subject: build: add GN build files
 
 diff --git a/BUILD.gn b/BUILD.gn
 new file mode 100644
-index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f994680923a500a36
+index 0000000000000000000000000000000000000000..f27c13b312a60d9b5c7ea0948b347ab0936ab3f8
 --- /dev/null
 +++ b/BUILD.gn
-@@ -0,0 +1,351 @@
+@@ -0,0 +1,369 @@
 +import("//electron/build/asar.gni")
 +import("//v8/gni/v8.gni")
 +
@@ -49,6 +49,9 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +  # `sourceUrl` and `headersUrl`. When compiling a release build, this will
 +  # default to https://nodejs.org/download/release/')
 +  node_release_urlbase = ""
++
++  # Allows embedders to override the NODE_MODULE_VERSION define
++  node_module_version = ""
 +}
 +
 +assert(!node_use_dtrace, "node_use_dtrace not supported in GN")
@@ -87,14 +90,14 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +
 +  macro_inputs = []
 +  if (!node_use_dtrace && !node_use_etw) {
-+    macro_inputs += [ "src/notrace_macros.py" ]
++    macro_inputs += [ "tools/js2c_macros/notrace_macros.py" ]
 +  }
 +  if (node_debug_lib) {
-+    macro_inputs += [ "tools/nodcheck_macros.py" ]
++    macro_inputs += [ "tools/js2c_macros/nodcheck_macros.py" ]
 +  } else {
-+    macro_inputs += [ "tools/dcheck_macros.py" ]
++    macro_inputs += [ "tools/js2c_macros/dcheck_macros.py" ]
 +  }
-+  macro_inputs += [ "tools/check_macros.py" ]
++  macro_inputs += [ "tools/js2c_macros/check_macros.py" ]
 +
 +  config_gypi = [ "$target_gen_dir/config.gypi" ]
 +
@@ -105,9 +108,7 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +
 +  cwd = "$target_gen_dir/js2c_inputs"
 +  script = "tools/js2c.py"
-+  args = rebase_path(outputs)
-+  args += library_files
-+  args += rebase_path(macro_inputs + config_gypi)
++  args = library_files + rebase_path(macro_inputs + config_gypi) + ["--target"] + rebase_path(outputs)
 +}
 +
 +config("node_features") {
@@ -122,6 +123,8 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +  } else {
 +    defines += [ "HAVE_OPENSSL=0" ]
 +  }
++  # boringssl does not support SSL_trace, let's disable it
++  defines += ["OPENSSL_NO_SSL_TRACE=1"]
 +  if (v8_enable_i18n_support) {
 +    defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
 +  } else {
@@ -157,11 +160,11 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +    "NODE_WANT_INTERNALS=1",
 +    "NODE_IMPLEMENTATION",
 +  ]
++  if (node_module_version != "") {
++    defines += [ "NODE_MODULE_VERSION=" + node_module_version ]
++  }
 +  if (is_component_build) {
 +    defines += [
-+      "BUILDING_V8_SHARED",
-+      "BUILDING_V8_PLATFORM_SHARED",
-+      "BUILDING_V8_BASE_SHARED",
 +      "NODE_SHARED_MODE",
 +    ]
 +  }
@@ -212,14 +215,14 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +component("node_lib") {
 +  deps = [
 +    ":node_js2c",
-+    "//third_party/brotli:enc",
-+    "//third_party/brotli:dec",
 +    "deps/cares",
 +    "deps/histogram",
 +    "deps/http_parser",
 +    "deps/llhttp",
 +    "deps/nghttp2",
 +    "deps/zlib",
++    "//third_party/brotli:dec",
++    "//third_party/brotli:enc",
 +    "//v8:v8_libplatform",
 +  ]
 +  public_deps = [
@@ -267,8 +270,8 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +      "src/inspector_agent.h",
 +      "src/inspector_io.cc",
 +      "src/inspector_io.h",
-+      "src/inspector_profiler.cc",
 +      "src/inspector_js_api.cc",
++      "src/inspector_profiler.cc",
 +      "src/inspector_socket.cc",
 +      "src/inspector_socket.h",
 +      "src/inspector_socket_server.cc",
@@ -335,6 +338,20 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +  ]
 +}
 +
++action("node_version_header") {
++  inputs = [
++    "src/node_version.h",
++  ]
++  outputs = [
++    "$node_headers_dir/include/node/node_version.h",
++  ]
++  script = "tools/generate_node_version_header.py"
++  args = [ rebase_path("src/node_version.h"), rebase_path(outputs[0]) ]
++  if (node_module_version != "") {
++    args += [ "$node_module_version" ]
++  }
++}
++
 +action("tar_headers") {
 +  deps = [
 +    ":copy_headers",
@@ -353,6 +370,7 @@ index 0000000000000000000000000000000000000000..028b0ae16ffac1fc89128f2f99468092
 +  public_deps = header_groups + [
 +                  ":zlib_headers",
 +                  ":node_gypi_headers",
++                  ":node_version_header",
 +                ]
 +}
 +
@@ -608,10 +626,10 @@ index 0000000000000000000000000000000000000000..66af819990b338caa49ca59d1fe6c5ad
 +}
 diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn
 new file mode 100644
-index 0000000000000000000000000000000000000000..b62fac6738ae74788faa6e5dcc705b81d8325ece
+index 0000000000000000000000000000000000000000..4674bdd48b4bfc9b7152377b8cd0984d1cf42562
 --- /dev/null
 +++ b/deps/uv/BUILD.gn
-@@ -0,0 +1,188 @@
+@@ -0,0 +1,185 @@
 +config("libuv_config") {
 +  include_dirs = [ "include" ]
 +
@@ -643,6 +661,9 @@ index 0000000000000000000000000000000000000000..b62fac6738ae74788faa6e5dcc705b81
 +
 +  defines = []
 +
++  # This only has an effect on Windows, where it will cause libuv's symbols to be exported in node.lib
++  defines += [ "BUILDING_UV_SHARED=1" ]
++
 +  cflags_c = [
 +    "-Wno-bitwise-op-parentheses",
 +    "-Wno-implicit-function-declaration",
@@ -781,7 +802,6 @@ index 0000000000000000000000000000000000000000..b62fac6738ae74788faa6e5dcc705b81
 +      "src/unix/linux-syscalls.h",
 +      "src/unix/procfs-exepath.c",
 +      "src/unix/sysinfo-loadavg.c",
-+      "src/unix/sysinfo-memory.c",
 +    ]
 +    libs += [
 +      "dl",
@@ -794,11 +814,6 @@ index 0000000000000000000000000000000000000000..b62fac6738ae74788faa6e5dcc705b81
 +      "src/unix/kqueue.c",
 +    ]
 +  }
-+  if (is_component_build && is_win) {
-+    defines += [
-+      "BUILDING_UV_SHARED=1",
-+    ]
-+  }
 +}
 diff --git a/deps/zlib/BUILD.gn b/deps/zlib/BUILD.gn
 new file mode 100644
@@ -866,10 +881,10 @@ index 0000000000000000000000000000000000000000..f13b471d17128468bed06e66bd03a2ea
 +}
 diff --git a/filenames.json b/filenames.json
 new file mode 100644
-index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914756fdb7e
+index 0000000000000000000000000000000000000000..edb0b215088118f567c5ad5e5969d1eb5ef661a3
 --- /dev/null
 +++ b/filenames.json
-@@ -0,0 +1,435 @@
+@@ -0,0 +1,443 @@
 +// This file is automatically generated by generate_gn_filenames_json.py
 +// DO NOT EDIT
 +{
@@ -883,8 +898,7 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +        "src/node_api.h",
 +        "src/node_api_types.h",
 +        "src/node_buffer.h",
-+        "src/node_object_wrap.h",
-+        "src/node_version.h"
++        "src/node_object_wrap.h"
 +      ]
 +    },
 +    {
@@ -940,11 +954,11 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +    }
 +  ],
 +  "library_files": [
-+    "lib/internal/bootstrap/primordials.js",
-+    "lib/internal/bootstrap/cache.js",
++    "lib/internal/bootstrap/environment.js",
 +    "lib/internal/bootstrap/loaders.js",
 +    "lib/internal/bootstrap/node.js",
 +    "lib/internal/bootstrap/pre_execution.js",
++    "lib/internal/per_context/primordials.js",
 +    "lib/internal/per_context/setup.js",
 +    "lib/internal/per_context/domexception.js",
 +    "lib/async_hooks.js",
@@ -1083,7 +1097,6 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +    "lib/internal/process/worker_thread_only.js",
 +    "lib/internal/process/report.js",
 +    "lib/internal/process/task_queues.js",
-+    "lib/internal/profiler.js",
 +    "lib/internal/querystring.js",
 +    "lib/internal/readline.js",
 +    "lib/internal/repl.js",
@@ -1137,9 +1150,16 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +    "deps/node-inspect/lib/internal/inspect_client.js",
 +    "deps/node-inspect/lib/internal/inspect_repl.js",
 +    "deps/acorn/acorn/dist/acorn.js",
-+    "deps/acorn/acorn-walk/dist/walk.js"
++    "deps/acorn/acorn-walk/dist/walk.js",
++    "deps/acorn-plugins/acorn-bigint/index.js",
++    "deps/acorn-plugins/acorn-class-fields/index.js",
++    "deps/acorn-plugins/acorn-numeric-separator/index.js",
++    "deps/acorn-plugins/acorn-private-class-elements/index.js",
++    "deps/acorn-plugins/acorn-private-methods/index.js",
++    "deps/acorn-plugins/acorn-static-class-features/index.js"
 +  ],
 +  "node_sources": [
++    "src/api/async_resource.cc",
 +    "src/api/callback.cc",
 +    "src/api/encoding.cc",
 +    "src/api/environment.cc",
@@ -1178,9 +1198,11 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +    "src/node_http_parser_traditional.cc",
 +    "src/node_http2.cc",
 +    "src/node_i18n.cc",
++    "src/node_main_instance.cc",
 +    "src/node_messaging.cc",
 +    "src/node_metadata.cc",
 +    "src/node_native_module.cc",
++    "src/node_native_module_env.cc",
 +    "src/node_options.cc",
 +    "src/node_os.cc",
 +    "src/node_perf.cc",
@@ -1256,16 +1278,17 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +    "src/node_http2_state.h",
 +    "src/node_i18n.h",
 +    "src/node_internals.h",
++    "src/node_main_instance.h",
 +    "src/node_messaging.h",
 +    "src/node_metadata.h",
 +    "src/node_mutex.h",
 +    "src/node_native_module.h",
++    "src/node_native_module_env.h",
 +    "src/node_object_wrap.h",
 +    "src/node_options.h",
 +    "src/node_options-inl.h",
 +    "src/node_perf.h",
 +    "src/node_perf_common.h",
-+    "src/node_persistent.h",
 +    "src/node_platform.h",
 +    "src/node_process.h",
 +    "src/node_revert.h",
@@ -1307,10 +1330,10 @@ index 0000000000000000000000000000000000000000..615b82d3d78d63c8441172d65f008914
 +}
 diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
 new file mode 100644
-index 0000000000000000000000000000000000000000..0e1a5a22315989d5b0b4b6462330b3d693a43228
+index 0000000000000000000000000000000000000000..48ad85e895b6111223119fafa57c13ba75cdbeae
 --- /dev/null
 +++ b/src/inspector/BUILD.gn
-@@ -0,0 +1,194 @@
+@@ -0,0 +1,195 @@
 +import("//v8/gni/v8.gni")
 +
 +inspector_protocol_dir = "../../tools/inspector_protocol"
@@ -1381,10 +1404,11 @@ index 0000000000000000000000000000000000000000..0e1a5a22315989d5b0b4b6462330b3d6
 +
 +  inputs = [
 +    "$target_gen_dir/node_protocol_config.json",
-+    "$target_gen_dir/node_protocol.json",
++    "$target_gen_dir/src/node_protocol.json",
++    "$inspector_protocol_dir/lib/base_string_adapter_cc.template",
++    "$inspector_protocol_dir/lib/base_string_adapter_h.template",
 +    "$inspector_protocol_dir/lib/Allocator_h.template",
 +    "$inspector_protocol_dir/lib/Array_h.template",
-+    "$inspector_protocol_dir/lib/Collections_h.template",
 +    "$inspector_protocol_dir/lib/DispatcherBase_cpp.template",
 +    "$inspector_protocol_dir/lib/DispatcherBase_h.template",
 +    "$inspector_protocol_dir/lib/ErrorSupport_cpp.template",
@@ -1463,13 +1487,13 @@ index 0000000000000000000000000000000000000000..0e1a5a22315989d5b0b4b6462330b3d6
 +    "node_protocol.pdl",
 +  ]
 +  outputs = [
-+    "$target_gen_dir/node_protocol.json",
++    "$target_gen_dir/src/node_protocol.json",
 +  ]
 +}
 +
 +generate_protocol_json("v8_protocol_json") {
 +  sources = [
-+    "//v8/src/inspector/js_protocol.pdl",
++    "//v8/include/js_protocol.pdl",
 +  ]
 +  outputs = [
 +    "$target_gen_dir/js_protocol.json",
@@ -1483,7 +1507,7 @@ index 0000000000000000000000000000000000000000..0e1a5a22315989d5b0b4b6462330b3d6
 +  ]
 +  inputs = [
 +    "$target_gen_dir/js_protocol.json",
-+    "$target_gen_dir/node_protocol.json",
++    "$target_gen_dir/src/node_protocol.json",
 +  ]
 +  outputs = [
 +    "$target_gen_dir/concatenated_protocol.json",
@@ -1505,6 +1529,21 @@ index 0000000000000000000000000000000000000000..0e1a5a22315989d5b0b4b6462330b3d6
 +  script = "../../tools/compress_json.py"
 +  args = rebase_path(inputs + outputs, root_build_dir)
 +}
+diff --git a/src/node_version.h b/src/node_version.h
+index 1c04b102721f891c6b657702b7f8585137647e04..a9f8a9c8cbfd3996906eb400388aaa99ef77f547 100644
+--- a/src/node_version.h
++++ b/src/node_version.h
+@@ -89,7 +89,10 @@
+  * version matching should open a pull request to reserve a number in this
+  * registry.
+  */
++// Electron sets NODE_MODULE_VERSION in their GN configuration
++#ifndef NODE_MODULE_VERSION
+ #define NODE_MODULE_VERSION 72
++#endif
+ 
+ // the NAPI_VERSION provided by this version of the runtime
+ #define NAPI_VERSION  4
 diff --git a/tools/generate_config_gypi.py b/tools/generate_config_gypi.py
 new file mode 100644
 index 0000000000000000000000000000000000000000..01f62d4ae6e3b9d539444e3dff069f0011353caa
@@ -1524,7 +1563,7 @@ index 0000000000000000000000000000000000000000..01f62d4ae6e3b9d539444e3dff069f00
 +  main(sys.argv[1:])
 diff --git a/tools/generate_gn_filenames_json.py b/tools/generate_gn_filenames_json.py
 new file mode 100755
-index 0000000000000000000000000000000000000000..28e97bcb9aed0a8c0bbfa0e00ba914aa923d4bba
+index 0000000000000000000000000000000000000000..41f0138dfa9f610de1f8267080fa15e8bd9e0325
 --- /dev/null
 +++ b/tools/generate_gn_filenames_json.py
 @@ -0,0 +1,63 @@
@@ -1579,7 +1618,7 @@ index 0000000000000000000000000000000000000000..28e97bcb9aed0a8c0bbfa0e00ba914aa
 +
 +  def add_headers(files, dest_dir):
 +    if 'src/node.h' in files:
-+      files = [f for f in files if f.endswith('.h')]
++      files = [f for f in files if f.endswith('.h') and f != 'src/node_version.h']
 +    elif any(f.startswith('deps/v8/') for f in files):
 +      files = [f.replace('deps/v8/', '//v8/', 1) for f in files]
 +    hs = {'files': sorted(files), 'dest_dir': dest_dir}
@@ -1591,6 +1630,37 @@ index 0000000000000000000000000000000000000000..28e97bcb9aed0a8c0bbfa0e00ba914aa
 +    f.write(FILENAMES_JSON_HEADER)
 +    f.write(json.dumps(out, sort_keys=True, indent=2, separators=(',', ': ')))
 +    f.write('\n')
+diff --git a/tools/generate_node_version_header.py b/tools/generate_node_version_header.py
+new file mode 100755
+index 0000000000000000000000000000000000000000..3088ae4bdf814ae255c9805ebd393b2eee17e941
+--- /dev/null
++++ b/tools/generate_node_version_header.py
+@@ -0,0 +1,25 @@
++#!/usr/bin/env python
++import re
++import sys
++
++node_version_file = sys.argv[1]
++out_file = sys.argv[2]
++NMV = None
++if len(sys.argv) > 3:
++  NMV = sys.argv[3]
++
++with open(node_version_file, 'r') as in_file, open(out_file, 'w') as out_file:
++  changed = False
++  contents = in_file.read()
++  new_contents = re.sub(
++    r'^#define NODE_MODULE_VERSION [0-9]+$',
++    '#define NODE_MODULE_VERSION ' + NMV,
++    contents,
++    flags=re.MULTILINE)
++
++  changed = contents != new_contents
++
++  if not changed and NMV is not None:
++    raise Exception("Did not modify the NMV from nodes value, this value MUST differ from node")
++
++  out_file.writelines(new_contents)
 diff --git a/tools/js2c.py b/tools/js2c.py
 index c3ac53f14b739142a5da43e15b43b8642b36fa84..68152c499ce610d759b5abd659340957efb864d6 100755
 --- a/tools/js2c.py

+ 0 - 159
patches/node/build_allow_embedders_to_override_the_node_module_version_define.patch

@@ -1,159 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Tue, 16 Apr 2019 15:12:14 -0700
-Subject: build: allow embedders to override the NODE_MODULE_VERSION define
-
-
-diff --git a/BUILD.gn b/BUILD.gn
-index 028b0ae16ffac1fc89128f2f994680923a500a36..b5912d4d671db27761be4c6283ed5e21818c5b04 100644
---- a/BUILD.gn
-+++ b/BUILD.gn
-@@ -37,6 +37,9 @@ declare_args() {
-   # `sourceUrl` and `headersUrl`. When compiling a release build, this will
-   # default to https://nodejs.org/download/release/')
-   node_release_urlbase = ""
-+
-+  # Allows embedders to override the NODE_MODULE_VERSION define
-+  node_module_version = ""
- }
- 
- assert(!node_use_dtrace, "node_use_dtrace not supported in GN")
-@@ -145,6 +148,9 @@ config("node_internal_config") {
-     "NODE_WANT_INTERNALS=1",
-     "NODE_IMPLEMENTATION",
-   ]
-+  if (node_module_version != "") {
-+    defines += [ "NODE_MODULE_VERSION=" + node_module_version ]
-+  }
-   if (is_component_build) {
-     defines += [
-       "BUILDING_V8_SHARED",
-@@ -200,14 +206,14 @@ config("node_internal_config") {
- component("node_lib") {
-   deps = [
-     ":node_js2c",
--    "//third_party/brotli:enc",
--    "//third_party/brotli:dec",
-     "deps/cares",
-     "deps/histogram",
-     "deps/http_parser",
-     "deps/llhttp",
-     "deps/nghttp2",
-     "deps/zlib",
-+    "//third_party/brotli:dec",
-+    "//third_party/brotli:enc",
-     "//v8:v8_libplatform",
-   ]
-   public_deps = [
-@@ -255,8 +261,8 @@ component("node_lib") {
-       "src/inspector_agent.h",
-       "src/inspector_io.cc",
-       "src/inspector_io.h",
--      "src/inspector_profiler.cc",
-       "src/inspector_js_api.cc",
-+      "src/inspector_profiler.cc",
-       "src/inspector_socket.cc",
-       "src/inspector_socket.h",
-       "src/inspector_socket_server.cc",
-@@ -323,6 +329,20 @@ copy("node_gypi_headers") {
-   ]
- }
- 
-+action("node_version_header") {
-+  inputs = [
-+    "src/node_version.h",
-+  ]
-+  outputs = [
-+    "$node_headers_dir/include/node/node_version.h",
-+  ]
-+  script = "tools/generate_node_version_header.py"
-+  args = [ rebase_path("src/node_version.h"), rebase_path(outputs[0]) ]
-+  if (node_module_version != "") {
-+    args += [ "$node_module_version" ]
-+  }
-+}
-+
- action("tar_headers") {
-   deps = [
-     ":copy_headers",
-@@ -341,6 +361,7 @@ group("copy_headers") {
-   public_deps = header_groups + [
-                   ":zlib_headers",
-                   ":node_gypi_headers",
-+                  ":node_version_header",
-                 ]
- }
- 
-diff --git a/filenames.json b/filenames.json
-index 615b82d3d78d63c8441172d65f008914756fdb7e..86d89280e74d7365ab2782517fb779fc072bf0bf 100644
---- a/filenames.json
-+++ b/filenames.json
-@@ -11,8 +11,7 @@
-         "src/node_api.h",
-         "src/node_api_types.h",
-         "src/node_buffer.h",
--        "src/node_object_wrap.h",
--        "src/node_version.h"
-+        "src/node_object_wrap.h"
-       ]
-     },
-     {
-diff --git a/src/node_version.h b/src/node_version.h
-index 1c04b102721f891c6b657702b7f8585137647e04..a9f8a9c8cbfd3996906eb400388aaa99ef77f547 100644
---- a/src/node_version.h
-+++ b/src/node_version.h
-@@ -89,7 +89,10 @@
-  * version matching should open a pull request to reserve a number in this
-  * registry.
-  */
-+// Electron sets NODE_MODULE_VERSION in their GN configuration
-+#ifndef NODE_MODULE_VERSION
- #define NODE_MODULE_VERSION 72
-+#endif
- 
- // the NAPI_VERSION provided by this version of the runtime
- #define NAPI_VERSION  4
-diff --git a/tools/generate_gn_filenames_json.py b/tools/generate_gn_filenames_json.py
-index 28e97bcb9aed0a8c0bbfa0e00ba914aa923d4bba..41f0138dfa9f610de1f8267080fa15e8bd9e0325 100755
---- a/tools/generate_gn_filenames_json.py
-+++ b/tools/generate_gn_filenames_json.py
-@@ -49,7 +49,7 @@ if __name__ == '__main__':
- 
-   def add_headers(files, dest_dir):
-     if 'src/node.h' in files:
--      files = [f for f in files if f.endswith('.h')]
-+      files = [f for f in files if f.endswith('.h') and f != 'src/node_version.h']
-     elif any(f.startswith('deps/v8/') for f in files):
-       files = [f.replace('deps/v8/', '//v8/', 1) for f in files]
-     hs = {'files': sorted(files), 'dest_dir': dest_dir}
-diff --git a/tools/generate_node_version_header.py b/tools/generate_node_version_header.py
-new file mode 100755
-index 0000000000000000000000000000000000000000..3088ae4bdf814ae255c9805ebd393b2eee17e941
---- /dev/null
-+++ b/tools/generate_node_version_header.py
-@@ -0,0 +1,25 @@
-+#!/usr/bin/env python
-+import re
-+import sys
-+
-+node_version_file = sys.argv[1]
-+out_file = sys.argv[2]
-+NMV = None
-+if len(sys.argv) > 3:
-+  NMV = sys.argv[3]
-+
-+with open(node_version_file, 'r') as in_file, open(out_file, 'w') as out_file:
-+  changed = False
-+  contents = in_file.read()
-+  new_contents = re.sub(
-+    r'^#define NODE_MODULE_VERSION [0-9]+$',
-+    '#define NODE_MODULE_VERSION ' + NMV,
-+    contents,
-+    flags=re.MULTILINE)
-+
-+  changed = contents != new_contents
-+
-+  if not changed and NMV is not None:
-+    raise Exception("Did not modify the NMV from nodes value, this value MUST differ from node")
-+
-+  out_file.writelines(new_contents)

+ 0 - 149
patches/node/build_fix_gn_build_scripts_and_js2c_for_node_12_4_and_embedder_use.patch

@@ -1,149 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Fri, 28 Jun 2019 17:13:38 -0700
-Subject: build: fix GN build scripts and js2c for node 12.4 and embedder use
- cases
-
-
-diff --git a/BUILD.gn b/BUILD.gn
-index c722975a4bc82b46192b0e72f4995fce243fa5bf..77b2ed2978682c1a171346339ded5f2638c27fd9 100644
---- a/BUILD.gn
-+++ b/BUILD.gn
-@@ -96,9 +96,7 @@ chdir_action("node_js2c") {
- 
-   cwd = "$target_gen_dir/js2c_inputs"
-   script = "tools/js2c.py"
--  args = rebase_path(outputs)
--  args += library_files
--  args += rebase_path(macro_inputs + config_gypi)
-+  args = library_files + rebase_path(macro_inputs + config_gypi) + ["--target"] + rebase_path(outputs)
- }
- 
- config("node_features") {
-@@ -113,6 +111,8 @@ config("node_features") {
-   } else {
-     defines += [ "HAVE_OPENSSL=0" ]
-   }
-+  # boringssl does not support SSL_trace, let's disable it
-+  defines += ["OPENSSL_NO_SSL_TRACE=1"]
-   if (v8_enable_i18n_support) {
-     defines += [ "NODE_HAVE_I18N_SUPPORT=1" ]
-   } else {
-diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
-index ebf5e610d675e53ad4af40e92d5217995ed8f577..48ad85e895b6111223119fafa57c13ba75cdbeae 100644
---- a/src/inspector/BUILD.gn
-+++ b/src/inspector/BUILD.gn
-@@ -68,7 +68,7 @@ action("protocol_generated_sources") {
- 
-   inputs = [
-     "$target_gen_dir/node_protocol_config.json",
--    "$target_gen_dir/node_protocol.json",
-+    "$target_gen_dir/src/node_protocol.json",
-     "$inspector_protocol_dir/lib/base_string_adapter_cc.template",
-     "$inspector_protocol_dir/lib/base_string_adapter_h.template",
-     "$inspector_protocol_dir/lib/Allocator_h.template",
-@@ -151,13 +151,13 @@ generate_protocol_json("node_protocol_json") {
-     "node_protocol.pdl",
-   ]
-   outputs = [
--    "$target_gen_dir/node_protocol.json",
-+    "$target_gen_dir/src/node_protocol.json",
-   ]
- }
- 
- generate_protocol_json("v8_protocol_json") {
-   sources = [
--    "//v8/src/inspector/js_protocol.pdl",
-+    "//v8/include/js_protocol.pdl",
-   ]
-   outputs = [
-     "$target_gen_dir/js_protocol.json",
-@@ -171,7 +171,7 @@ action("concatenate_protocols") {
-   ]
-   inputs = [
-     "$target_gen_dir/js_protocol.json",
--    "$target_gen_dir/node_protocol.json",
-+    "$target_gen_dir/src/node_protocol.json",
-   ]
-   outputs = [
-     "$target_gen_dir/concatenated_protocol.json",
-diff --git a/tools/js2c.py b/tools/js2c.py
-index 87cca4eaf7c909e1f871287d7f019f701a05dd0f..c7a90f6eaeb9f5789ffb86c070132551f4275354 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -187,13 +187,15 @@ namespace native_module {{
- 
- {0}
- 
--void NativeModuleLoader::LoadJavaScriptSource() {{
-+void NativeModuleLoader::Load{4}JavaScriptSource() {{
-   {1}
- }}
- 
-+#if {2}
- UnionBytes NativeModuleLoader::GetConfig() {{
--  return UnionBytes(config_raw, {2});  // config.gypi
-+  return UnionBytes(config_raw, {3});  // config.gypi
- }}
-+#endif
- 
- }}  // namespace native_module
- 
-@@ -273,9 +275,9 @@ def NormalizeFileName(filename):
- 
-   return os.path.splitext(filename)[0]
- 
--def JS2C(source_files, target):
-+def JS2C(source_files, target, only_js):
-   # Process input from all *macro.py files
--  consts, macros = ReadMacros(source_files['.py'])
-+  consts, macros = ReadMacros([] if only_js else source_files['.py'])
- 
-   # Build source code lines
-   definitions = []
-@@ -294,13 +296,15 @@ def JS2C(source_files, target):
-     elif filename == 'internal/fs/streams.js':
-       AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
- 
--  config_def, config_size = handle_config_gypi(source_files['config.gypi'])
--  definitions.append(config_def)
-+  config_size = 0
-+  if not only_js:
-+    config_def, config_size = handle_config_gypi(source_files['config.gypi'])
-+    definitions.append(config_def)
- 
-   # Emit result
-   definitions = ''.join(definitions)
-   initializers = '\n  '.join(initializers)
--  out = TEMPLATE.format(definitions, initializers, config_size)
-+  out = TEMPLATE.format(definitions, initializers, '0' if only_js else '1', config_size, 'Embedder' if only_js else '')
-   write_if_chaged(out, target)
- 
- 
-@@ -353,17 +357,21 @@ def main():
-   )
-   parser.add_argument('--target', help='output file')
-   parser.add_argument('--verbose', action='store_true', help='output file')
-+  parser.add_argument('--only-js', action='store_true', help='do not require or parse any config.gypi files')
-   parser.add_argument('sources', nargs='*', help='input files')
-   options = parser.parse_args()
-   global is_verbose
-   is_verbose = options.verbose
-   source_files = functools.reduce(SourceFileByExt, options.sources, {})
-   # Should have exactly 3 types: `.js`, `.py`, and `.gypi`
--  assert len(source_files) == 3
--  # Currently config.gypi is the only `.gypi` file allowed
--  assert source_files['.gypi'] == ['config.gypi']
--  source_files['config.gypi'] = source_files.pop('.gypi')[0]
--  JS2C(source_files, options.target)
-+  if options.only_js:
-+    assert len(source_files) == 1
-+  else:
-+    assert len(source_files) == 3
-+    # Currently config.gypi is the only `.gypi` file allowed
-+    assert source_files['.gypi'][0].endswith('config.gypi')
-+    source_files['config.gypi'] = source_files.pop('.gypi')[0]
-+  JS2C(source_files, options.target, options.only_js)
- 
- 
- if __name__ == "__main__":

+ 150 - 0
patches/node/build_modify_js2c_py_to_allow_injection_of_original-fs_and_custom_embedder_js.patch

@@ -0,0 +1,150 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Cheng Zhao <[email protected]>
+Date: Thu, 11 Apr 2019 17:16:13 +0900
+Subject: build: modify js2c.py to allow injection of original-fs and custom embedder JS
+
+This patch does two things:
+* Updates js2c.py so that original-fs is automatically created with
+support for streams by copying the file at build time and making a new
+builtin called "original-fs" and "original-fs/streams"
+* Updates js2c.py so that //electron can call it as part of its build
+process and provide embedder modules (electrons
+renderer/browser/worker/sandboxed bootstrap scripts).  These are loaded
+through LoadEmbedderJavaScriptSource()
+
+diff --git a/src/node_native_module.cc b/src/node_native_module.cc
+index 814adb620dcf8a459bbede11714e9ccd7f4e0b3e..04a706d15f2ab682f8d4ae972abee8986494f7a7 100644
+--- a/src/node_native_module.cc
++++ b/src/node_native_module.cc
+@@ -23,6 +23,7 @@ NativeModuleLoader NativeModuleLoader::instance_;
+ 
+ NativeModuleLoader::NativeModuleLoader() : config_(GetConfig()) {
+   LoadJavaScriptSource();
++  LoadEmbedderJavaScriptSource();
+ }
+ 
+ NativeModuleLoader* NativeModuleLoader::GetInstance() {
+diff --git a/src/node_native_module.h b/src/node_native_module.h
+index fabaea75686161f488a03349e07049a513b98fad..5a6b01dc12fb77d5f8c26a1153ead2a1b2a8d061 100644
+--- a/src/node_native_module.h
++++ b/src/node_native_module.h
+@@ -44,6 +44,7 @@ class NativeModuleLoader {
+ 
+   // Generated by tools/js2c.py as node_javascript.cc
+   void LoadJavaScriptSource();  // Loads data into source_
++  void LoadEmbedderJavaScriptSource();  // Loads embedder data into source_
+   UnionBytes GetConfig();       // Return data for config.gypi
+ 
+   bool Exists(const char* id);
+diff --git a/tools/js2c.py b/tools/js2c.py
+index 68152c499ce610d759b5abd659340957efb864d6..27c9ca57c3ad6188282d43ce1efdb53efd1161bc 100755
+--- a/tools/js2c.py
++++ b/tools/js2c.py
+@@ -187,13 +187,15 @@ namespace native_module {{
+ 
+ {0}
+ 
+-void NativeModuleLoader::LoadJavaScriptSource() {{
++void NativeModuleLoader::Load{4}JavaScriptSource() {{
+   {1}
+ }}
+ 
++#if {2}
+ UnionBytes NativeModuleLoader::GetConfig() {{
+-  return UnionBytes(config_raw, {2});  // config.gypi
++  return UnionBytes(config_raw, {3});  // config.gypi
+ }}
++#endif
+ 
+ }}  // namespace native_module
+ 
+@@ -243,8 +245,8 @@ def GetDefinition(var, source, step=30):
+   return definition, len(code_points)
+ 
+ 
+-def AddModule(filename, consts, macros, definitions, initializers):
+-  code = ReadFile(filename)
++def AddModule(filename, consts, macros, definitions, initializers, FileReadFn=ReadFile):
++  code = FileReadFn(filename)
+   code = ExpandConstants(code, consts)
+   code = ExpandMacros(code, macros)
+   name = NormalizeFileName(filename)
+@@ -256,7 +258,7 @@ def AddModule(filename, consts, macros, definitions, initializers):
+   initializers.append(initializer)
+ 
+ def NormalizeFileName(filename):
+-  split = filename.split(os.path.sep)
++  split = os.path.normpath(filename).split(os.path.sep)
+   if split[0] == 'deps':
+     split = ['internal'] + split
+   else:  # `lib/**/*.js` so drop the 'lib' part
+@@ -273,9 +275,9 @@ def NormalizeFileName(filename):
+ 
+   return os.path.splitext(filename)[0]
+ 
+-def JS2C(source_files, target):
++def JS2C(source_files, target, only_js):
+   # Process input from all *macro.py files
+-  consts, macros = ReadMacros(source_files['.py'])
++  consts, macros = ReadMacros([] if only_js else source_files['.py'])
+ 
+   # Build source code lines
+   definitions = []
+@@ -283,14 +285,26 @@ def JS2C(source_files, target):
+ 
+   for filename in source_files['.js']:
+     AddModule(filename, consts, macros, definitions, initializers)
+-
+-  config_def, config_size = handle_config_gypi(source_files['config.gypi'])
+-  definitions.append(config_def)
++    # Electron: Expose fs module without asar support.
++    if filename == 'lib/fs.js':
++      # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
++      # dependency. So to expose the unmodified Node 'fs' functionality here,
++      # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
++      # copies to depend on each other instead of on our asarified 'fs' code.
++      # See https://github.com/electron/electron/pull/16028 for more.
++      AddModule('lib/original-fs.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/streams')", "require('internal/original-fs/streams')"))
++    elif filename == 'lib/internal/fs/streams.js':
++      AddModule('lib/internal/original-fs/streams.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
++
++  config_size = 0
++  if not only_js:
++    config_def, config_size = handle_config_gypi(source_files['config.gypi'])
++    definitions.append(config_def)
+ 
+   # Emit result
+   definitions = ''.join(definitions)
+   initializers = '\n  '.join(initializers)
+-  out = TEMPLATE.format(definitions, initializers, config_size)
++  out = TEMPLATE.format(definitions, initializers, '0' if only_js else '1', config_size, 'Embedder' if only_js else '')
+   write_if_chaged(out, target)
+ 
+ 
+@@ -343,17 +357,21 @@ def main():
+   )
+   parser.add_argument('--target', help='output file')
+   parser.add_argument('--verbose', action='store_true', help='output file')
++  parser.add_argument('--only-js', action='store_true', help='do not require or parse any config.gypi files')
+   parser.add_argument('sources', nargs='*', help='input files')
+   options = parser.parse_args()
+   global is_verbose
+   is_verbose = options.verbose
+   source_files = functools.reduce(SourceFileByExt, options.sources, {})
+   # Should have exactly 3 types: `.js`, `.py`, and `.gypi`
+-  assert len(source_files) == 3
+-  # Currently config.gypi is the only `.gypi` file allowed
+-  assert source_files['.gypi'] == ['config.gypi']
+-  source_files['config.gypi'] = source_files.pop('.gypi')[0]
+-  JS2C(source_files, options.target)
++  if options.only_js:
++    assert len(source_files) == 1
++  else:
++    assert len(source_files) == 3
++    # Currently config.gypi is the only `.gypi` file allowed
++    assert source_files['.gypi'][0].endswith('config.gypi')
++    source_files['config.gypi'] = source_files.pop('.gypi')[0]
++  JS2C(source_files, options.target, options.only_js)
+ 
+ 
+ if __name__ == "__main__":

+ 0 - 1
patches/node/chore_add_ability_to_prevent_warn_non_context-aware_native_modules.patch

@@ -4,7 +4,6 @@ Date: Wed, 22 May 2019 13:34:18 -0700
 Subject: chore: add ability to prevent / warn non context-aware native modules
  being loaded
 
-
 diff --git a/src/env.h b/src/env.h
 index b97d024a0e8396ebd21b96bd7f1a9473abfefe9b..23ad7569d31bc534247ed373819bc291a4f4bfe6 100644
 --- a/src/env.h

+ 0 - 40
patches/node/chore_fix_js2c_hacks_for_original-fs.patch

@@ -1,40 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Mon, 15 Jul 2019 10:26:42 -0700
-Subject: chore: fix js2c hacks for original-fs
-
-
-diff --git a/tools/js2c.py b/tools/js2c.py
-index c7a90f6eaeb9f5789ffb86c070132551f4275354..4b0b631c46901c8ff01341c8d7f63c13008a5798 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -245,8 +245,8 @@ def GetDefinition(var, source, step=30):
-   return definition, len(code_points)
- 
- 
--def AddModule(filename, consts, macros, definitions, initializers):
--  code = ReadFile(filename)
-+def AddModule(filename, consts, macros, definitions, initializers, FileReadFn=ReadFile):
-+  code = FileReadFn(filename)
-   code = ExpandConstants(code, consts)
-   code = ExpandMacros(code, macros)
-   name = NormalizeFileName(filename)
-@@ -286,15 +286,15 @@ def JS2C(source_files, target, only_js):
-   for filename in source_files['.js']:
-     AddModule(filename, consts, macros, definitions, initializers)
-     # Electron: Expose fs module without asar support.
--    if filename == 'fs.js':
-+    if filename == 'lib/fs.js':
-       # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
-       # dependency. So to expose the unmodified Node 'fs' functionality here,
-       # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
-       # copies to depend on each other instead of on our asarified 'fs' code.
-       # See https://github.com/electron/electron/pull/16028 for more.
--      AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
-+      AddModule('lib/original-fs.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/streams')", "require('internal/original-fs/streams')"))
-     elif filename == 'internal/fs/streams.js':
--      AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
-+      AddModule('lib/internal/original-fs/streams.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
- 
-   config_size = 0
-   if not only_js:

+ 0 - 1
patches/node/chore_re-add_compileandcall_this_should_be_added_as_a_helper_in.patch

@@ -4,7 +4,6 @@ Date: Fri, 28 Jun 2019 17:13:54 -0700
 Subject: chore: re-add CompileAndCall, this should be added as a helper in
  electron
 
-
 diff --git a/src/node_native_module_env.cc b/src/node_native_module_env.cc
 index 31536000fc8d2f9ce9589ef8e31cb55439fbd28d..6cb49b3b6def15a38ce1ba51da11af2567cb84ec 100644
 --- a/src/node_native_module_env.cc

+ 0 - 19
patches/node/chore_remove_sysinfo-memory_from_build_files.patch

@@ -1,19 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Mon, 15 Jul 2019 11:11:52 -0700
-Subject: chore: remove sysinfo-memory from build files
-
-Refs: https://github.com/libuv/libuv/commit/3a1be725326bfe637355c461bd77993c0fda2173
-
-diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn
-index 7370980c52ea03ca02eae3488930432f1857c6fb..4674bdd48b4bfc9b7152377b8cd0984d1cf42562 100644
---- a/deps/uv/BUILD.gn
-+++ b/deps/uv/BUILD.gn
-@@ -170,7 +170,6 @@ static_library("uv") {
-       "src/unix/linux-syscalls.h",
-       "src/unix/procfs-exepath.c",
-       "src/unix/sysinfo-loadavg.c",
--      "src/unix/sysinfo-memory.c",
-     ]
-     libs += [
-       "dl",

+ 0 - 141
patches/node/chore_update_gn_files_for_file_movement.patch

@@ -1,141 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Shelley Vohr <[email protected]>
-Date: Fri, 21 Jun 2019 10:23:11 -0700
-Subject: chore: update GN files for file movement
-
-
-diff --git a/BUILD.gn b/BUILD.gn
-index b5912d4d671db27761be4c6283ed5e21818c5b04..c722975a4bc82b46192b0e72f4995fce243fa5bf 100644
---- a/BUILD.gn
-+++ b/BUILD.gn
-@@ -78,14 +78,14 @@ chdir_action("node_js2c") {
- 
-   macro_inputs = []
-   if (!node_use_dtrace && !node_use_etw) {
--    macro_inputs += [ "src/notrace_macros.py" ]
-+    macro_inputs += [ "tools/js2c_macros/notrace_macros.py" ]
-   }
-   if (node_debug_lib) {
--    macro_inputs += [ "tools/nodcheck_macros.py" ]
-+    macro_inputs += [ "tools/js2c_macros/nodcheck_macros.py" ]
-   } else {
--    macro_inputs += [ "tools/dcheck_macros.py" ]
-+    macro_inputs += [ "tools/js2c_macros/dcheck_macros.py" ]
-   }
--  macro_inputs += [ "tools/check_macros.py" ]
-+  macro_inputs += [ "tools/js2c_macros/check_macros.py" ]
- 
-   config_gypi = [ "$target_gen_dir/config.gypi" ]
- 
-diff --git a/filenames.json b/filenames.json
-index 86d89280e74d7365ab2782517fb779fc072bf0bf..edb0b215088118f567c5ad5e5969d1eb5ef661a3 100644
---- a/filenames.json
-+++ b/filenames.json
-@@ -67,11 +67,11 @@
-     }
-   ],
-   "library_files": [
--    "lib/internal/bootstrap/primordials.js",
--    "lib/internal/bootstrap/cache.js",
-+    "lib/internal/bootstrap/environment.js",
-     "lib/internal/bootstrap/loaders.js",
-     "lib/internal/bootstrap/node.js",
-     "lib/internal/bootstrap/pre_execution.js",
-+    "lib/internal/per_context/primordials.js",
-     "lib/internal/per_context/setup.js",
-     "lib/internal/per_context/domexception.js",
-     "lib/async_hooks.js",
-@@ -210,7 +210,6 @@
-     "lib/internal/process/worker_thread_only.js",
-     "lib/internal/process/report.js",
-     "lib/internal/process/task_queues.js",
--    "lib/internal/profiler.js",
-     "lib/internal/querystring.js",
-     "lib/internal/readline.js",
-     "lib/internal/repl.js",
-@@ -264,9 +263,16 @@
-     "deps/node-inspect/lib/internal/inspect_client.js",
-     "deps/node-inspect/lib/internal/inspect_repl.js",
-     "deps/acorn/acorn/dist/acorn.js",
--    "deps/acorn/acorn-walk/dist/walk.js"
-+    "deps/acorn/acorn-walk/dist/walk.js",
-+    "deps/acorn-plugins/acorn-bigint/index.js",
-+    "deps/acorn-plugins/acorn-class-fields/index.js",
-+    "deps/acorn-plugins/acorn-numeric-separator/index.js",
-+    "deps/acorn-plugins/acorn-private-class-elements/index.js",
-+    "deps/acorn-plugins/acorn-private-methods/index.js",
-+    "deps/acorn-plugins/acorn-static-class-features/index.js"
-   ],
-   "node_sources": [
-+    "src/api/async_resource.cc",
-     "src/api/callback.cc",
-     "src/api/encoding.cc",
-     "src/api/environment.cc",
-@@ -305,9 +311,11 @@
-     "src/node_http_parser_traditional.cc",
-     "src/node_http2.cc",
-     "src/node_i18n.cc",
-+    "src/node_main_instance.cc",
-     "src/node_messaging.cc",
-     "src/node_metadata.cc",
-     "src/node_native_module.cc",
-+    "src/node_native_module_env.cc",
-     "src/node_options.cc",
-     "src/node_os.cc",
-     "src/node_perf.cc",
-@@ -383,16 +391,17 @@
-     "src/node_http2_state.h",
-     "src/node_i18n.h",
-     "src/node_internals.h",
-+    "src/node_main_instance.h",
-     "src/node_messaging.h",
-     "src/node_metadata.h",
-     "src/node_mutex.h",
-     "src/node_native_module.h",
-+    "src/node_native_module_env.h",
-     "src/node_object_wrap.h",
-     "src/node_options.h",
-     "src/node_options-inl.h",
-     "src/node_perf.h",
-     "src/node_perf_common.h",
--    "src/node_persistent.h",
-     "src/node_platform.h",
-     "src/node_process.h",
-     "src/node_revert.h",
-diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn
-index 0e1a5a22315989d5b0b4b6462330b3d693a43228..ebf5e610d675e53ad4af40e92d5217995ed8f577 100644
---- a/src/inspector/BUILD.gn
-+++ b/src/inspector/BUILD.gn
-@@ -69,9 +69,10 @@ action("protocol_generated_sources") {
-   inputs = [
-     "$target_gen_dir/node_protocol_config.json",
-     "$target_gen_dir/node_protocol.json",
-+    "$inspector_protocol_dir/lib/base_string_adapter_cc.template",
-+    "$inspector_protocol_dir/lib/base_string_adapter_h.template",
-     "$inspector_protocol_dir/lib/Allocator_h.template",
-     "$inspector_protocol_dir/lib/Array_h.template",
--    "$inspector_protocol_dir/lib/Collections_h.template",
-     "$inspector_protocol_dir/lib/DispatcherBase_cpp.template",
-     "$inspector_protocol_dir/lib/DispatcherBase_h.template",
-     "$inspector_protocol_dir/lib/ErrorSupport_cpp.template",
-diff --git a/tools/js2c.py b/tools/js2c.py
-index 3e6ad7d5e12888e26a2b4eaa2eff7e2421b630f7..87cca4eaf7c909e1f871287d7f019f701a05dd0f 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -284,14 +284,14 @@ def JS2C(source_files, target):
-   for filename in source_files['.js']:
-     AddModule(filename, consts, macros, definitions, initializers)
-     # Electron: Expose fs module without asar support.
--    if name == 'fs.js':
-+    if filename == 'fs.js':
-       # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
-       # dependency. So to expose the unmodified Node 'fs' functionality here,
-       # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
-       # copies to depend on each other instead of on our asarified 'fs' code.
-       # See https://github.com/electron/electron/pull/16028 for more.
-       AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
--    elif name == 'internal/fs/streams.js':
-+    elif filename == 'internal/fs/streams.js':
-       AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
- 
-   config_def, config_size = handle_config_gypi(source_files['config.gypi'])

+ 0 - 27
patches/node/feat_add_original-fs_module.patch

@@ -1,27 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Cheng Zhao <[email protected]>
-Date: Thu, 11 Apr 2019 17:16:13 +0900
-Subject: feat: add original-fs module
-
-
-diff --git a/tools/js2c.py b/tools/js2c.py
-index 68152c499ce610d759b5abd659340957efb864d6..3e6ad7d5e12888e26a2b4eaa2eff7e2421b630f7 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -283,6 +283,16 @@ def JS2C(source_files, target):
- 
-   for filename in source_files['.js']:
-     AddModule(filename, consts, macros, definitions, initializers)
-+    # Electron: Expose fs module without asar support.
-+    if name == 'fs.js':
-+      # Node's 'fs' and 'internal/fs/streams' have a lazy-loaded circular
-+      # dependency. So to expose the unmodified Node 'fs' functionality here,
-+      # we have to copy both 'fs' *and* 'internal/fs/streams' and modify the
-+      # copies to depend on each other instead of on our asarified 'fs' code.
-+      # See https://github.com/electron/electron/pull/16028 for more.
-+      AddModule('original-fs', lines.replace("require('internal/fs/streams')", "require('original-fs/streams')"))
-+    elif name == 'internal/fs/streams.js':
-+      AddModule('original-fs/streams', lines.replace("require('fs')", "require('original-fs')"))
- 
-   config_def, config_size = handle_config_gypi(source_files['config.gypi'])
-   definitions.append(config_def)

+ 0 - 20
patches/node/fix_don_t_define_building_v8_shared_in_component_builds_109.patch

@@ -1,20 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Jeremy Apthorp <[email protected]>
-Date: Wed, 3 Jul 2019 09:58:01 -0700
-Subject: fix: don't define BUILDING_V8_SHARED in component builds (#109)
-
-
-diff --git a/BUILD.gn b/BUILD.gn
-index 77b2ed2978682c1a171346339ded5f2638c27fd9..f27c13b312a60d9b5c7ea0948b347ab0936ab3f8 100644
---- a/BUILD.gn
-+++ b/BUILD.gn
-@@ -153,9 +153,6 @@ config("node_internal_config") {
-   }
-   if (is_component_build) {
-     defines += [
--      "BUILDING_V8_SHARED",
--      "BUILDING_V8_PLATFORM_SHARED",
--      "BUILDING_V8_BASE_SHARED",
-       "NODE_SHARED_MODE",
-     ]
-   }

+ 0 - 19
patches/node/fix_ensure_js2c_maps_internal-fs_streams.patch

@@ -1,19 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Mon, 15 Jul 2019 17:44:47 -0700
-Subject: fix: ensure js2c maps internal-fs/streams
-
-
-diff --git a/tools/js2c.py b/tools/js2c.py
-index 4e63ceefe1ff41d2105c3d71980c4f5f5ad11a30..27c9ca57c3ad6188282d43ce1efdb53efd1161bc 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -293,7 +293,7 @@ def JS2C(source_files, target, only_js):
-       # copies to depend on each other instead of on our asarified 'fs' code.
-       # See https://github.com/electron/electron/pull/16028 for more.
-       AddModule('lib/original-fs.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('internal/fs/streams')", "require('internal/original-fs/streams')"))
--    elif filename == 'internal/fs/streams.js':
-+    elif filename == 'lib/internal/fs/streams.js':
-       AddModule('lib/internal/original-fs/streams.js', consts, macros, definitions, initializers, lambda _: ReadFile(filename).replace("require('fs')", "require('original-fs')"))
- 
-   config_size = 0

+ 0 - 31
patches/node/fix_export_libuv_symbols_73.patch

@@ -1,31 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Jeremy Apthorp <[email protected]>
-Date: Thu, 11 Oct 2018 16:24:57 -0700
-Subject: fix: export libuv symbols (#73)
-
-Closes electron/electron#15075
-
-diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn
-index b62fac6738ae74788faa6e5dcc705b81d8325ece..7370980c52ea03ca02eae3488930432f1857c6fb 100644
---- a/deps/uv/BUILD.gn
-+++ b/deps/uv/BUILD.gn
-@@ -29,6 +29,9 @@ static_library("uv") {
- 
-   defines = []
- 
-+  # This only has an effect on Windows, where it will cause libuv's symbols to be exported in node.lib
-+  defines += [ "BUILDING_UV_SHARED=1" ]
-+
-   cflags_c = [
-     "-Wno-bitwise-op-parentheses",
-     "-Wno-implicit-function-declaration",
-@@ -180,9 +183,4 @@ static_library("uv") {
-       "src/unix/kqueue.c",
-     ]
-   }
--  if (is_component_build && is_win) {
--    defines += [
--      "BUILDING_UV_SHARED=1",
--    ]
--  }
- }

+ 0 - 1
patches/node/fix_expose_tracing_agent_and_use_tracing_tracingcontroller_instead.patch

@@ -4,7 +4,6 @@ Date: Fri, 26 Oct 2018 15:35:13 +1100
 Subject: fix: expose tracing::Agent and use tracing::TracingController instead
  of v8::TracingController
 
-
 diff --git a/src/api/environment.cc b/src/api/environment.cc
 index eeeef7442d834ace51a6c6be11058d21e4995a99..bfc849d362a18bc7cd499584a439a1d29f0864f8 100644
 --- a/src/api/environment.cc

+ 0 - 19
patches/node/fix_make_js2c_normalize_paths_before_splitting_on_separaters.patch

@@ -1,19 +0,0 @@
-From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
-From: Samuel Attard <[email protected]>
-Date: Mon, 15 Jul 2019 11:41:22 -0700
-Subject: fix: make js2c normalize paths before splitting on separaters
-
-
-diff --git a/tools/js2c.py b/tools/js2c.py
-index 4b0b631c46901c8ff01341c8d7f63c13008a5798..4e63ceefe1ff41d2105c3d71980c4f5f5ad11a30 100755
---- a/tools/js2c.py
-+++ b/tools/js2c.py
-@@ -258,7 +258,7 @@ def AddModule(filename, consts, macros, definitions, initializers, FileReadFn=Re
-   initializers.append(initializer)
- 
- def NormalizeFileName(filename):
--  split = filename.split(os.path.sep)
-+  split = os.path.normpath(filename).split(os.path.sep)
-   if split[0] == 'deps':
-     split = ['internal'] + split
-   else:  # `lib/**/*.js` so drop the 'lib' part