From cb88e99bfec7d5d1dfada57a05f7a149461e0abf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Stan=C4=9Bk?= Date: Thu, 22 May 2025 14:16:25 +0200 Subject: [PATCH] build: search for libnode.so in multiple places As the actual location of built libnode.so may differ depending on which system was used to orchestrate the build (ninja or make), multiple places should be searched for it's location. PR-URL: https://github.com/nodejs/node/pull/58213 Reviewed-By: James M Snell Reviewed-By: Richard Lau --- tools/install.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/tools/install.py b/tools/install.py index c067b65ed5d..24c297d60a4 100755 --- a/tools/install.py +++ b/tools/install.py @@ -181,9 +181,19 @@ def files(options, action): link_path = abspath(options.install_path, 'lib/libnode.so') try_symlink(options, so_name, link_path) else: - output_lib = 'libnode.' + options.variables.get('shlib_suffix') - action(options, [os.path.join(options.build_dir, output_lib)], - os.path.join(options.variables.get('libdir'), output_lib)) + # Ninja and Makefile generators output the library in different directories; + # find out which one we have, and install first found + output_lib_name = 'libnode.' + options.variables.get('shlib_suffix') + output_lib_candidate_paths = [ + os.path.join(options.build_dir, output_lib_name), + os.path.join(options.build_dir, "lib", output_lib_name), + ] + try: + output_lib = next(filter(os.path.exists, output_lib_candidate_paths)) + except StopIteration as not_found: + raise RuntimeError("No libnode.so to install!") from not_found + action(options, [output_lib], + os.path.join(options.variables.get('libdir'), output_lib_name)) action(options, [os.path.join(options.v8_dir, 'tools/gdbinit')], 'share/doc/node/') action(options, [os.path.join(options.v8_dir, 'tools/lldb_commands.py')], 'share/doc/node/')