mirror of
https://github.com/nodejs/node.git
synced 2025-05-08 01:35:51 +00:00

When building the node with `--shared` option, the major output is the shared library. However, we still build a node executable which links to the shared lib. It's for testing purpose. When testing with the executable, some test cases move/copy the executable, change the relative path to the shared library and fail. Using lib path env would solve the issue. However, in macOS, need to change the install name for the shared library and use rpath in the executable. In AIX, `-brtl` linker option rebinds the symbols in the executable and addon modules could use them. Signed-off-by: Yihong Wang <yh.wang@ibm.com> PR-URL: https://github.com/nodejs/node/pull/18626 Refs: https://github.com/nodejs/node/issues/18535 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
30 lines
892 B
JavaScript
30 lines
892 B
JavaScript
/* eslint-disable required-modules */
|
|
'use strict';
|
|
const path = require('path');
|
|
|
|
// If node executable is linked to shared lib, need to take care about the
|
|
// shared lib path.
|
|
exports.addLibraryPath = function(env) {
|
|
if (!process.config.variables.node_shared) {
|
|
return;
|
|
}
|
|
|
|
env = env || process.env;
|
|
|
|
env.LD_LIBRARY_PATH =
|
|
(env.LD_LIBRARY_PATH ? env.LD_LIBRARY_PATH + path.delimiter : '') +
|
|
path.join(path.dirname(process.execPath), 'lib.target');
|
|
// For AIX.
|
|
env.LIBPATH =
|
|
(env.LIBPATH ? env.LIBPATH + path.delimiter : '') +
|
|
path.join(path.dirname(process.execPath), 'lib.target');
|
|
// For Mac OSX.
|
|
env.DYLD_LIBRARY_PATH =
|
|
(env.DYLD_LIBRARY_PATH ? env.DYLD_LIBRARY_PATH + path.delimiter : '') +
|
|
path.dirname(process.execPath);
|
|
// For Windows.
|
|
env.PATH =
|
|
(env.PATH ? env.PATH + path.delimiter : '') +
|
|
path.dirname(process.execPath);
|
|
};
|