Skip to content

Commit ce19715

Browse files
committed
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 <[email protected]> PR-URL: nodejs#54646 Reviewed-By: Marco Ippolito <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 24302c9 commit ce19715

7 files changed

+22
-8
lines changed

configure.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,11 @@
5858
icu_versions = json.loads((tools_path / 'icu' / 'icu_versions.json').read_text(encoding='utf-8'))
5959
maglev_enabled_architectures = ('x64', 'arm', 'arm64')
6060

61+
# builtins may be removed later if they have been disabled by options
6162
shareable_builtins = {'cjs_module_lexer/lexer': 'deps/cjs-module-lexer/lexer.js',
6263
'cjs_module_lexer/dist/lexer': 'deps/cjs-module-lexer/dist/lexer.js',
63-
'undici/undici': 'deps/undici/undici.js'
64+
'undici/undici': 'deps/undici/undici.js',
65+
'amaro/dist/index': 'deps/amaro/dist/index.js'
6466
}
6567

6668
# create option groups
@@ -2202,6 +2204,10 @@ def make_bin_override():
22022204
configure_inspector(output)
22032205
configure_section_file(output)
22042206

2207+
# remove builtins that have been disabled
2208+
if options.without_amaro:
2209+
del shareable_builtins['amaro/dist/index']
2210+
22052211
# configure shareable builtins
22062212
output['variables']['node_builtin_shareable_builtins'] = []
22072213
for builtin, value in shareable_builtins.items():

node.gni

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ declare_args() {
2020
"deps/cjs-module-lexer/lexer.js",
2121
"deps/cjs-module-lexer/dist/lexer.js",
2222
"deps/undici/undici.js",
23+
"deps/amaro/dist/index.js",
2324
]
2425
}
2526

node.gyp

-5
Original file line numberDiff line numberDiff line change
@@ -466,11 +466,6 @@
466466
}, {
467467
'use_openssl_def%': 0,
468468
}],
469-
[ 'node_use_amaro=="true"', {
470-
'deps_files': [
471-
'deps/amaro/dist/index.js',
472-
]
473-
} ]
474469
],
475470
},
476471

src/node_builtins.cc

+7
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,13 @@ BuiltinLoader::BuiltinLoader()
5050
AddExternalizedBuiltin("internal/deps/undici/undici",
5151
STRINGIFY(NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH));
5252
#endif // NODE_SHARED_BUILTIN_UNDICI_UNDICI_PATH
53+
54+
#if HAVE_AMARO
55+
#ifdef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
56+
AddExternalizedBuiltin("internal/deps/amaro/dist/index",
57+
STRINGIFY(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH));
58+
#endif // NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
59+
#endif // HAVE_AMARO
5360
}
5461

5562
bool BuiltinLoader::Exists(const char* id) {

src/node_metadata.cc

+2
Original file line numberDiff line numberDiff line change
@@ -127,9 +127,11 @@ Metadata::Versions::Versions() {
127127
cjs_module_lexer = CJS_MODULE_LEXER_VERSION;
128128
uvwasi = UVWASI_VERSION_STRING;
129129

130+
#ifndef NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH
130131
#if HAVE_AMARO
131132
amaro = AMARO_VERSION;
132133
#endif
134+
#endif
133135

134136
#if HAVE_OPENSSL
135137
openssl = GetOpenSSLVersion();

src/node_metadata.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ namespace node {
2727
#define NODE_HAS_RELEASE_URLS
2828
#endif
2929

30-
#if HAVE_AMARO
30+
#if HAVE_AMARO && !defined(NODE_SHARED_BUILTIN_AMARO_DIST_INDEX_PATH)
3131
#define NODE_VERSIONS_KEY_AMARO(V) V(amaro)
3232
#else
3333
#define NODE_VERSIONS_KEY_AMARO(V)

test/parallel/test-process-versions.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ const expected_keys = [
2727
];
2828

2929
const hasUndici = process.config.variables.node_builtin_shareable_builtins.includes('deps/undici/undici.js');
30+
const hasAmaro = process.config.variables.node_builtin_shareable_builtins.includes('deps/amaro/dist/index.js');
3031

3132
if (process.config.variables.node_use_amaro) {
32-
expected_keys.push('amaro');
33+
if (hasAmaro) {
34+
expected_keys.push('amaro');
35+
}
3336
}
3437
if (hasUndici) {
3538
expected_keys.push('undici');

0 commit comments

Comments
 (0)