build: search for libnode.so in multiple places · nodejs/node@22e9736

Original file line numberDiff line numberDiff line change

@@ -181,9 +181,19 @@ def files(options, action):

181181

link_path = abspath(options.install_path, 'lib/libnode.so')

182182

try_symlink(options, so_name, link_path)

183183

else:

184-

output_lib = 'libnode.' + options.variables.get('shlib_suffix')

185-

action(options, [os.path.join(options.build_dir, output_lib)],

186-

os.path.join(options.variables.get('libdir'), output_lib))

184+

# Ninja and Makefile generators output the library in different directories;

185+

# find out which one we have, and install first found

186+

output_lib_name = 'libnode.' + options.variables.get('shlib_suffix')

187+

output_lib_candidate_paths = [

188+

os.path.join(options.build_dir, output_lib_name),

189+

os.path.join(options.build_dir, "lib", output_lib_name),

190+

]

191+

try:

192+

output_lib = next(filter(os.path.exists, output_lib_candidate_paths))

193+

except StopIteration as not_found:

194+

raise RuntimeError("No libnode.so to install!") from not_found

195+

action(options, [output_lib],

196+

os.path.join(options.variables.get('libdir'), output_lib_name))

187197
188198

action(options, [os.path.join(options.v8_dir, 'tools/gdbinit')], 'share/doc/node/')

189199

action(options, [os.path.join(options.v8_dir, 'tools/lldb_commands.py')], 'share/doc/node/')