-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
For AIX we need to use gmake For AIX we need to set up the path to the exp file which contains the symbols needed for linking. The file will either be in one of the following depeding on whether are are in installed or development environment: - the include/node directory - the out/Release directory
- Loading branch information
Showing
5 changed files
with
221 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
var path = require('path') | ||
, log = require('npmlog') | ||
|
||
function findNodeDirectory(scriptLocation, processObj) { | ||
// set dirname and process if not passed in | ||
// this facilitates regression tests | ||
if (scriptLocation === undefined) { | ||
scriptLocation = __dirname | ||
} | ||
if (processObj === undefined) { | ||
processObj = process | ||
} | ||
|
||
// Have a look to see what is above us, to try and work out where we are | ||
npm_parent_directory = path.join(scriptLocation, '../../../..') | ||
log.verbose('node-gyp root', 'npm_parent_directory is ' | ||
+ path.basename(npm_parent_directory)) | ||
node_root_dir = "" | ||
|
||
log.verbose('node-gyp root', 'Finding node root directory') | ||
if (path.basename(npm_parent_directory) === 'deps') { | ||
// We are in a build directory where this script lives in | ||
// deps/npm/node_modules/node-gyp/lib | ||
node_root_dir = path.join(npm_parent_directory, '..') | ||
log.verbose('node-gyp root', 'in build directory, root = ' | ||
+ node_root_dir) | ||
} else if (path.basename(npm_parent_directory) === 'node_modules') { | ||
// We are in a node install directory where this script lives in | ||
// lib/node_modules/npm/node_modules/node-gyp/lib or | ||
// node_modules/npm/node_modules/node-gyp/lib depending on the | ||
// platform | ||
if (processObj.platform === 'win32') { | ||
node_root_dir = path.join(npm_parent_directory, '..') | ||
} else { | ||
node_root_dir = path.join(npm_parent_directory, '../..') | ||
} | ||
log.verbose('node-gyp root', 'in install directory, root = ' | ||
+ node_root_dir) | ||
} else { | ||
// We don't know where we are, try working it out from the location | ||
// of the node binary | ||
var node_dir = path.dirname(processObj.execPath) | ||
var directory_up = path.basename(node_dir) | ||
if (directory_up === 'bin') { | ||
node_root_dir = path.join(node_dir, '..') | ||
} else if (directory_up === 'Release' || directory_up === 'Debug') { | ||
// If we are a recently built node, and the directory structure | ||
// is that of a repository. If we are on Windows then we only need | ||
// to go one level up, everything else, two | ||
if (processObj.platform === 'win32') { | ||
node_root_dir = path.join(node_dir, '..') | ||
} else { | ||
node_root_dir = path.join(node_dir, '../..') | ||
} | ||
} | ||
// Else return the default blank, "". | ||
} | ||
return node_root_dir | ||
} | ||
|
||
module.exports = findNodeDirectory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
var test = require('tape') | ||
var path = require('path') | ||
var findNodeDirectory = require('../lib/find-node-directory') | ||
|
||
var platforms = ['darwin', 'freebsd', 'linux', 'sunos', 'win32', 'aix'] | ||
|
||
// we should find the directory based on the directory | ||
// the script is running in and it should match the layout | ||
// in a build tree where npm is installed in | ||
// .... /deps/npm | ||
test('test find-node-directory - node install', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} | ||
t.equal( | ||
findNodeDirectory('/x/deps/npm/node_modules/node-gyp/lib', processObj), | ||
path.join('/x')) | ||
} | ||
}) | ||
|
||
// we should find the directory based on the directory | ||
// the script is running in and it should match the layout | ||
// in an installed tree where npm is installed in | ||
// .... /lib/node_modules/npm or .../node_modules/npm | ||
// depending on the patform | ||
test('test find-node-directory - node build', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} | ||
if (platforms[next] === 'win32') { | ||
t.equal( | ||
findNodeDirectory('/y/node_modules/npm/node_modules/node-gyp/lib', | ||
processObj), path.join('/y')) | ||
} else { | ||
t.equal( | ||
findNodeDirectory('/y/lib/node_modules/npm/node_modules/node-gyp/lib', | ||
processObj), path.join('/y')) | ||
} | ||
} | ||
}) | ||
|
||
// we should find the directory based on the execPath | ||
// for node and match because it was in the bin directory | ||
test('test find-node-directory - node in bin directory', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} | ||
t.equal( | ||
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), | ||
path.join('/x/y')) | ||
} | ||
}) | ||
|
||
// we should find the directory based on the execPath | ||
// for node and match because it was in the Release directory | ||
test('test find-node-directory - node in build release dir', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj | ||
if (platforms[next] === 'win32') { | ||
processObj = {execPath: '/x/y/Release/node', platform: platforms[next]} | ||
} else { | ||
processObj = {execPath: '/x/y/out/Release/node', | ||
platform: platforms[next]} | ||
} | ||
|
||
t.equal( | ||
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), | ||
path.join('/x/y')) | ||
} | ||
}) | ||
|
||
// we should find the directory based on the execPath | ||
// for node and match because it was in the Debug directory | ||
test('test find-node-directory - node in Debug release dir', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj | ||
if (platforms[next] === 'win32') { | ||
processObj = {execPath: '/a/b/Debug/node', platform: platforms[next]} | ||
} else { | ||
processObj = {execPath: '/a/b/out/Debug/node', platform: platforms[next]} | ||
} | ||
|
||
t.equal( | ||
findNodeDirectory('/nothere/npm/node_modules/node-gyp/lib', processObj), | ||
path.join('/a/b')) | ||
} | ||
}) | ||
|
||
// we should not find it as it will not match based on the execPath nor | ||
// the directory from which the script is running | ||
test('test find-node-directory - not found', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj = {execPath: '/x/y/z/y', platform:next} | ||
t.equal(findNodeDirectory('/a/b/c/d', processObj), '') | ||
} | ||
}) | ||
|
||
// we should find the directory based on the directory | ||
// the script is running in and it should match the layout | ||
// in a build tree where npm is installed in | ||
// .... /deps/npm | ||
// same test as above but make sure additional directory entries | ||
// don't cause an issue | ||
test('test find-node-directory - node install', function (t) { | ||
t.plan(platforms.length) | ||
for (var next = 0; next < platforms.length; next++) { | ||
var processObj = {execPath: '/x/y/bin/node', platform: platforms[next]} | ||
t.equal( | ||
findNodeDirectory('/x/y/z/a/b/c/deps/npm/node_modules/node-gyp/lib', | ||
processObj), path.join('/x/y/z/a/b/c')) | ||
} | ||
}) |