From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 From: Jeremy Apthorp 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/BUILD.gn b/BUILD.gn index 1ed186b597eece7c34cb69c8e1e20870555a040d..2ce1e8a7dcca2ba153d387d11970c72b5f43c167 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1,14 +1,406 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +import("//v8/gni/v8.gni") +import("//electron/js2c_toolchain.gni") +import("electron_node.gni") -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. +declare_args() { + # Enable the V8 inspector protocol for use with node. + node_enable_inspector = true -import("unofficial.gni") + # Build node with SSL support. + # The variable is called "openssl" for parity with node's GYP build. + node_use_openssl = true -node_gn_build("node") { + # Use the specified path to system CA (PEM format) in addition to + # the BoringSSL supplied CA store or compiled-in Mozilla CA copy. + node_openssl_system_ca_path = "" + + # Initialize v8 platform during node.js startup. + # NB. this must be turned off in Electron, because Electron initializes the + # v8 platform itself. + node_use_v8_platform = false + + # Build with DTrace support. + node_use_dtrace = false + + # Build with ETW support. + node_use_etw = false + + # Build JavaScript in lib/ with DCHECK macros. + node_debug_lib = false + + # Custom build tag. + node_tag = "" + + # V8 options to pass, see `node --v8-options` for examples + node_v8_options = "" + + # Provide a custom URL prefix for the `process.release` properties + # `sourceUrl` and `headersUrl`. When compiling a release build, this will + # default to https://nodejs.org/download/release/') + node_release_urlbase = "" + + # Allows downstream packagers (eg. Linux distributions) to build Electron against system shared libraries. + use_system_cares = false + use_system_nghttp2 = false + use_system_llhttp = false + use_system_histogram = false +} + +if (is_linux) { + import("//build/config/linux/pkg_config.gni") + if (use_system_cares) { + pkg_config("cares") { + packages = [ "libcares" ] + } + } + if (use_system_nghttp2) { + pkg_config("nghttp2") { + packages = [ "libnghttp2" ] + } + } +} + +assert(!node_use_dtrace, "node_use_dtrace not supported in GN") +assert(!node_use_etw, "node_use_etw not supported in GN") + +assert(!node_enable_inspector || node_use_openssl, + "node_enable_inspector requires node_use_openssl") + +config("node_internals") { + defines = [ "NODE_WANT_INTERNALS=1" ] +} + +node_files = read_file("filenames.json", "json") +library_files = node_files.library_files +fs_files = node_files.fs_files +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 = library_files + outputs = [ + "$target_gen_dir/js2c_inputs/{{source_target_relative}}", + ] +} + +action("node_js2c_original_fs") { + script = "tools/generate_original_fs.py" + inputs = fs_files + outputs = [] + foreach(file, fs_files + original_fs_files) { + outputs += ["$target_gen_dir/js2c_inputs/$file"] + } + + args = [rebase_path("$target_gen_dir/js2c_inputs")] + fs_files +} + +action("node_js2c_exec") { + deps = [ + "//electron:generate_config_gypi", + ":node_js2c_original_fs", + ":node_js2c_inputs", + ":node_js2c($electron_js2c_toolchain)" + ] + config_gypi = [ "$root_gen_dir/config.gypi" ] + inputs = library_files + get_target_outputs(":node_js2c_original_fs") + config_gypi + outputs = [ + "$target_gen_dir/node_javascript.cc", + ] + + script = "//electron/build/run-in-dir.py" + out_dir = get_label_info(":anything($electron_js2c_toolchain)", "root_out_dir") + args = [ rebase_path("$target_gen_dir/js2c_inputs"), rebase_path("$out_dir/node_js2c") ] + + rebase_path(outputs) + library_files + fs_files + original_fs_files + rebase_path(config_gypi) +} + +config("node_features") { + defines = [] + if (node_enable_inspector) { + defines += [ "HAVE_INSPECTOR=1" ] + } else { + defines += [ "HAVE_INSPECTOR=0" ] + } + if (node_use_openssl) { + defines += [ "HAVE_OPENSSL=1" ] + } else { + defines += [ "HAVE_OPENSSL=0" ] + } + if (v8_enable_i18n_support) { + defines += [ "NODE_HAVE_I18N_SUPPORT=1" ] + } else { + defines += [ "NODE_HAVE_I18N_SUPPORT=0" ] + } + if (node_use_v8_platform) { + defines += [ "NODE_USE_V8_PLATFORM=1" ] + } else { + defines += [ "NODE_USE_V8_PLATFORM=0" ] + } +} + +config("node_lib_config") { + include_dirs = [ "src" ] + + cflags = [ + "-Wno-shadow", + # FIXME(deepak1556): include paths should be corrected, + # refer https://docs.google.com/presentation/d/1oxNHaVjA9Gn_rTzX6HIpJHP7nXRua_0URXxxJ3oYRq0/edit#slide=id.g71ecd450e_2_702 + "-Wno-microsoft-include", + ] + + configs = [ ":node_features" ] + + if (is_debug) { + defines = [ "DEBUG" ] + } +} + +config("node_internal_config") { + visibility = [ + ":*", + "src/inspector:*", + ] + defines = [ + "NODE_WANT_INTERNALS=1", + "NODE_IMPLEMENTATION", + ] + if (node_module_version != "") { + defines += [ "NODE_EMBEDDER_MODULE_VERSION=" + node_module_version ] + } + if (is_component_build) { + defines += [ + "NODE_SHARED_MODE", + ] + } + + if (target_cpu == "x86") { + node_arch = "ia32" + } else { + node_arch = target_cpu + } + defines += [ "NODE_ARCH=\"$node_arch\"" ] + + if (target_os == "win") { + node_platform = "win32" + } else if (target_os == "mac") { + node_platform = "darwin" + } else { + node_platform = target_os + } + defines += [ "NODE_PLATFORM=\"$node_platform\"" ] + + 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\"", + "EVP_CTRL_CCM_SET_TAG=EVP_CTRL_GCM_SET_TAG", + ] + } +} + +executable("overlapped-checker") { + sources = [] + if (is_win) { + sources += [ "test/overlapped-checker/main_win.c" ] + } else { + sources += [ "test/overlapped-checker/main_unix.c" ] + } +} + +if (current_toolchain == electron_js2c_toolchain) { + executable("node_js2c") { + defines = [] + sources = [ + "tools/js2c.cc", + "tools/executable_wrapper.h", + "src/embedded_data.cc", + "src/embedded_data.h", + ] + include_dirs = [ "tools", "src" ] + deps = [ + "deps/simdutf($electron_js2c_toolchain)", + "deps/uv($electron_js2c_toolchain)", + "//v8" + ] + + if (!is_win) { + defines += [ "NODE_JS2C_USE_STRING_LITERALS" ] + } + if (is_debug) { + cflags_cc = [ "-g", "-O0" ] + defines += [ "DEBUG" ] + } + } +} + +component("node_lib") { + deps = [ + ":node_js2c_exec", + "deps/googletest:gtest", + "deps/ada", + "deps/base64", + "deps/simdutf", + "deps/uvwasi", + "//third_party/zlib", + "//third_party/brotli:dec", + "//third_party/brotli:enc", + "//v8:v8_libplatform", + ] + if (use_system_cares) { + configs += [ ":cares" ] + } else { + deps += [ "deps/cares" ] + } + if (use_system_nghttp2) { + configs += [ ":nghttp2" ] + } else { + deps += [ "deps/nghttp2" ] + } + public_deps = [ + "deps/uv", + "//electron:electron_js2c", + "//v8", + ] + configs += [ ":node_internal_config" ] + public_configs = [ ":node_lib_config" ] + include_dirs = [ + "src", + "deps/postject" + ] + libs = [] + if (use_system_llhttp) { + libs += [ "llhttp" ] + } else { + deps += [ "deps/llhttp" ] + } + if (use_system_histogram) { + libs += [ "hdr_histogram" ] + include_dirs += [ "/usr/include/hdr" ] + } else { + deps += [ "deps/histogram" ] + } + frameworks = [] + cflags_cc = [ + "-Wno-deprecated-declarations", + "-Wno-implicit-fallthrough", + "-Wno-return-type", + "-Wno-sometimes-uninitialized", + "-Wno-string-plus-int", + "-Wno-unused-function", + "-Wno-unused-label", + "-Wno-unused-private-field", + "-Wno-unused-variable", + ] + + if (v8_enable_i18n_support) { + deps += [ "//third_party/icu" ] + } + + sources = node_files.node_sources + sources += [ + "$root_gen_dir/electron_natives.cc", + "$target_gen_dir/node_javascript.cc", + "src/node_snapshot_stub.cc", + ] + + if (is_win) { + libs += [ "psapi.lib" ] + } + if (is_mac) { + frameworks += [ "CoreFoundation.framework" ] + } + + if (node_enable_inspector) { + sources += [ + "src/inspector_agent.cc", + "src/inspector_agent.h", + "src/inspector_io.cc", + "src/inspector_io.h", + "src/inspector_js_api.cc", + "src/inspector_profiler.cc", + "src/inspector_socket.cc", + "src/inspector_socket.h", + "src/inspector_socket_server.cc", + "src/inspector_socket_server.h", + ] + deps += [ "src/inspector" ] + } + + if (node_use_openssl) { + deps += [ "//third_party/boringssl" ] + sources += [ + "src/crypto/crypto_aes.cc", + "src/crypto/crypto_aes.h", + "src/crypto/crypto_bio.cc", + "src/crypto/crypto_bio.h", + "src/crypto/crypto_cipher.cc", + "src/crypto/crypto_cipher.h", + "src/crypto/crypto_clienthello-inl.h", + "src/crypto/crypto_clienthello.cc", + "src/crypto/crypto_clienthello.h", + "src/crypto/crypto_common.cc", + "src/crypto/crypto_common.h", + "src/crypto/crypto_context.cc", + "src/crypto/crypto_context.h", + "src/crypto/crypto_dh.cc", + "src/crypto/crypto_dh.h", + "src/crypto/crypto_dsa.cc", + "src/crypto/crypto_dsa.h", + "src/crypto/crypto_ec.cc", + "src/crypto/crypto_ec.h", + "src/crypto/crypto_groups.h", + "src/crypto/crypto_hash.cc", + "src/crypto/crypto_hash.h", + "src/crypto/crypto_hkdf.cc", + "src/crypto/crypto_hkdf.h", + "src/crypto/crypto_hmac.cc", + "src/crypto/crypto_hmac.h", + "src/crypto/crypto_keygen.cc", + "src/crypto/crypto_keygen.h", + "src/crypto/crypto_keys.cc", + "src/crypto/crypto_keys.h", + "src/crypto/crypto_pbkdf2.cc", + "src/crypto/crypto_pbkdf2.h", + "src/crypto/crypto_random.cc", + "src/crypto/crypto_random.h", + "src/crypto/crypto_rsa.cc", + "src/crypto/crypto_rsa.h", + "src/crypto/crypto_scrypt.cc", + "src/crypto/crypto_scrypt.h", + "src/crypto/crypto_sig.cc", + "src/crypto/crypto_sig.h", + "src/crypto/crypto_spkac.cc", + "src/crypto/crypto_spkac.h", + "src/crypto/crypto_timing.cc", + "src/crypto/crypto_timing.h", + "src/crypto/crypto_tls.cc", + "src/crypto/crypto_tls.h", + "src/crypto/crypto_util.cc", + "src/crypto/crypto_util.h", + "src/crypto/crypto_x509.cc", + "src/crypto/crypto_x509.h", + "src/node_crypto.cc", + "src/node_crypto.h", + ] + cflags_cc += [ "-Wno-sign-compare" ] + } } diff --git a/deps/ada/BUILD.gn b/deps/ada/BUILD.gn index e92ac3a3beac143dced2efb05304ed8ba832b067..1ce69e9deba1a9b191e8d95f4c82e0ec1f7b50ca 100644 --- a/deps/ada/BUILD.gn +++ b/deps/ada/BUILD.gn @@ -1,14 +1,12 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +import("//v8/gni/v8.gni") -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. +config("ada_config") { + include_dirs = [ "." ] +} -import("unofficial.gni") +static_library("ada") { + include_dirs = [ "." ] + sources = [ "ada.cpp" ] -ada_gn_build("ada") { + public_configs = [ ":ada_config" ] } diff --git a/deps/base64/unofficial.gni b/deps/base64/unofficial.gni index 0e69d7383762f6b81c5b57698aa9d121d5a9c401..35bbeb37acc7ccb14b4b8a644ec3d4c76ca5c61c 100644 --- a/deps/base64/unofficial.gni +++ b/deps/base64/unofficial.gni @@ -12,6 +12,10 @@ template("base64_gn_build") { } } + # FIXME(zcbenz): ASM on win/x86 compiles perfectly in upstream Node, figure + # out why it does not work in Electron's build configs. + support_x86_asm = current_cpu == "x64" || (current_cpu == "x86" && !is_win) + config("base64_internal_config") { include_dirs = [ "base64/lib" ] if (is_component_build) { @@ -19,7 +23,7 @@ template("base64_gn_build") { } else { defines = [] } - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { defines += [ "HAVE_SSSE3=1", "HAVE_SSE41=1", @@ -69,7 +73,7 @@ template("base64_gn_build") { source_set("base64_ssse3") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/ssse3/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-mssse3" ] } @@ -79,7 +83,7 @@ template("base64_gn_build") { source_set("base64_sse41") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/sse41/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-msse4.1" ] } @@ -89,7 +93,7 @@ template("base64_gn_build") { source_set("base64_sse42") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/sse42/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-msse4.2" ] } @@ -99,7 +103,7 @@ template("base64_gn_build") { source_set("base64_avx") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/avx/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-mavx" ] } else if (is_win) { @@ -111,7 +115,7 @@ template("base64_gn_build") { source_set("base64_avx2") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/avx2/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-mavx2" ] } else if (is_win) { @@ -123,7 +127,7 @@ template("base64_gn_build") { source_set("base64_avx512") { configs += [ ":base64_internal_config" ] sources = [ "base64/lib/arch/avx512/codec.c" ] - if (current_cpu == "x86" || current_cpu == "x64") { + if (support_x86_asm) { if (is_clang || !is_win) { cflags_c = [ "-mavx512vl", diff --git a/deps/cares/BUILD.gn b/deps/cares/BUILD.gn index ac19ac73ed1e24c61cb679f3851685b79cfc8b39..3f253daee0f9b1faa50857f61d76de001bd8947e 100644 --- a/deps/cares/BUILD.gn +++ b/deps/cares/BUILD.gn @@ -1,14 +1,163 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("cares_config") { + include_dirs = [ "include", "src/lib" ] +} +static_library("cares") { + defines = [ "CARES_STATICLIB" ] + include_dirs = [ "include" ] + public_configs = [ ":cares_config" ] + + libs = [] + cflags_c = [ + "-Wno-logical-not-parentheses", + "-Wno-implicit-fallthrough", + "-Wno-sign-compare", + ] + + sources = [ + "include/ares.h", + "include/ares_dns.h", + "include/ares_dns_record.h", + "include/ares_nameser.h", + "include/ares_rules.h", + "include/ares_version.h", + "src/lib/ares__addrinfo2hostent.c", + "src/lib/ares__addrinfo_localhost.c", + "src/lib/ares__buf.c", + "src/lib/ares__buf.h", + "src/lib/ares__close_sockets.c", + "src/lib/ares__hosts_file.c", + "src/lib/ares__htable.c", + "src/lib/ares__htable.h", + "src/lib/ares__htable_asvp.c", + "src/lib/ares__htable_asvp.h", + "src/lib/ares__htable_strvp.c", + "src/lib/ares__htable_strvp.h", + "src/lib/ares__htable_szvp.c", + "src/lib/ares__htable_szvp.h", + "src/lib/ares__iface_ips.c", + "src/lib/ares__iface_ips.h", + "src/lib/ares__llist.c", + "src/lib/ares__llist.h", + "src/lib/ares__parse_into_addrinfo.c", + "src/lib/ares__slist.c", + "src/lib/ares__slist.h", + "src/lib/ares__socket.c", + "src/lib/ares__sortaddrinfo.c", + "src/lib/ares__threads.c", + "src/lib/ares__threads.h", + "src/lib/ares__timeval.c", + "src/lib/ares_android.c", + "src/lib/ares_android.h", + "src/lib/ares_cancel.c", + "src/lib/ares_create_query.c", + "src/lib/ares_data.c", + "src/lib/ares_data.h", + "src/lib/ares_destroy.c", + "src/lib/ares_dns_mapping.c", + "src/lib/ares_dns_name.c", + "src/lib/ares_dns_parse.c", + "src/lib/ares_dns_record.c", + "src/lib/ares_dns_private.h", + "src/lib/ares_dns_write.c", + "src/lib/ares_event.h", + "src/lib/ares_event_win32.h", + "src/lib/ares_event_epoll.c", + "src/lib/ares_event_kqueue.c", + "src/lib/ares_event_poll.c", + "src/lib/ares_event_select.c", + "src/lib/ares_event_thread.c", + "src/lib/ares_event_wake_pipe.c", + "src/lib/ares_event_win32.c", + "src/lib/ares_expand_name.c", + "src/lib/ares_expand_string.c", + "src/lib/ares_fds.c", + "src/lib/ares_free_hostent.c", + "src/lib/ares_free_string.c", + "src/lib/ares_freeaddrinfo.c", + "src/lib/ares_getaddrinfo.c", + "src/lib/ares_getenv.c", + "src/lib/ares_getenv.h", + "src/lib/ares_gethostbyaddr.c", + "src/lib/ares_gethostbyname.c", + "src/lib/ares_getnameinfo.c", + "src/lib/ares_getsock.c", + "src/lib/ares_inet_net_pton.h", + "src/lib/ares_init.c", + "src/lib/ares_library_init.c", + "src/lib/ares_ipv6.h", + "src/lib/ares_math.c", + "src/lib/ares_options.c", + "src/lib/ares_parse_a_reply.c", + "src/lib/ares_parse_aaaa_reply.c", + "src/lib/ares_parse_caa_reply.c", + "src/lib/ares_parse_mx_reply.c", + "src/lib/ares_parse_naptr_reply.c", + "src/lib/ares_parse_ns_reply.c", + "src/lib/ares_parse_ptr_reply.c", + "src/lib/ares_parse_soa_reply.c", + "src/lib/ares_parse_srv_reply.c", + "src/lib/ares_parse_txt_reply.c", + "src/lib/ares_parse_uri_reply.c", + "src/lib/ares_platform.c", + "src/lib/ares_platform.h", + "src/lib/ares_private.h", + "src/lib/ares_process.c", + "src/lib/ares_qcache.c", + "src/lib/ares_query.c", + "src/lib/ares_rand.c", + "src/lib/ares_search.c", + "src/lib/ares_send.c", + "src/lib/ares_setup.h", + "src/lib/ares_strcasecmp.c", + "src/lib/ares_strcasecmp.h", + "src/lib/ares_str.c", + "src/lib/ares_str.h", + "src/lib/ares_strerror.c", + "src/lib/ares_strsplit.c", + "src/lib/ares_strsplit.h", + "src/lib/ares_sysconfig.c", + "src/lib/ares_sysconfig_files.c", + "src/lib/ares_timeout.c", + "src/lib/ares_update_servers.c", + "src/lib/ares_version.c", + "src/lib/inet_net_pton.c", + "src/lib/inet_ntop.c", + "src/lib/setup_once.h", + "src/tools/ares_getopt.c", + "src/tools/ares_getopt.h", + ] + + if (!is_win) { + defines += [ + "_DARWIN_USE_64_BIT_INODE=1", + "_LARGEFILE_SOURCE", + "_FILE_OFFSET_BITS=64", + "_GNU_SOURCE", + ] + } -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. + if (is_win) { + defines += [ "CARES_PULL_WS2TCPIP_H=1" ] + include_dirs += [ "config/win32" ] + sources += [ + "src/lib/config-win32.h", + "src/lib/windows_port.c", + ] + libs += [ + "ws2_32.lib", + "iphlpapi.lib", + ] + } else { + defines += [ "HAVE_CONFIG_H" ] + } -import("unofficial.gni") + if (is_linux) { + include_dirs += [ "config/linux" ] + sources += [ "config/linux/ares_config.h" ] + } -cares_gn_build("cares") { + if (is_mac) { + include_dirs += [ "config/darwin" ] + sources += [ "config/darwin/ares_config.h" ] + } } diff --git a/deps/googletest/BUILD.gn b/deps/googletest/BUILD.gn index de13f3f653b5d53610f4611001c10dce332293c2..0daf8c006cef89e76d7eccec3e924bd2718021c9 100644 --- a/deps/googletest/BUILD.gn +++ b/deps/googletest/BUILD.gn @@ -1,14 +1,64 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("gtest_config") { + include_dirs = [ "include" ] + defines = [ "UNIT_TEST" ] +} + +static_library("gtest") { + include_dirs = [ + "include", + "." # src + ] + + public_configs = [ ":gtest_config" ] -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. + cflags_cc = [ + "-Wno-c++98-compat-extra-semi", + "-Wno-unused-const-variable", + "-Wno-unreachable-code-return", + ] -import("unofficial.gni") + defines = [ + "GTEST_HAS_POSIX_RE=0", + "GTEST_LANG_CXX11=1", + ] + + sources = [ + "include/gtest/gtest_pred_impl.h", + "include/gtest/gtest_prod.h", + "include/gtest/gtest-death-test.h", + "include/gtest/gtest-matchers.h", + "include/gtest/gtest-message.h", + "include/gtest/gtest-param-test.h", + "include/gtest/gtest-printers.h", + "include/gtest/gtest-spi.h", + "include/gtest/gtest-test-part.h", + "include/gtest/gtest-typed-test.h", + "include/gtest/gtest.h", + "include/gtest/internal/gtest-death-test-internal.h", + "include/gtest/internal/gtest-filepath.h", + "include/gtest/internal/gtest-internal.h", + "include/gtest/internal/gtest-param-util.h", + "include/gtest/internal/gtest-port-arch.h", + "include/gtest/internal/gtest-port.h", + "include/gtest/internal/gtest-string.h", + "include/gtest/internal/gtest-type-util.h", + "include/gtest/internal/custom/gtest-port.h", + "include/gtest/internal/custom/gtest-printers.h", + "include/gtest/internal/custom/gtest.h", + "src/gtest-all.cc", + "src/gtest-death-test.cc", + "src/gtest-filepath.cc", + "src/gtest-internal-inl.h", + "src/gtest-matchers.cc", + "src/gtest-port.cc", + "src/gtest-printers.cc", + "src/gtest-test-part.cc", + "src/gtest-typed-test.cc", + "src/gtest.cc", + ] +} -googletest_gn_build("googletest") { +static_library("gtest_main") { + deps = [ ":gtest" ] + sources = [ "src/gtest_main.cc" ] } diff --git a/deps/histogram/BUILD.gn b/deps/histogram/BUILD.gn index e2f3ee37137a6b7d45cbe79f8b9ba7f693ffc4d3..85467b372f01cf602af45fa2f0d599acabfc2310 100644 --- a/deps/histogram/BUILD.gn +++ b/deps/histogram/BUILD.gn @@ -1,14 +1,19 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("histogram_config") { + include_dirs = [ "include" ] -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. + cflags = [ + "-Wno-implicit-function-declaration", + "-Wno-incompatible-pointer-types", + "-Wno-unused-function", + "-Wno-atomic-alignment", + ] +} -import("unofficial.gni") +static_library("histogram") { + public_configs = [ ":histogram_config" ] -histogram_gn_build("histogram") { + sources = [ + "src/hdr_histogram.c", + "src/hdr_histogram.h", + ] } diff --git a/deps/llhttp/BUILD.gn b/deps/llhttp/BUILD.gn index 64a2a4799d5530276f46aa1faa63ece063390ada..fb000f8ee7647c375bc190d1729d67bb7770d109 100644 --- a/deps/llhttp/BUILD.gn +++ b/deps/llhttp/BUILD.gn @@ -1,14 +1,15 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## - -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. - -import("unofficial.gni") +config("llhttp_config") { + include_dirs = [ "include" ] + cflags = [ "-Wno-unreachable-code" ] +} -llhttp_gn_build("llhttp") { +static_library("llhttp") { + include_dirs = [ "include" ] + public_configs = [ ":llhttp_config" ] + cflags_c = [ "-Wno-implicit-fallthrough" ] + sources = [ + "src/api.c", + "src/http.c", + "src/llhttp.c", + ] } diff --git a/deps/nghttp2/BUILD.gn b/deps/nghttp2/BUILD.gn index 274352b0e2449f8db49d9a49c6b92a69f97e8363..f04c7ca24af6cdbe8d739bcd55172110963888e9 100644 --- a/deps/nghttp2/BUILD.gn +++ b/deps/nghttp2/BUILD.gn @@ -1,14 +1,51 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## - -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. +config("nghttp2_config") { + defines = [ "NGHTTP2_STATICLIB" ] + include_dirs = [ "lib/includes" ] +} +static_library("nghttp2") { + public_configs = [ ":nghttp2_config" ] + defines = [ + "_U_", + "BUILDING_NGHTTP2", + "NGHTTP2_STATICLIB", + "HAVE_CONFIG_H", + ] + include_dirs = [ "lib/includes" ] -import("unofficial.gni") + cflags_c = [ + "-Wno-implicit-function-declaration", + "-Wno-implicit-fallthrough", + "-Wno-string-plus-int", + "-Wno-unreachable-code-return", + "-Wno-unused-but-set-variable", + ] -nghttp2_gn_build("nghttp2") { + sources = [ + "lib/nghttp2_buf.c", + "lib/nghttp2_callbacks.c", + "lib/nghttp2_debug.c", + "lib/nghttp2_extpri.c", + "lib/nghttp2_frame.c", + "lib/nghttp2_hd.c", + "lib/nghttp2_hd_huffman.c", + "lib/nghttp2_hd_huffman_data.c", + "lib/nghttp2_helper.c", + "lib/nghttp2_http.c", + "lib/nghttp2_map.c", + "lib/nghttp2_mem.c", + "lib/nghttp2_alpn.c", + "lib/nghttp2_option.c", + "lib/nghttp2_outbound_item.c", + "lib/nghttp2_pq.c", + "lib/nghttp2_priority_spec.c", + "lib/nghttp2_queue.c", + "lib/nghttp2_ratelim.c", + "lib/nghttp2_rcbuf.c", + "lib/nghttp2_session.c", + "lib/nghttp2_stream.c", + "lib/nghttp2_submit.c", + "lib/nghttp2_time.c", + "lib/nghttp2_version.c", + "lib/sfparse.c", + ] } diff --git a/deps/simdjson/BUILD.gn b/deps/simdjson/BUILD.gn index d0580ccf354d2000fb0075fd3bb4579f93477927..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 100644 --- a/deps/simdjson/BUILD.gn +++ b/deps/simdjson/BUILD.gn @@ -1,14 +0,0 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## - -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. - -import("unofficial.gni") - -simdjson_gn_build("simdjson") { -} diff --git a/deps/simdutf/BUILD.gn b/deps/simdutf/BUILD.gn index 119d49456911e99944294bd00b3f182a8f0e35b5..ce38c3633a228306622a7237067393d25332c59c 100644 --- a/deps/simdutf/BUILD.gn +++ b/deps/simdutf/BUILD.gn @@ -1,14 +1,21 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("simdutf_config") { + include_dirs = [ "." ] +} -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. +static_library("simdutf") { + include_dirs = [ "." ] + sources = [ + "simdutf.cpp", + ] -import("unofficial.gni") + public_configs = [ ":simdutf_config" ] -simdutf_gn_build("simdutf") { + cflags_cc = [ + "-Wno-ambiguous-reversed-operator", + "-Wno-c++98-compat-extra-semi", + "-Wno-unreachable-code", + "-Wno-unreachable-code-break", + "-Wno-unused-const-variable", + "-Wno-unused-function", + ] } diff --git a/deps/uv/BUILD.gn b/deps/uv/BUILD.gn index 8e6ac27048b5965e20f35c7a63e469beb6fa5970..7518168141db7958550c7f5dc1ed17ccdbbe4a60 100644 --- a/deps/uv/BUILD.gn +++ b/deps/uv/BUILD.gn @@ -1,14 +1,194 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("libuv_config") { + include_dirs = [ "include" ] -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. + defines = [] -import("unofficial.gni") + if (is_linux) { + defines += [ "_POSIX_C_SOURCE=200112" ] + } + if (!is_win) { + defines += [ + "_LARGEFILE_SOURCE", + "_FILE_OFFSET_BITS=64", + ] + } + if (is_mac) { + defines += [ "_DARWIN_USE_64_BIT_INODE=1" ] + } +} + +static_library("uv") { + include_dirs = [ + "include", + "src", + ] + + public_configs = [ ":libuv_config" ] + + ldflags = [] + + 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-incompatible-pointer-types", + "-Wno-bitwise-op-parentheses", + "-Wno-implicit-fallthrough", + "-Wno-implicit-function-declaration", + "-Wno-missing-braces", + "-Wno-sign-compare", + "-Wno-sometimes-uninitialized", + "-Wno-string-conversion", + "-Wno-switch", + "-Wno-unused-function", + "-Wno-unused-result", + "-Wno-unused-variable", + "-Wno-unreachable-code", + "-Wno-unreachable-code-return", + "-Wno-unused-but-set-variable", + "-Wno-shadow", + ] + + libs = [] + + sources = [ + "include/uv.h", + "include/uv/tree.h", + "include/uv/errno.h", + "include/uv/threadpool.h", + "include/uv/version.h", + "src/fs-poll.c", + "src/heap-inl.h", + "src/idna.c", + "src/idna.h", + "src/inet.c", + "src/queue.h", + "src/random.c", + "src/strscpy.c", + "src/strscpy.h", + "src/strtok.c", + "src/strtok.h", + "src/thread-common.c", + "src/threadpool.c", + "src/timer.c", + "src/uv-data-getter-setters.c", + "src/uv-common.c", + "src/uv-common.h", + "src/version.c", + ] + + if (is_win) { + defines += [ "_GNU_SOURCE" ] + sources += [ + "include/uv/win.h", + "src/win/async.c", + "src/win/atomicops-inl.h", + "src/win/core.c", + "src/win/detect-wakeup.c", + "src/win/dl.c", + "src/win/error.c", + "src/win/fs.c", + "src/win/fs-event.c", + "src/win/getaddrinfo.c", + "src/win/getnameinfo.c", + "src/win/handle.c", + "src/win/handle-inl.h", + "src/win/internal.h", + "src/win/loop-watcher.c", + "src/win/pipe.c", + "src/win/thread.c", + "src/win/poll.c", + "src/win/process.c", + "src/win/process-stdio.c", + "src/win/req-inl.h", + "src/win/signal.c", + "src/win/snprintf.c", + "src/win/stream.c", + "src/win/stream-inl.h", + "src/win/tcp.c", + "src/win/tty.c", + "src/win/udp.c", + "src/win/util.c", + "src/win/winapi.c", + "src/win/winapi.h", + "src/win/winsock.c", + "src/win/winsock.h", + ] -uv_gn_build("uv") { + libs += [ + "advapi32.lib", + "iphlpapi.lib", + "psapi.lib", + "shell32.lib", + "user32.lib", + "userenv.lib", + "ws2_32.lib", + ] + } else { + sources += [ + "include/uv/unix.h", + "include/uv/linux.h", + "include/uv/sunos.h", + "include/uv/darwin.h", + "include/uv/bsd.h", + "include/uv/aix.h", + "src/unix/async.c", + "src/unix/core.c", + "src/unix/dl.c", + "src/unix/fs.c", + "src/unix/getaddrinfo.c", + "src/unix/getnameinfo.c", + "src/unix/internal.h", + "src/unix/loop.c", + "src/unix/loop-watcher.c", + "src/unix/pipe.c", + "src/unix/poll.c", + "src/unix/process.c", + "src/unix/random-devurandom.c", + "src/unix/signal.c", + "src/unix/stream.c", + "src/unix/tcp.c", + "src/unix/thread.c", + "src/unix/tty.c", + "src/unix/udp.c", + ] + libs += [ "m" ] + ldflags += [ "-pthread" ] + } + if (is_mac || is_linux) { + sources += [ "src/unix/proctitle.c" ] + } + if (is_mac) { + sources += [ + "src/unix/darwin-proctitle.c", + "src/unix/darwin.c", + "src/unix/fsevents.c", + "src/unix/random-getentropy.c", + ] + defines += [ + "_DARWIN_USE_64_BIT_INODE=1", + "_DARWIN_UNLIMITED_SELECT=1", + ] + } + if (is_linux) { + defines += [ "_GNU_SOURCE" ] + sources += [ + "src/unix/linux.c", + "src/unix/procfs-exepath.c", + "src/unix/random-getrandom.c", + "src/unix/random-sysctl-linux.c", + ] + libs += [ + "dl", + "rt", + ] + } + if (is_mac) { # is_bsd + sources += [ + "src/unix/bsd-ifaddrs.c", + "src/unix/kqueue.c", + ] + } } diff --git a/deps/uvwasi/BUILD.gn b/deps/uvwasi/BUILD.gn index 4f8fb081df805a786e523e5f0ffbb0096fdeca99..d9fcf8dc972b1caa2b7a130b1144c685316035cd 100644 --- a/deps/uvwasi/BUILD.gn +++ b/deps/uvwasi/BUILD.gn @@ -1,14 +1,39 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +config("uvwasi_config") { + include_dirs = [ "include" ] +} + +static_library("uvwasi") { + include_dirs = [ + "include", + "src", + ] + + defines = [] + if (is_linux) { + defines += [ + "_GNU_SOURCE", + "_POSIX_C_SOURCE=200112" + ] + } + + deps = [ "../../deps/uv" ] -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. + public_configs = [ ":uvwasi_config" ] -import("unofficial.gni") + cflags_c = [] + if (!is_win) { + cflags_c += [ "-fvisibility=hidden" ] + } -uvwasi_gn_build("uvwasi") { + sources = [ + "src/clocks.c", + "src/fd_table.c", + "src/path_resolver.c", + "src/poll_oneoff.c", + "src/sync_helpers.c", + "src/uv_mapping.c", + "src/uvwasi.c", + "src/wasi_rights.c", + "src/wasi_serdes.c" + ] } diff --git a/electron_node.gni b/electron_node.gni new file mode 100644 index 0000000000000000000000000000000000000000..af9cbada10203b387fb9732b346583b1c4349223 --- /dev/null +++ b/electron_node.gni @@ -0,0 +1,4 @@ +declare_args() { + # Allows embedders to override the NODE_MODULE_VERSION define + node_module_version = "" +} diff --git a/filenames.json b/filenames.json new file mode 100644 index 0000000000000000000000000000000000000000..fd42e2a5e6163ff70db0f716d2f9a32f13cdf668 --- /dev/null +++ b/filenames.json @@ -0,0 +1,734 @@ +// This file is automatically generated by generate_gn_filenames_json.py +// DO NOT EDIT +{ + "fs_files": [ + "lib/internal/fs/cp/cp-sync.js", + "lib/internal/fs/cp/cp.js", + "lib/internal/fs/dir.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" + ], + "headers": [ + { + "dest_dir": "include/node/", + "files": [ + "src/js_native_api.h", + "src/js_native_api_types.h", + "src/node.h", + "src/node_api.h", + "src/node_api_types.h", + "src/node_buffer.h", + "src/node_object_wrap.h" + ] + }, + { + "dest_dir": "include/node/./", + "files": [ + "//v8/include/v8-array-buffer.h", + "//v8/include/v8-callbacks.h", + "//v8/include/v8-container.h", + "//v8/include/v8-context.h", + "//v8/include/v8-cppgc.h", + "//v8/include/v8-data.h", + "//v8/include/v8-date.h", + "//v8/include/v8-debug.h", + "//v8/include/v8-embedder-heap.h", + "//v8/include/v8-embedder-state-scope.h", + "//v8/include/v8-exception.h", + "//v8/include/v8-extension.h", + "//v8/include/v8-external.h", + "//v8/include/v8-forward.h", + "//v8/include/v8-function-callback.h", + "//v8/include/v8-function.h", + "//v8/include/v8-handle-base.h", + "//v8/include/v8-initialization.h", + "//v8/include/v8-internal.h", + "//v8/include/v8-isolate.h", + "//v8/include/v8-json.h", + "//v8/include/v8-local-handle.h", + "//v8/include/v8-locker.h", + "//v8/include/v8-maybe.h", + "//v8/include/v8-memory-span.h", + "//v8/include/v8-message.h", + "//v8/include/v8-microtask-queue.h", + "//v8/include/v8-microtask.h", + "//v8/include/v8-object.h", + "//v8/include/v8-persistent-handle.h", + "//v8/include/v8-platform.h", + "//v8/include/v8-primitive-object.h", + "//v8/include/v8-primitive.h", + "//v8/include/v8-profiler.h", + "//v8/include/v8-promise.h", + "//v8/include/v8-proxy.h", + "//v8/include/v8-regexp.h", + "//v8/include/v8-sandbox.h", + "//v8/include/v8-script.h", + "//v8/include/v8-snapshot.h", + "//v8/include/v8-source-location.h", + "//v8/include/v8-statistics.h", + "//v8/include/v8-template.h", + "//v8/include/v8-traced-handle.h", + "//v8/include/v8-typed-array.h", + "//v8/include/v8-unwinder.h", + "//v8/include/v8-value-serializer.h", + "//v8/include/v8-value.h", + "//v8/include/v8-version.h", + "//v8/include/v8-wasm.h", + "//v8/include/v8-weak-callback-info.h", + "//v8/include/v8.h", + "//v8/include/v8config.h", + "deps/uv/include/uv.h" + ] + }, + { + "dest_dir": "include/node/libplatform/", + "files": [ + "//v8/include/libplatform/libplatform-export.h", + "//v8/include/libplatform/libplatform.h", + "//v8/include/libplatform/v8-tracing.h" + ] + }, + { + "dest_dir": "include/node/cppgc/", + "files": [ + "//v8/include/cppgc/allocation.h", + "//v8/include/cppgc/common.h", + "//v8/include/cppgc/cross-thread-persistent.h", + "//v8/include/cppgc/custom-space.h", + "//v8/include/cppgc/default-platform.h", + "//v8/include/cppgc/ephemeron-pair.h", + "//v8/include/cppgc/explicit-management.h", + "//v8/include/cppgc/garbage-collected.h", + "//v8/include/cppgc/heap-consistency.h", + "//v8/include/cppgc/heap-handle.h", + "//v8/include/cppgc/heap-state.h", + "//v8/include/cppgc/heap-statistics.h", + "//v8/include/cppgc/heap.h", + "//v8/include/cppgc/liveness-broker.h", + "//v8/include/cppgc/macros.h", + "//v8/include/cppgc/member.h", + "//v8/include/cppgc/name-provider.h", + "//v8/include/cppgc/object-size-trait.h", + "//v8/include/cppgc/persistent.h", + "//v8/include/cppgc/platform.h", + "//v8/include/cppgc/prefinalizer.h", + "//v8/include/cppgc/process-heap-statistics.h", + "//v8/include/cppgc/sentinel-pointer.h", + "//v8/include/cppgc/source-location.h", + "//v8/include/cppgc/testing.h", + "//v8/include/cppgc/trace-trait.h", + "//v8/include/cppgc/type-traits.h", + "//v8/include/cppgc/visitor.h" + ] + }, + { + "dest_dir": "include/node/cppgc/internal/", + "files": [ + "//v8/include/cppgc/internal/api-constants.h", + "//v8/include/cppgc/internal/atomic-entry-flag.h", + "//v8/include/cppgc/internal/base-page-handle.h", + "//v8/include/cppgc/internal/caged-heap-local-data.h", + "//v8/include/cppgc/internal/caged-heap.h", + "//v8/include/cppgc/internal/compiler-specific.h", + "//v8/include/cppgc/internal/finalizer-trait.h", + "//v8/include/cppgc/internal/gc-info.h", + "//v8/include/cppgc/internal/logging.h", + "//v8/include/cppgc/internal/member-storage.h", + "//v8/include/cppgc/internal/name-trait.h", + "//v8/include/cppgc/internal/persistent-node.h", + "//v8/include/cppgc/internal/pointer-policies.h", + "//v8/include/cppgc/internal/write-barrier.h" + ] + }, + { + "dest_dir": "include/node/uv/", + "files": [ + "deps/uv/include/uv/aix.h", + "deps/uv/include/uv/bsd.h", + "deps/uv/include/uv/darwin.h", + "deps/uv/include/uv/errno.h", + "deps/uv/include/uv/linux.h", + "deps/uv/include/uv/os390.h", + "deps/uv/include/uv/posix.h", + "deps/uv/include/uv/sunos.h", + "deps/uv/include/uv/threadpool.h", + "deps/uv/include/uv/tree.h", + "deps/uv/include/uv/unix.h", + "deps/uv/include/uv/version.h", + "deps/uv/include/uv/win.h" + ] + } + ], + "library_files": [ + "lib/_http_agent.js", + "lib/_http_client.js", + "lib/_http_common.js", + "lib/_http_incoming.js", + "lib/_http_outgoing.js", + "lib/_http_server.js", + "lib/_stream_duplex.js", + "lib/_stream_passthrough.js", + "lib/_stream_readable.js", + "lib/_stream_transform.js", + "lib/_stream_wrap.js", + "lib/_stream_writable.js", + "lib/_tls_common.js", + "lib/_tls_wrap.js", + "lib/assert.js", + "lib/assert/strict.js", + "lib/async_hooks.js", + "lib/buffer.js", + "lib/child_process.js", + "lib/cluster.js", + "lib/console.js", + "lib/constants.js", + "lib/crypto.js", + "lib/dgram.js", + "lib/diagnostics_channel.js", + "lib/dns.js", + "lib/dns/promises.js", + "lib/domain.js", + "lib/events.js", + "lib/http.js", + "lib/http2.js", + "lib/https.js", + "lib/inspector.js", + "lib/inspector/promises.js", + "lib/internal/abort_controller.js", + "lib/internal/assert.js", + "lib/internal/assert/assertion_error.js", + "lib/internal/assert/calltracker.js", + "lib/internal/async_hooks.js", + "lib/internal/blob.js", + "lib/internal/blocklist.js", + "lib/internal/bootstrap/node.js", + "lib/internal/bootstrap/realm.js", + "lib/internal/bootstrap/shadow_realm.js", + "lib/internal/bootstrap/switches/does_not_own_process_state.js", + "lib/internal/bootstrap/switches/does_own_process_state.js", + "lib/internal/bootstrap/switches/is_main_thread.js", + "lib/internal/bootstrap/switches/is_not_main_thread.js", + "lib/internal/bootstrap/web/exposed-wildcard.js", + "lib/internal/bootstrap/web/exposed-window-or-worker.js", + "lib/internal/buffer.js", + "lib/internal/child_process.js", + "lib/internal/child_process/serialization.js", + "lib/internal/cli_table.js", + "lib/internal/cluster/child.js", + "lib/internal/cluster/primary.js", + "lib/internal/cluster/round_robin_handle.js", + "lib/internal/cluster/shared_handle.js", + "lib/internal/cluster/utils.js", + "lib/internal/cluster/worker.js", + "lib/internal/console/constructor.js", + "lib/internal/console/global.js", + "lib/internal/constants.js", + "lib/internal/crypto/aes.js", + "lib/internal/crypto/certificate.js", + "lib/internal/crypto/cfrg.js", + "lib/internal/crypto/cipher.js", + "lib/internal/crypto/diffiehellman.js", + "lib/internal/crypto/ec.js", + "lib/internal/crypto/hash.js", + "lib/internal/crypto/hashnames.js", + "lib/internal/crypto/hkdf.js", + "lib/internal/crypto/keygen.js", + "lib/internal/crypto/keys.js", + "lib/internal/crypto/mac.js", + "lib/internal/crypto/pbkdf2.js", + "lib/internal/crypto/random.js", + "lib/internal/crypto/rsa.js", + "lib/internal/crypto/scrypt.js", + "lib/internal/crypto/sig.js", + "lib/internal/crypto/util.js", + "lib/internal/crypto/webcrypto.js", + "lib/internal/crypto/webidl.js", + "lib/internal/crypto/x509.js", + "lib/internal/debugger/inspect.js", + "lib/internal/debugger/inspect_client.js", + "lib/internal/debugger/inspect_repl.js", + "lib/internal/dgram.js", + "lib/internal/dns/callback_resolver.js", + "lib/internal/dns/promises.js", + "lib/internal/dns/utils.js", + "lib/internal/encoding.js", + "lib/internal/error_serdes.js", + "lib/internal/errors.js", + "lib/internal/event_target.js", + "lib/internal/events/abort_listener.js", + "lib/internal/events/symbols.js", + "lib/internal/file.js", + "lib/internal/fixed_queue.js", + "lib/internal/freelist.js", + "lib/internal/freeze_intrinsics.js", + "lib/internal/heap_utils.js", + "lib/internal/histogram.js", + "lib/internal/http.js", + "lib/internal/http2/compat.js", + "lib/internal/http2/core.js", + "lib/internal/http2/util.js", + "lib/internal/idna.js", + "lib/internal/inspector_async_hook.js", + "lib/internal/js_stream_socket.js", + "lib/internal/legacy/processbinding.js", + "lib/internal/linkedlist.js", + "lib/internal/main/check_syntax.js", + "lib/internal/main/embedding.js", + "lib/internal/main/eval_stdin.js", + "lib/internal/main/eval_string.js", + "lib/internal/main/inspect.js", + "lib/internal/main/mksnapshot.js", + "lib/internal/main/print_help.js", + "lib/internal/main/prof_process.js", + "lib/internal/main/repl.js", + "lib/internal/main/run_main_module.js", + "lib/internal/main/test_runner.js", + "lib/internal/main/watch_mode.js", + "lib/internal/main/worker_thread.js", + "lib/internal/mime.js", + "lib/internal/modules/cjs/loader.js", + "lib/internal/modules/esm/assert.js", + "lib/internal/modules/esm/create_dynamic_module.js", + "lib/internal/modules/esm/fetch_module.js", + "lib/internal/modules/esm/formats.js", + "lib/internal/modules/esm/get_format.js", + "lib/internal/modules/esm/hooks.js", + "lib/internal/modules/esm/initialize_import_meta.js", + "lib/internal/modules/esm/load.js", + "lib/internal/modules/esm/loader.js", + "lib/internal/modules/esm/module_job.js", + "lib/internal/modules/esm/module_map.js", + "lib/internal/modules/esm/package_config.js", + "lib/internal/modules/esm/resolve.js", + "lib/internal/modules/esm/shared_constants.js", + "lib/internal/modules/esm/translators.js", + "lib/internal/modules/esm/utils.js", + "lib/internal/modules/esm/worker.js", + "lib/internal/modules/helpers.js", + "lib/internal/modules/package_json_reader.js", + "lib/internal/modules/run_main.js", + "lib/internal/navigator.js", + "lib/internal/net.js", + "lib/internal/options.js", + "lib/internal/per_context/domexception.js", + "lib/internal/per_context/messageport.js", + "lib/internal/per_context/primordials.js", + "lib/internal/perf/event_loop_delay.js", + "lib/internal/perf/event_loop_utilization.js", + "lib/internal/perf/nodetiming.js", + "lib/internal/perf/observe.js", + "lib/internal/perf/performance.js", + "lib/internal/perf/performance_entry.js", + "lib/internal/perf/resource_timing.js", + "lib/internal/perf/timerify.js", + "lib/internal/perf/usertiming.js", + "lib/internal/perf/utils.js", + "lib/internal/policy/manifest.js", + "lib/internal/policy/sri.js", + "lib/internal/priority_queue.js", + "lib/internal/process/execution.js", + "lib/internal/process/per_thread.js", + "lib/internal/process/permission.js", + "lib/internal/process/policy.js", + "lib/internal/process/pre_execution.js", + "lib/internal/process/promises.js", + "lib/internal/process/report.js", + "lib/internal/process/signal.js", + "lib/internal/process/task_queues.js", + "lib/internal/process/warning.js", + "lib/internal/process/worker_thread_only.js", + "lib/internal/promise_hooks.js", + "lib/internal/querystring.js", + "lib/internal/readline/callbacks.js", + "lib/internal/readline/emitKeypressEvents.js", + "lib/internal/readline/interface.js", + "lib/internal/readline/promises.js", + "lib/internal/readline/utils.js", + "lib/internal/repl.js", + "lib/internal/repl/await.js", + "lib/internal/repl/history.js", + "lib/internal/repl/utils.js", + "lib/internal/socket_list.js", + "lib/internal/socketaddress.js", + "lib/internal/source_map/prepare_stack_trace.js", + "lib/internal/source_map/source_map.js", + "lib/internal/source_map/source_map_cache.js", + "lib/internal/stream_base_commons.js", + "lib/internal/streams/add-abort-signal.js", + "lib/internal/streams/compose.js", + "lib/internal/streams/destroy.js", + "lib/internal/streams/duplex.js", + "lib/internal/streams/duplexify.js", + "lib/internal/streams/end-of-stream.js", + "lib/internal/streams/from.js", + "lib/internal/streams/lazy_transform.js", + "lib/internal/streams/legacy.js", + "lib/internal/streams/operators.js", + "lib/internal/streams/passthrough.js", + "lib/internal/streams/pipeline.js", + "lib/internal/streams/readable.js", + "lib/internal/streams/state.js", + "lib/internal/streams/transform.js", + "lib/internal/streams/utils.js", + "lib/internal/streams/writable.js", + "lib/internal/test/binding.js", + "lib/internal/test/transfer.js", + "lib/internal/test_runner/coverage.js", + "lib/internal/test_runner/harness.js", + "lib/internal/test_runner/mock/mock.js", + "lib/internal/test_runner/mock/mock_timers.js", + "lib/internal/test_runner/reporter/dot.js", + "lib/internal/test_runner/reporter/junit.js", + "lib/internal/test_runner/reporter/lcov.js", + "lib/internal/test_runner/reporter/spec.js", + "lib/internal/test_runner/reporter/tap.js", + "lib/internal/test_runner/reporter/v8-serializer.js", + "lib/internal/test_runner/runner.js", + "lib/internal/test_runner/test.js", + "lib/internal/test_runner/tests_stream.js", + "lib/internal/test_runner/utils.js", + "lib/internal/timers.js", + "lib/internal/tls/secure-context.js", + "lib/internal/tls/secure-pair.js", + "lib/internal/trace_events_async_hooks.js", + "lib/internal/tty.js", + "lib/internal/url.js", + "lib/internal/util.js", + "lib/internal/util/colors.js", + "lib/internal/util/comparisons.js", + "lib/internal/util/debuglog.js", + "lib/internal/util/embedding.js", + "lib/internal/util/inspect.js", + "lib/internal/util/inspector.js", + "lib/internal/util/iterable_weak_map.js", + "lib/internal/util/parse_args/parse_args.js", + "lib/internal/util/parse_args/utils.js", + "lib/internal/util/types.js", + "lib/internal/v8/startup_snapshot.js", + "lib/internal/v8_prof_polyfill.js", + "lib/internal/v8_prof_processor.js", + "lib/internal/validators.js", + "lib/internal/vm.js", + "lib/internal/vm/module.js", + "lib/internal/wasm_web_api.js", + "lib/internal/watch_mode/files_watcher.js", + "lib/internal/watchdog.js", + "lib/internal/webidl.js", + "lib/internal/webstreams/adapters.js", + "lib/internal/webstreams/compression.js", + "lib/internal/webstreams/encoding.js", + "lib/internal/webstreams/queuingstrategies.js", + "lib/internal/webstreams/readablestream.js", + "lib/internal/webstreams/transfer.js", + "lib/internal/webstreams/transformstream.js", + "lib/internal/webstreams/util.js", + "lib/internal/webstreams/writablestream.js", + "lib/internal/worker.js", + "lib/internal/worker/io.js", + "lib/internal/worker/js_transferable.js", + "lib/module.js", + "lib/net.js", + "lib/os.js", + "lib/path.js", + "lib/path/posix.js", + "lib/path/win32.js", + "lib/perf_hooks.js", + "lib/process.js", + "lib/punycode.js", + "lib/querystring.js", + "lib/readline.js", + "lib/readline/promises.js", + "lib/repl.js", + "lib/sea.js", + "lib/stream.js", + "lib/stream/consumers.js", + "lib/stream/promises.js", + "lib/stream/web.js", + "lib/string_decoder.js", + "lib/sys.js", + "lib/test.js", + "lib/test/reporters.js", + "lib/timers.js", + "lib/timers/promises.js", + "lib/tls.js", + "lib/trace_events.js", + "lib/tty.js", + "lib/url.js", + "lib/util.js", + "lib/util/types.js", + "lib/v8.js", + "lib/vm.js", + "lib/wasi.js", + "lib/worker_threads.js", + "lib/zlib.js", + "deps/v8/tools/splaytree.mjs", + "deps/v8/tools/codemap.mjs", + "deps/v8/tools/consarray.mjs", + "deps/v8/tools/csvparser.mjs", + "deps/v8/tools/profile.mjs", + "deps/v8/tools/profile_view.mjs", + "deps/v8/tools/logreader.mjs", + "deps/v8/tools/arguments.mjs", + "deps/v8/tools/tickprocessor.mjs", + "deps/v8/tools/sourcemap.mjs", + "deps/v8/tools/tickprocessor-driver.mjs", + "deps/acorn/acorn/dist/acorn.js", + "deps/acorn/acorn-walk/dist/walk.js", + "deps/minimatch/index.js", + "deps/cjs-module-lexer/lexer.js", + "deps/cjs-module-lexer/dist/lexer.js", + "deps/undici/undici.js" + ], + "node_sources": [ + "src/api/async_resource.cc", + "src/api/callback.cc", + "src/api/embed_helpers.cc", + "src/api/encoding.cc", + "src/api/environment.cc", + "src/api/exceptions.cc", + "src/api/hooks.cc", + "src/api/utils.cc", + "src/async_wrap.cc", + "src/base_object.cc", + "src/cares_wrap.cc", + "src/cleanup_queue.cc", + "src/connect_wrap.cc", + "src/connection_wrap.cc", + "src/dataqueue/queue.cc", + "src/debug_utils.cc", + "src/embedded_data.cc", + "src/encoding_binding.cc", + "src/env.cc", + "src/fs_event_wrap.cc", + "src/handle_wrap.cc", + "src/heap_utils.cc", + "src/histogram.cc", + "src/internal_only_v8.cc", + "src/js_native_api.h", + "src/js_native_api_types.h", + "src/js_native_api_v8.cc", + "src/js_native_api_v8.h", + "src/js_native_api_v8_internals.h", + "src/js_stream.cc", + "src/json_utils.cc", + "src/js_udp_wrap.cc", + "src/json_parser.h", + "src/json_parser.cc", + "src/module_wrap.cc", + "src/node.cc", + "src/node_api.cc", + "src/node_binding.cc", + "src/node_blob.cc", + "src/node_buffer.cc", + "src/node_builtins.cc", + "src/node_config.cc", + "src/node_constants.cc", + "src/node_contextify.cc", + "src/node_credentials.cc", + "src/node_dir.cc", + "src/node_dotenv.cc", + "src/node_env_var.cc", + "src/node_errors.cc", + "src/node_external_reference.cc", + "src/node_file.cc", + "src/node_http_parser.cc", + "src/node_http2.cc", + "src/node_i18n.cc", + "src/node_main_instance.cc", + "src/node_messaging.cc", + "src/node_metadata.cc", + "src/node_options.cc", + "src/node_os.cc", + "src/node_perf.cc", + "src/node_platform.cc", + "src/node_postmortem_metadata.cc", + "src/node_process_events.cc", + "src/node_process_methods.cc", + "src/node_process_object.cc", + "src/node_realm.cc", + "src/node_report.cc", + "src/node_report_module.cc", + "src/node_report_utils.cc", + "src/node_sea.cc", + "src/node_serdes.cc", + "src/node_shadow_realm.cc", + "src/node_snapshotable.cc", + "src/node_sockaddr.cc", + "src/node_stat_watcher.cc", + "src/node_symbols.cc", + "src/node_task_queue.cc", + "src/node_trace_events.cc", + "src/node_types.cc", + "src/node_url.cc", + "src/node_util.cc", + "src/node_v8.cc", + "src/node_wasi.cc", + "src/node_wasm_web_api.cc", + "src/node_watchdog.cc", + "src/node_worker.cc", + "src/node_zlib.cc", + "src/path.cc", + "src/permission/child_process_permission.cc", + "src/permission/fs_permission.cc", + "src/permission/inspector_permission.cc", + "src/permission/permission.cc", + "src/permission/worker_permission.cc", + "src/pipe_wrap.cc", + "src/process_wrap.cc", + "src/signal_wrap.cc", + "src/spawn_sync.cc", + "src/stream_base.cc", + "src/stream_pipe.cc", + "src/stream_wrap.cc", + "src/string_bytes.cc", + "src/string_decoder.cc", + "src/tcp_wrap.cc", + "src/timers.cc", + "src/timer_wrap.cc", + "src/tracing/agent.cc", + "src/tracing/node_trace_buffer.cc", + "src/tracing/node_trace_writer.cc", + "src/tracing/trace_event.cc", + "src/tracing/traced_value.cc", + "src/tty_wrap.cc", + "src/udp_wrap.cc", + "src/util.cc", + "src/uv.cc", + "src/aliased_buffer.h", + "src/aliased_buffer-inl.h", + "src/aliased_struct.h", + "src/aliased_struct-inl.h", + "src/async_wrap.h", + "src/async_wrap-inl.h", + "src/base_object.h", + "src/base_object-inl.h", + "src/base_object_types.h", + "src/base64.h", + "src/base64-inl.h", + "src/blob_serializer_deserializer.h", + "src/blob_serializer_deserializer-inl.h", + "src/callback_queue.h", + "src/callback_queue-inl.h", + "src/cleanup_queue.h", + "src/cleanup_queue-inl.h", + "src/connect_wrap.h", + "src/connection_wrap.h", + "src/dataqueue/queue.h", + "src/debug_utils.h", + "src/debug_utils-inl.h", + "src/embedded_data.h", + "src/encoding_binding.h", + "src/env_properties.h", + "src/env.h", + "src/env-inl.h", + "src/handle_wrap.h", + "src/histogram.h", + "src/histogram-inl.h", + "src/js_stream.h", + "src/json_utils.h", + "src/large_pages/node_large_page.cc", + "src/large_pages/node_large_page.h", + "src/memory_tracker.h", + "src/memory_tracker-inl.h", + "src/module_wrap.h", + "src/node.h", + "src/node_api.h", + "src/node_api_types.h", + "src/node_binding.h", + "src/node_blob.h", + "src/node_buffer.h", + "src/node_builtins.h", + "src/node_constants.h", + "src/node_context_data.h", + "src/node_contextify.h", + "src/node_dir.h", + "src/node_dotenv.h", + "src/node_errors.h", + "src/node_exit_code.h", + "src/node_external_reference.h", + "src/node_file.h", + "src/node_file-inl.h", + "src/node_http_common.h", + "src/node_http_common-inl.h", + "src/node_http2.h", + "src/node_http2_state.h", + "src/node_i18n.h", + "src/node_internals.h", + "src/node_main_instance.h", + "src/node_mem.h", + "src/node_mem-inl.h", + "src/node_messaging.h", + "src/node_metadata.h", + "src/node_mutex.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_platform.h", + "src/node_process.h", + "src/node_process-inl.h", + "src/node_realm.h", + "src/node_realm-inl.h", + "src/node_report.h", + "src/node_revert.h", + "src/node_root_certs.h", + "src/node_sea.h", + "src/node_shadow_realm.h", + "src/node_snapshotable.h", + "src/node_snapshot_builder.h", + "src/node_sockaddr.h", + "src/node_sockaddr-inl.h", + "src/node_stat_watcher.h", + "src/node_union_bytes.h", + "src/node_url.h", + "src/node_version.h", + "src/node_v8.h", + "src/node_v8_platform-inl.h", + "src/node_wasi.h", + "src/node_watchdog.h", + "src/node_worker.h", + "src/path.h", + "src/permission/child_process_permission.h", + "src/permission/fs_permission.h", + "src/permission/inspector_permission.h", + "src/permission/permission.h", + "src/permission/worker_permission.h", + "src/pipe_wrap.h", + "src/req_wrap.h", + "src/req_wrap-inl.h", + "src/spawn_sync.h", + "src/stream_base.h", + "src/stream_base-inl.h", + "src/stream_pipe.h", + "src/stream_wrap.h", + "src/string_bytes.h", + "src/string_decoder.h", + "src/string_decoder-inl.h", + "src/string_search.h", + "src/tcp_wrap.h", + "src/timers.h", + "src/tracing/agent.h", + "src/tracing/node_trace_buffer.h", + "src/tracing/node_trace_writer.h", + "src/tracing/trace_event.h", + "src/tracing/trace_event_common.h", + "src/tracing/traced_value.h", + "src/timer_wrap.h", + "src/timer_wrap-inl.h", + "src/tty_wrap.h", + "src/udp_wrap.h", + "src/util.h", + "src/util-inl.h", + "//v8/include/v8.h", + "deps/postject/postject-api.h" + ] +} diff --git a/src/inspector/BUILD.gn b/src/inspector/BUILD.gn index 909fd14345fcd988c381e640280f4b33f2e0c351..800431e6659f95f0495cb90b8fa2cccbc9f34661 100644 --- a/src/inspector/BUILD.gn +++ b/src/inspector/BUILD.gn @@ -1,14 +1,202 @@ -############################################################################## -# # -# DO NOT EDIT THIS FILE! # -# # -############################################################################## +import("//v8/gni/v8.gni") -# This file is used by GN for building, which is NOT the build system used for -# building official binaries. -# Please modify the gyp files if you are making changes to build system. +inspector_protocol_dir = "../../tools/inspector_protocol" -import("unofficial.gni") +_protocol_generated = [ + "protocol/Forward.h", + "protocol/Protocol.cpp", + "protocol/Protocol.h", + "protocol/NodeWorker.cpp", + "protocol/NodeWorker.h", + "protocol/NodeTracing.cpp", + "protocol/NodeTracing.h", + "protocol/NodeRuntime.cpp", + "protocol/NodeRuntime.h", +] -inspector_gn_build("inspector") { +# These are from node_protocol_config.json +# These convoluted path hacks are to work around the fact that node.js is very +# confused about what paths are in its includes, without changing node at all. +# Hopefully, keying everything in this file off the paths that are in +# node_protocol_config.json will mean that the paths stay in sync. +inspector_protocol_package = "src/node/inspector/protocol" +inspector_protocol_output = "node/inspector/protocol" + +config("inspector_config") { + include_dirs = [ + "$target_gen_dir", + "$target_gen_dir/src", + ] + + configs = [ "../..:node_features" ] +} + +source_set("inspector") { + sources = [ + "main_thread_interface.cc", + "main_thread_interface.h", + "node_string.cc", + "node_string.h", + "runtime_agent.cc", + "runtime_agent.h", + "tracing_agent.cc", + "tracing_agent.h", + "worker_agent.cc", + "worker_agent.h", + "worker_inspector.cc", + "worker_inspector.h", + ] + sources += rebase_path(_protocol_generated, + ".", + "$target_gen_dir/$inspector_protocol_package/..") + include_dirs = [ + "//v8/include", + "..", + ] + deps = [ + ":protocol_generated_sources", + ":v8_inspector_compress_protocol_json", + "../../deps/uv", + "../../deps/simdutf", + "//third_party/icu:icuuc", + ] + configs += [ + "../..:node_internal_config", + "../..:node_lib_config", + ] + public_configs = [ ":inspector_config" ] +} + +# This based on the template from //v8/../inspector_protocol.gni +action("protocol_generated_sources") { + # This is to ensure that the output directory exists--the code generator + # doesn't create it. + write_file("$target_gen_dir/$inspector_protocol_package/.dummy", "") + script = "$inspector_protocol_dir/code_generator.py" + + inputs = [ + "$target_gen_dir/node_protocol_config.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/DispatcherBase_cpp.template", + "$inspector_protocol_dir/lib/DispatcherBase_h.template", + "$inspector_protocol_dir/lib/ErrorSupport_cpp.template", + "$inspector_protocol_dir/lib/ErrorSupport_h.template", + "$inspector_protocol_dir/lib/Forward_h.template", + "$inspector_protocol_dir/lib/FrontendChannel_h.template", + "$inspector_protocol_dir/lib/Maybe_h.template", + "$inspector_protocol_dir/lib/Object_cpp.template", + "$inspector_protocol_dir/lib/Object_h.template", + "$inspector_protocol_dir/lib/Parser_cpp.template", + "$inspector_protocol_dir/lib/Parser_h.template", + "$inspector_protocol_dir/lib/Protocol_cpp.template", + "$inspector_protocol_dir/lib/ValueConversions_h.template", + "$inspector_protocol_dir/lib/Values_cpp.template", + "$inspector_protocol_dir/lib/Values_h.template", + "$inspector_protocol_dir/templates/Exported_h.template", + "$inspector_protocol_dir/templates/Imported_h.template", + "$inspector_protocol_dir/templates/TypeBuilder_cpp.template", + "$inspector_protocol_dir/templates/TypeBuilder_h.template", + ] + + deps = [ + ":node_protocol_config", + ":node_protocol_json", + ] + + args = [ + "--jinja_dir", + rebase_path("//third_party/", root_build_dir), # jinja is in chromium's third_party + "--output_base", + rebase_path("$target_gen_dir/src", root_build_dir), + "--config", + rebase_path("$target_gen_dir/node_protocol_config.json", root_build_dir), + ] + + outputs = + get_path_info(rebase_path(rebase_path(_protocol_generated, + ".", + "$inspector_protocol_output/.."), + ".", + "$target_gen_dir/src"), + "abspath") +} + +template("generate_protocol_json") { + copy_target_name = target_name + "_copy" + copy(copy_target_name) { + sources = invoker.sources + outputs = [ + "$target_gen_dir/{{source_file_part}}", + ] + } + copied_pdl = get_target_outputs(":$copy_target_name") + action(target_name) { + deps = [ + ":$copy_target_name", + ] + sources = copied_pdl + outputs = invoker.outputs + script = "$inspector_protocol_dir/convert_protocol_to_json.py" + args = rebase_path(sources + outputs, root_build_dir) + } +} + +copy("node_protocol_config") { + sources = [ + "node_protocol_config.json", + ] + outputs = [ + "$target_gen_dir/{{source_file_part}}", + ] +} + +generate_protocol_json("node_protocol_json") { + sources = [ + "node_protocol.pdl", + ] + outputs = [ + "$target_gen_dir/src/node_protocol.json", + ] +} + +generate_protocol_json("v8_protocol_json") { + sources = [ + "//v8/include/js_protocol.pdl", + ] + outputs = [ + "$target_gen_dir/js_protocol.json", + ] +} + +action("concatenate_protocols") { + deps = [ + ":node_protocol_json", + ":v8_protocol_json", + ] + inputs = [ + "$target_gen_dir/js_protocol.json", + "$target_gen_dir/src/node_protocol.json", + ] + outputs = [ + "$target_gen_dir/concatenated_protocol.json", + ] + script = "//v8/third_party/inspector_protocol/concatenate_protocols.py" + args = rebase_path(inputs + outputs, root_build_dir) +} + +action("v8_inspector_compress_protocol_json") { + deps = [ + ":concatenate_protocols", + ] + inputs = [ + "$target_gen_dir/concatenated_protocol.json", + ] + outputs = [ + "$target_gen_dir/v8_inspector_protocol_json.h", + ] + script = "../../tools/compress_json.py" + args = rebase_path(inputs + outputs, root_build_dir) } diff --git a/src/node_builtins.cc b/src/node_builtins.cc index bbb63df7899d4b9bf80e13eee78453352dd5c75b..804296db12f7864f72648f5f36834a924503e4a6 100644 --- a/src/node_builtins.cc +++ b/src/node_builtins.cc @@ -765,6 +765,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 75a7f3dd89e096d13ad7d70ed29d301cd56315b5..9a20a275fbe5df9f384b7b1d1d26806e7cd05384 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_gn_filenames_json.py b/tools/generate_gn_filenames_json.py new file mode 100755 index 0000000000000000000000000000000000000000..37c16859003e61636fe2f1a4040b1e904c472d0b --- /dev/null +++ b/tools/generate_gn_filenames_json.py @@ -0,0 +1,117 @@ +#!/usr/bin/env python3 +import json +import os +import sys + +import install + +from utils import SearchFiles + +def LoadPythonDictionary(path): + file_string = open(path).read() + try: + file_data = eval(file_string, {'__builtins__': None}, None) + except SyntaxError as e: + e.filename = path + raise + except Exception as e: + raise Exception("Unexpected error while reading %s: %s" % (path, str(e))) + + assert isinstance(file_data, dict), "%s does not eval to a dictionary" % path + + return file_data + + +FILENAMES_JSON_HEADER = ''' +// This file is automatically generated by generate_gn_filenames_json.py +// DO NOT EDIT +'''.lstrip() + +SRC_DIR = os.path.abspath(os.path.join(__file__, '..', '..', '..', '..')) + +def get_out_dir(): + out_dir = 'Testing' + override = os.environ.get('ELECTRON_OUT_DIR') + if override is not None: + out_dir = override + return os.path.join(SRC_DIR, 'out', out_dir) + +if __name__ == '__main__': + node_root_dir = os.path.dirname(os.path.dirname(__file__)) + node_gyp_path = os.path.join(node_root_dir, 'node.gyp') + out = {} + node_gyp = LoadPythonDictionary(node_gyp_path) + node_lib_target = next( + t for t in node_gyp['targets'] + if t['target_name'] == '<(node_lib_target_name)') + node_source_blocklist = { + '<@(library_files)', + '<@(deps_files)', + '<@(node_sources)', + 'common.gypi', + '<(SHARED_INTERMEDIATE_DIR)/node_javascript.cc', + } + + def filter_v8_files(files): + v8_files = [f for f in files if f.startswith('deps/v8/')] + other_files = [f for f in files if not f.startswith('deps/v8/')] + + for i, f in enumerate(v8_files): + if not f.startswith('deps/v8/tools'): + if f.endswith('js'): + v8_files[i] = f.replace('deps/v8/', '../../v8/', 1) + else: + v8_files[i] = f.replace('deps/v8/', '//v8/') + + if any(f == '<@(node_builtin_shareable_builtins)' for f in other_files): + other_files.remove('<@(node_builtin_shareable_builtins)') + shared_builtins = ['deps/cjs-module-lexer/lexer.js', 'deps/cjs-module-lexer/dist/lexer.js', 'deps/undici/undici.js'] + other_files.extend(shared_builtins) + + return v8_files + other_files + + def filter_fs_files(files): + return [f for f in files if f.startswith('lib/internal/fs/')] + ['lib/fs.js'] + ['lib/fs/promises.js'] + + lib_files = SearchFiles('lib', 'js') + out['library_files'] = filter_v8_files(lib_files) + out['library_files'] += filter_v8_files(node_gyp['variables']['deps_files']) + out['node_sources'] = node_gyp['variables']['node_sources'] + + out['fs_files'] = filter_fs_files(out['library_files']) + # fs files are handled separately + out['library_files'] = [f for f in out['library_files'] if f not in out['fs_files']] + + blocklisted_sources = [ + f for f in node_lib_target['sources'] + if f not in node_source_blocklist] + out['node_sources'] += filter_v8_files(blocklisted_sources) + + out['headers'] = [] + def add_headers(options, files, dest_dir): + if 'src/node.h' in files: + files = [f for f in files if f.endswith('.h') and f != 'src/node_version.h'] + elif any(f.startswith('../../v8/') for f in files): + files = [f.replace('../../v8/', '//v8/', 1) for f in files] + if files: + dir_index = next((i for i, d in enumerate(out['headers']) if d['dest_dir'] == dest_dir), -1) + if (dir_index != -1): + out['headers'][dir_index]['files'] += sorted(files) + else: + hs = {'files': sorted(files), 'dest_dir': dest_dir} + out['headers'].append(hs) + + config_gypi_path = os.path.join(get_out_dir(), 'gen', 'config.gypi') + root_gen_dir = os.path.join(node_root_dir, 'out', 'Release', 'gen') + + options = install.parse_options(['install', '--v8-dir', '../../v8', '--config-gypi-path', config_gypi_path, '--headers-only']) + options.variables['node_use_openssl'] = 'false' + options.variables['node_shared_libuv'] = 'false' + # We generate zlib headers in Electron's BUILD.gn. + options.variables['node_shared_zlib'] = '' + + install.headers(options, add_headers) + with open(os.path.join(node_root_dir, 'filenames.json'), 'w') as f: + f.write(FILENAMES_JSON_HEADER) + f.write(json.dumps(out, sort_keys=True, indent=2, separators=(',', ': '))) + f.write('\n') diff --git a/tools/generate_original_fs.py b/tools/generate_original_fs.py new file mode 100644 index 0000000000000000000000000000000000000000..9be3ac447f9a4dde23fefc26e0b922b4ba88f083 --- /dev/null +++ b/tools/generate_original_fs.py @@ -0,0 +1,19 @@ +import os +import sys + +node_root_dir = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) +out_dir = sys.argv[1] +fs_files = sys.argv[2:] + +for fs_file in fs_files: + with open(os.path.join(node_root_dir, fs_file), 'r') as f: + contents = f.read() + original_fs_file = fs_file.replace('internal/fs/', 'internal/original-fs/').replace('lib/fs.js', 'lib/original-fs.js').replace('lib/fs/', 'lib/original-fs/') + + with open(os.path.join(out_dir, fs_file), 'w') as original_f: + original_f.write(contents) + + with open(os.path.join(out_dir, original_fs_file), 'w') as transformed_f: + transformed_contents = contents.replace('internal/fs/', 'internal/original-fs/').replace('require(\'fs', 'require(\'original-fs') + transformed_f.write(transformed_contents) + diff --git a/tools/install.py b/tools/install.py index b132c7bf26c02886a7ab341a1973bf449744ba0f..757e3e60a7be01fac55c5fbb010dbbae00b1bfca 100755 --- a/tools/install.py +++ b/tools/install.py @@ -264,6 +264,7 @@ def headers(options, action): 'include/v8-forward.h', 'include/v8-function-callback.h', 'include/v8-function.h', + 'include/v8-handle-base.h', 'include/v8-initialization.h', 'include/v8-internal.h', 'include/v8-isolate.h', @@ -284,6 +285,8 @@ def headers(options, action): 'include/v8-promise.h', 'include/v8-proxy.h', 'include/v8-regexp.h', + "include/v8-sandbox.h", + "include/v8-source-location.h", 'include/v8-script.h', 'include/v8-snapshot.h', 'include/v8-statistics.h', @@ -390,7 +393,7 @@ def parse_options(args): parser.add_argument('--build-dir', help='the location of built binaries', default='out/Release') parser.add_argument('--v8-dir', help='the location of V8', - default='deps/v8') + default='../../v8') parser.add_argument('--config-gypi-path', help='the location of config.gypi', default='config.gypi') parser.add_argument('--is-win', help='build for Windows target', diff --git a/tools/js2c.cc b/tools/js2c.cc old mode 100644 new mode 100755 index e0f3d8844718ab8a6478c40ff713c1fd6bcff95a..c73a5b666dbaf555c749d836c20a7ae19a840847 --- a/tools/js2c.cc +++ b/tools/js2c.cc @@ -30,6 +30,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; @@ -196,6 +197,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 { @@ -211,7 +213,11 @@ const ThreadsafeCopyOnWrite 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(map); } void RegisterExternalReferencesForInternalizedBuiltinCode( @@ -228,6 +234,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 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(map); +} + +void EmbedderRegisterExternalReferencesForInternalizedBuiltinCode( + ExternalReferenceRegistry* registry) { +%.*s +} + +} // namespace builtins + +} // namespace node +)"; + Fragment Format(const Fragments& definitions, const Fragments& initializers, const Fragments& registrations) { @@ -237,13 +282,12 @@ Fragment Format(const Fragments& definitions, size_t init_size = init_buf.size(); std::vector 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 result(result_size, 0); int r = snprintf(result.data(), result_size, - kTemplate, + only_js ? kEmbedderTemplate: kTemplate, static_cast(def_buf.size()), def_buf.data(), static_cast(init_buf.size()), @@ -834,12 +878,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); } @@ -865,6 +912,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"); @@ -913,6 +962,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"); @@ -932,6 +989,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 @@ -940,4 +998,4 @@ NODE_MAIN(int argc, node::argv_type raw_argv[]) { char** argv; node::FixupMain(argc, raw_argv, &argv); return node::js2c::Main(argc, argv); -} +} \ No newline at end of file