dfhs_module_path_arch_triplet
authorDebian Javascript Maintainers <pkg-javascript-devel@lists.alioth.debian.org>
Thu, 28 Feb 2019 14:52:30 +0000 (14:52 +0000)
committerJérémy Lal <kapouer@melix.org>
Thu, 28 Feb 2019 14:52:30 +0000 (14:52 +0000)
Gbp-Pq: Name dfhs_module_path_arch_triplet.patch

configure.py
lib/internal/modules/cjs/loader.js
test/parallel/test-module-loading-globalpaths.js

index b62be2302c846dbd00f9a33b66ff18908bf5be39..f0cc9aa3c82a738b73655213efa291d73c9b1f5c 100755 (executable)
@@ -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))
index fb3770b7299d4e7c13174e6d3277e0e9292095d2..cc1352ad83b12a8f6646c16070c7c890e118cca1 100644 (file)
@@ -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'));
index 284dbb0b3cd564625d7e7a72c1a311f4213d6742..f965642774a6476527c5bcbc4dfeeff762a3bf1d 100644 (file)
@@ -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}';`);