deps: allow amaro to be externalizable

- allow amaro to be externalized like other builtins
  containing WASM. More context is available in
  https://github.com/nodejs/node/blob/main/doc/contributing/maintaining/maintaining-dependencies.md#supporting-externalizable-dependencies-with-javascript-code

Signed-off-by: Michael Dawson <midawson@redhat.com>
PR-URL: https://github.com/nodejs/node/pull/54646
Reviewed-By: Marco Ippolito <marcoippolito54@gmail.com>
Reviewed-By: Richard Lau <rlau@redhat.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
This commit is contained in:
Michael Dawson 2024-08-29 20:20:08 +00:00
parent 24302c9fe9
commit ce19715cbb
7 changed files with 22 additions and 8 deletions

View File

@ -58,9 +58,11 @@ valid_intl_modes = ('none', 'small-icu', 'full-icu', 'system-icu')
icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8'))
maglev_enabled_architectures = ('x64', 'arm', 'arm64')
# builtins may be removed later if they have been disabled by options
shareable_builtins = {'cjs_module_lexer/lexer': 'deps/cjs-module-lexer/lexer.js',
'cjs_module_lexer/dist/lexer': 'deps/cjs-module-lexer/dist/lexer.js',
'undici/undici': 'deps/undici/undici.js'
'undici/undici': 'deps/undici/undici.js',
'amaro/dist/index': 'deps/amaro/dist/index.js'
}
# create option groups
@ -2202,6 +2204,10 @@ configure_static(output)
configure_inspector(output)
configure_section_file(output)
# remove builtins that have been disabled
if options.without_amaro:
del shareable_builtins['amaro/dist/index']
# configure shareable builtins
output['variables']['node_builtin_shareable_builtins'] = []
for builtin, value in shareable_builtins.items():

View File

@ -20,6 +20,7 @@ declare_args() {
"deps/cjs-module-lexer/lexer.js",
"deps/cjs-module-lexer/dist/lexer.js",
"deps/undici/undici.js",
"deps/amaro/dist/index.js",
]
}

View File

@ -466,11 +466,6 @@
}, {
'use_openssl_def%': 0,
}],
[ 'node_use_amaro=="true"', {
'deps_files': [
'deps/amaro/dist/index.js',
]
} ]
],
},

View File

@ -50,6 +50,13 @@ BuiltinLoader::BuiltinLoader()
AddExternalizedBuiltin("internal/deps/undici/undici",
STRINGIFY(NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH));
#endif // NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
#if HAVE_AMARO
#ifdef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
AddExternalizedBuiltin("internal/deps/amaro/dist/index",
STRINGIFY(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH));
#endif // NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
#endif // HAVE_AMARO
}
bool BuiltinLoader::Exists(const char* id) {

View File

@ -127,9 +127,11 @@ Metadata::Versions::Versions() {
cjs_module_lexer = CJS_MODULE_LEXER_VERSION;
uvwasi = UVWASI_VERSION_STRING;
#ifndef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
#if HAVE_AMARO
amaro = AMARO_VERSION;
#endif
#endif
#if HAVE_OPENSSL
openssl = GetOpenSSLVersion();

View File

@ -27,7 +27,7 @@ namespace node {
#define NODE_HAS_RELEASE_URLS
#endif
#if HAVE_AMARO
#if HAVE_AMARO && !defined(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)
#define NODE_VERSIONS_KEY_AMARO(V) V(amaro)
#else
#define NODE_VERSIONS_KEY_AMARO(V)

View File

@ -27,9 +27,12 @@ const expected_keys = [
];
const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
const hasAmaro = process.config.variables.node_builtin_shareable_builtins.includes('deps/amaro/dist/index.js');
if (process.config.variables.node_use_amaro) {
if (hasAmaro) {
expected_keys.push('amaro');
}
}
if (hasUndici) {
expected_keys.push('undici');