From: Bastien ROUCARIÈS Date: Mon, 20 Apr 2020 07:44:09 +0000 (+0100) Subject: Multiarch search path, arch triplet, DFHS path for modules X-Git-Tag: archive/raspbian/10.19.0_dfsg1-1+rpi1^2~13 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=656eac323971a6ce43a42515e147181c2d8ceb06;p=nodejs.git Multiarch search path, arch triplet, DFHS path for modules Last-Update: 2018-09-30 Forwarded: https://github.com/nodejs/node/issues/22745 Gbp-Pq: Name dfhs_module_path_arch_triplet.patch --- diff --git a/configure.py b/configure.py index 5a786142f..c69cce0e8 100755 --- a/configure.py +++ b/configure.py @@ -80,6 +80,11 @@ parser.add_option('--coverage', dest='coverage', help='Build node with code coverage enabled') +parser.add_option('--arch-triplet', + action='store', + dest='arch_triplet', + help='arch triplet used by distro') + parser.add_option('--debug', action='store_true', dest='debug', @@ -113,6 +118,11 @@ parser.add_option('--gdb', dest='gdb', help='add gdb support') +parser.add_option('--node-relative-path', + action='store', + dest='node_relative_path', + help='Node path(s) used by require, resolved relative to prefix dir.') + parser.add_option('--no-ifaddrs', action='store_true', dest='no_ifaddrs', @@ -1154,6 +1164,17 @@ def configure_node(o): else: o['variables']['node_target_type'] = 'executable' + if options.arch_triplet: + o['variables']['arch_triplet'] = options.arch_triplet + else: + o['variables']['arch_triplet'] = 'unknown-unknown-unknown' + + if options.node_relative_path: + o['variables']['node_relative_path'] = options.node_relative_path + else: + o['variables']['node_relative_path']= '' + + def configure_library(lib, output, pkgname=None): shared_lib = 'shared_' + lib output['variables']['node_' + shared_lib] = b(getattr(options, shared_lib)) diff --git a/lib/internal/modules/cjs/loader.js b/lib/internal/modules/cjs/loader.js index 44c357187..6e6db3953 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -843,6 +843,7 @@ Module.createRequireFromPath = (filename) => { Module._initPaths = function() { const isWindows = process.platform === 'win32'; + const relativePaths = process.config.variables.node_relative_path; var homeDir; var nodePath; @@ -863,7 +864,17 @@ Module._initPaths = function() { } else { prefixDir = path.resolve(process.execPath, '..', '..'); } - var paths = [path.resolve(prefixDir, 'lib', 'node')]; + var postDirs = []; + if (relativePaths) { + relativePaths.split(path.delimiter).map(path => { + if (path) postDirs.push(path); + }); + } else { + postDirs.push(path.join('lib', 'node')); + } + var paths = postDirs.map(postDir => { + return path.resolve(prefixDir, postDir); + }); if (homeDir) { paths.unshift(path.resolve(homeDir, '.node_libraries')); diff --git a/test/parallel/test-module-loading-globalpaths.js b/test/parallel/test-module-loading-globalpaths.js index 284dbb0b3..f96564277 100644 --- a/test/parallel/test-module-loading-globalpaths.js +++ b/test/parallel/test-module-loading-globalpaths.js @@ -73,10 +73,10 @@ if (process.argv[2] === 'child') { // Test module in $PREFIX/lib/node. // Write module into $PREFIX/lib/node. - const expectedString = '$PREFIX/lib/node'; + const expectedString = '$PREFIX/lib/nodejs'; const prefixLibPath = path.join(prefixPath, 'lib'); fs.mkdirSync(prefixLibPath); - const prefixLibNodePath = path.join(prefixLibPath, 'node'); + const prefixLibNodePath = path.join(prefixLibPath, 'nodejs'); fs.mkdirSync(prefixLibNodePath); const pkgPath = path.join(prefixLibNodePath, `${pkgName}.js`); fs.writeFileSync(pkgPath, `exports.string = '${expectedString}';`);