From: Debian Javascript Maintainers Date: Thu, 28 Feb 2019 14:52:30 +0000 (+0000) Subject: dfhs_module_path_arch_triplet X-Git-Tag: archive/raspbian/10.15.2_dfsg-1+rpi1^2~14 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=53c0b555e83f3fae82b0dbd1287977192e0a0275;p=nodejs.git dfhs_module_path_arch_triplet Gbp-Pq: Name dfhs_module_path_arch_triplet.patch --- diff --git a/configure.py b/configure.py index b62be2302..f0cc9aa3c 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', @@ -1124,6 +1134,16 @@ 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): 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 fb3770b72..cc1352ad8 100644 --- a/lib/internal/modules/cjs/loader.js +++ b/lib/internal/modules/cjs/loader.js @@ -754,6 +754,7 @@ Module.createRequireFromPath = (filename) => { Module._initPaths = function() { const isWindows = process.platform === 'win32'; + const relativePaths = process.config.variables.node_relative_path; var homeDir; var nodePath; @@ -774,7 +775,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}';`);