Files
node/node.gni
Shelley Vohr 6f38736d63 build: allow linking shared dependencies in the GN build
The GN build always compiles the bundled copies of brotli, c-ares,
HdrHistogram, llhttp, libuv, nghttp2, SQLite and zstd, so anyone
packaging a GN-built Node.js for a Linux distribution has no
counterpart to configure's --shared-* options.

Add node_shared_* args named after the GYP variables. When one is set,
that dependency's GN template defines its target as a group carrying a
pkg-config config instead of the bundled sources, so every existing
"deps/<name>" reference picks up the system library without further
changes, and config.gypi reports the choice like a GYP build does.

Refs: https://github.com/nodejs/node/pull/55903
Signed-off-by: Shelley Vohr <[email protected]>
PR-URL: https://github.com/nodejs/node/pull/65797
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: James M Snell <[email protected]>
2026-09-07 07:19:20 +00:00

101 lines
3.5 KiB
Plaintext

# This file is used by GN for building, which is NOT the build system used for
# building official binaries.
# Please take a look at node.gyp if you are making changes to build system.
# Embedder options.
declare_args() {
# The location of Node.js in source code tree.
node_path = "//node"
# The location of V8 - use the one from node's deps by default.
node_v8_path = "$node_path/deps/v8"
# The location of OpenSSL - use the one from node's deps by default.
node_openssl_path = "$node_path/deps/openssl"
# The location of simdutf - use the one from node's deps by default.
node_simdutf_path = "//third_party/simdutf"
# The location of inspector_protocol - use the one from node's deps by default.
node_inspector_protocol_path = "//third_party/inspector_protocol"
# The NODE_MODULE_VERSION defined in node_version.h.
node_module_version = exec_script("$node_path/tools/getmoduleversion.py", [], "value")
# Support for external shareable builtins.
# TODO(zcbenz): This is currently copied from configure.py, we should share
# the list between configure.py and GN configurations.
node_builtin_shareable_builtins = [
"deps/undici/undici.js",
"deps/amaro/dist/index.js",
]
}
# Equivalent of gyp file's configurations.
declare_args() {
# Enable the V8 inspector protocol for use with node.
node_enable_inspector = true
# Build node with SSL support.
# The variable is called "openssl" for parity with node's GYP build.
node_use_openssl = true
# Build node with SQLite support.
node_use_sqlite = true
# Build node with FFI support.
# Disabled in GN builds. The unofficial GN build does not support node:ffi.
node_use_ffi = false
# Link against a shared libffi when FFI support is enabled.
# Unsupported in GN builds.
node_shared_ffi = false
# 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.
node_use_v8_platform = true
# 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 = ""
# Use code cache to speed up startup. Disabled for cross compilation.
node_use_node_code_cache = host_os == target_os && host_cpu == target_cpu
# Use snapshot to speed up startup.
# TODO(zcbenz): There are few broken things for now:
# 1. cross-os compilation is not supported.
# 2. node_mksnapshot crashes when cross-compiling for x64 from arm64.
node_use_node_snapshot = (host_os == target_os) && !(host_cpu == "arm64" && target_cpu == "x64")
# Build with Amaro (TypeScript utils).
node_use_amaro = true
}
# Link against shared copies of the bundled dependencies instead of building
# them, like configure's --shared-* options. The libraries are looked up with
# pkg-config, so these are meant for Linux distribution builds.
declare_args() {
node_shared_brotli = false
node_shared_cares = false
node_shared_hdr_histogram = false
node_shared_http_parser = false
node_shared_libuv = false
node_shared_nghttp2 = false
node_shared_sqlite = false
node_shared_zstd = false
}
assert(!node_enable_inspector || node_use_openssl,
"node_enable_inspector requires node_use_openssl")