Comparing version 0.1.0 to 0.1.1
@@ -16,3 +16,3 @@ #!/usr/bin/env node | ||
, ansi = require('ansi') | ||
, cursor = ansi(process.stdout) | ||
, cursor = ansi(process.stderr) | ||
@@ -84,3 +84,3 @@ /** | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write(err.message + '\n') | ||
.fg.reset().write(err.stack + '\n') | ||
cursor.fg.red().write('ERR! ') | ||
@@ -94,3 +94,3 @@ .fg.reset().write('not ok\n') | ||
versions.forEach(function (version) { | ||
cursor.write(' ' + version + '\n') | ||
console.log(version) | ||
}) | ||
@@ -119,1 +119,15 @@ } else { | ||
}) | ||
process.on('uncaughtException', function (err) { | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write('UNCAUGHT EXCEPTION:\n') | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write(err.stack + '\n') | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write('This is a bug in `node-gyp`. Please open an Issue:\n') | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write(' https://github.com/TooTallNate/node-gyp/issues\n') | ||
cursor.fg.red().write('ERR! ') | ||
.fg.reset().write('not ok\n') | ||
process.exit(1) | ||
}) |
@@ -10,2 +10,4 @@ | ||
, which = require('which') | ||
, asyncEmit = require('./util/asyncEmit') | ||
, createHook = require('./util/hook') | ||
, win = process.platform == 'win32' | ||
@@ -19,18 +21,28 @@ | ||
var command = win ? 'msbuild' : 'make' | ||
, emitter | ||
// First make sure we have the build command in the PATH | ||
which(command, function (err, execPath) { | ||
if (err) { | ||
if (win && /not found/.test(err.message)) { | ||
// On windows and no 'msbuild' found. Let's guess where it is | ||
return guessMsbuild() | ||
} else { | ||
// Some other error or 'make' not found on Unix, report that to the user | ||
return callback(err) | ||
} | ||
} | ||
gyp.verbose('`which` succeeded' + command, execPath) | ||
build() | ||
createHook('gyp-build.js', function (err, _e) { | ||
if (err) return callback(err) | ||
emitter = _e | ||
doWhich() | ||
}) | ||
function doWhich () { | ||
// First make sure we have the build command in the PATH | ||
which(command, function (err, execPath) { | ||
if (err) { | ||
if (win && /not found/.test(err.message)) { | ||
// On windows and no 'msbuild' found. Let's guess where it is | ||
guessMsbuild() | ||
} else { | ||
// Some other error or 'make' not found on Unix, report that to the user | ||
callback(err) | ||
} | ||
return | ||
} | ||
gyp.verbose('`which` succeeded' + command, execPath) | ||
build() | ||
}) | ||
} | ||
/** | ||
@@ -53,3 +65,3 @@ * Guess the location of the "msbuild.exe" file on Windows. | ||
/** | ||
* The final step. Actually spawn the process and compile the module. | ||
* Actually spawn the process and compile the module. | ||
*/ | ||
@@ -94,5 +106,16 @@ | ||
asyncEmit(emitter, 'before', function (err) { | ||
if (err) return callback(err) | ||
var proc = gyp.spawn(command, argv) | ||
proc.on('exit', onExit) | ||
}) | ||
} | ||
var proc = gyp.spawn(command, argv) | ||
proc.on('exit', function (code, signal) { | ||
/** | ||
* Invoked after the make/msbuild command exits. | ||
*/ | ||
function onExit (code, signal) { | ||
asyncEmit(emitter, 'after', function (err) { | ||
if (err) return callback(err) | ||
if (code !== 0) { | ||
@@ -99,0 +122,0 @@ return callback(new Error('`' + command + '` failed with exit code: ' + code)) |
@@ -12,2 +12,4 @@ | ||
, glob = require('glob') | ||
, asyncEmit = require('./util/asyncEmit') | ||
, createHook = require('./util/hook') | ||
, targets = [] | ||
@@ -44,35 +46,54 @@ | ||
, counter = 0 | ||
, emitter | ||
targets.forEach(function (target) { | ||
gyp.verbose('globbing', target) | ||
glob(target, function (err, result) { | ||
createHook('gyp-clean.js', function (err, _e) { | ||
if (err) return callback(err) | ||
emitter = _e | ||
asyncEmit(emitter, 'before', function (err) { | ||
if (err) return callback(err) | ||
globCount-- | ||
doClean() | ||
}) | ||
}) | ||
files.push.apply(files, result) | ||
result.forEach(function (file) { | ||
counter++ | ||
gyp.verbose('removing', file) | ||
function doClean () { | ||
targets.forEach(function (target) { | ||
gyp.verbose('globbing', target) | ||
rm(file, function (err) { | ||
if (err) return callback(err) | ||
counter-- | ||
gyp.verbose('removed', file) | ||
if (counter === 0) { | ||
gyp.verbose('done removing files', files) | ||
callback() | ||
} | ||
glob(target, function (err, result) { | ||
if (err) return callback(err) | ||
globCount-- | ||
files.push.apply(files, result) | ||
result.forEach(function (file) { | ||
counter++ | ||
gyp.verbose('removing', file) | ||
rm(file, function (err) { | ||
if (err) return callback(err) | ||
counter-- | ||
gyp.verbose('removed', file) | ||
if (counter === 0) { | ||
gyp.verbose('done removing files', files) | ||
after() | ||
} | ||
}) | ||
}) | ||
if (globCount === 0 && counter === 0) { | ||
// Nothing to clean! | ||
gyp.info('nothing to clean') | ||
after() | ||
} | ||
}) | ||
}) | ||
} | ||
if (globCount === 0 && counter === 0) { | ||
// Nothing to clean! | ||
gyp.info('nothing to clean') | ||
callback() | ||
} | ||
function after () { | ||
asyncEmit(emitter, 'after', function (err) { | ||
if (err) return callback(err) | ||
callback() | ||
}) | ||
}) | ||
} | ||
} |
@@ -11,2 +11,5 @@ | ||
, glob = require('glob') | ||
, createHook = require('./util/hook') | ||
, asyncEmit = require('./util/asyncEmit') | ||
, nodeVersion = require('./util/node_version') | ||
, win = process.platform == 'win32' | ||
@@ -20,15 +23,26 @@ | ||
, next = win ? go : cleanupMakefile | ||
, emitter | ||
, version | ||
if (gyp.opts.target) { | ||
// if --target was given, then ensure that version is installed | ||
version = parseFloat(gyp.opts.target) | ||
gyp.verbose('compiling against --target node version', version) | ||
} else { | ||
// if no --target was specified then use the current host node version | ||
version = parseFloat(process.versions.node) | ||
gyp.verbose('no --target version specified, falling back to host node version', version) | ||
// Very first step is to load up the user-defined 'gyp-configure.js' file if it | ||
// exists. We relay filecycle events using the eventemitter returned from this | ||
createHook('gyp-configure.js', function (err, _e) { | ||
if (err) return callback(err) | ||
emitter = _e | ||
getVersion() | ||
}) | ||
function getVersion () { | ||
if (gyp.opts.target) { | ||
// if --target was given, then ensure that version is installed | ||
version = nodeVersion.parse(gyp.opts.target) | ||
gyp.verbose('compiling against --target node version', version) | ||
} else { | ||
// if no --target was specified then use the current host node version | ||
version = nodeVersion.parse(process.versions.node) | ||
gyp.verbose('no --target version specified, falling back to host node version', version) | ||
} | ||
gyp.opts.ensure = true | ||
gyp.commands.install([ version ], next) | ||
} | ||
gyp.opts.ensure = true | ||
gyp.commands.install([ version ], next) | ||
@@ -68,7 +82,6 @@ /** | ||
var target = String(version) | ||
, devDir = path.join(process.env.HOME, '.node-gyp', target) | ||
var devDir = path.join(process.env.HOME, '.node-gyp', version) | ||
, gyp_addon = path.join(devDir, 'tools', 'gyp_addon') | ||
if (win && version < 0.8) { | ||
if (win && nodeVersion.lessThan(version, 0, 8)) { | ||
gyp.verbose('on Windows and target version is less than 0.8; applying #2685 patch') | ||
@@ -82,3 +95,3 @@ // if < 0.8, we need to manually apply the patch at joyent/node#2685, | ||
if (!win && version < 0.8) { | ||
if (!win && nodeVersion.lessThan(version, 0, 8)) { | ||
gyp.verbose('on Unix and target version is less than 0.8; applying #2722 patch') | ||
@@ -121,6 +134,20 @@ argv.push('-I') | ||
argv.unshift(gyp_addon) | ||
var cp = gyp.spawn(python, argv) | ||
cp.on('exit', function (code, signal) { | ||
if (code !== 0) { | ||
asyncEmit(emitter, 'before', function (err) { | ||
if (err) return callback(err) | ||
var cp = gyp.spawn(python, argv) | ||
cp.on('exit', onCpExit) | ||
}) | ||
} | ||
/** | ||
* Called when the `gyp_addon` child process exits. | ||
*/ | ||
function onCpExit (code, signal) { | ||
asyncEmit(emitter, 'after', function (err) { | ||
if (err) { | ||
callback(err) | ||
} else if (code !== 0) { | ||
callback(new Error('`gyp_addon` failed with exit code: ' + code)) | ||
@@ -132,6 +159,6 @@ } else if (process.platform == 'darwin' && gyp.opts.arch != 'ia32') { | ||
} else { | ||
// we're done | ||
callback() | ||
} | ||
}) | ||
} | ||
@@ -146,3 +173,3 @@ | ||
function remove_i386 () { | ||
glob('*.target.gyp.mk', function (err, files) { | ||
glob('**/*.target.gyp.mk', function (err, files) { | ||
if (err) return callback(err) | ||
@@ -149,0 +176,0 @@ var count = files.length |
@@ -18,2 +18,3 @@ | ||
, minimatch = require('minimatch') | ||
, nodeVersion = require('./util/node_version') | ||
, distUrl = 'http://nodejs.org/dist' | ||
@@ -33,20 +34,28 @@ , win = process.platform == 'win32' | ||
// ensure no double-callbacks happen | ||
function cb () { | ||
function cb (err) { | ||
if (cb.done) return | ||
cb.done = true | ||
callback.apply(null, arguments) | ||
if (err) { | ||
gyp.verbose('got an error, rolling back install') | ||
// roll-back the install if anything went wrong | ||
gyp.commands.remove([ version ], function (err2) { | ||
callback(err) | ||
}) | ||
} else { | ||
callback.apply(null, arguments) | ||
} | ||
} | ||
var version = parseFloat(argv[0] || gyp.opts.target) | ||
var version = nodeVersion.parse(argv[0] || gyp.opts.target) | ||
if (isNaN(version)) { | ||
return cb(new Error('You must specify a version to install (like "0.7")')) | ||
if (!version) { | ||
return callback(new Error('You must specify a version to install (like "0.7")')) | ||
} | ||
if (version < 0.6) { | ||
return cb(new Error('Minimum target version is `0.6` or greater. Got: ' + version)) | ||
if (nodeVersion.lessThan(version, 0, 6)) { | ||
return callback(new Error('Minimum target version is `0.6` or greater. Got: ' + version)) | ||
} | ||
// TODO: Make ~/.node-gyp configurable | ||
var devDir = path.join(process.env.HOME, '.node-gyp', version.toString()) | ||
var devDir = path.join(process.env.HOME, '.node-gyp', version) | ||
@@ -56,5 +65,7 @@ // If '--ensure' was passed, then don't *always* install the version, | ||
if (gyp.opts.ensure) { | ||
gyp.verbose('--ensure was passed, so won\'t reinstall if already installed') | ||
fs.stat(devDir, function (err, stat) { | ||
if (err) { | ||
if (err.code == 'ENOENT') { | ||
gyp.verbose('version not already installed, continuing with install', version) | ||
go() | ||
@@ -85,3 +96,3 @@ } else { | ||
// TODO: download the newest version instead of the .0 release | ||
var tarballUrl = distUrl + '/v' + version.toFixed(1) + '.0/node-v' + version.toFixed(1) + '.0.tar.gz' | ||
var tarballUrl = distUrl + '/v' + version + '.0/node-v' + version + '.0.tar.gz' | ||
, badDownload = false | ||
@@ -102,5 +113,3 @@ , parser = tar.Parse() | ||
badDownload = true | ||
gyp.commands.remove([ version ], function (err2) { | ||
cb(err || new Error(res.statusCode + ' status code downloading tarball')) | ||
}) | ||
cb(err || new Error(res.statusCode + ' status code downloading tarball')) | ||
} | ||
@@ -155,3 +164,3 @@ } | ||
if (version < 0.7) { | ||
if (nodeVersion.lessThan(version, 0, 7)) { | ||
// copy over gyp_addon, addon.gypi and common.gypi | ||
@@ -168,3 +177,3 @@ async++ | ||
if (win && version < 0.8) { | ||
if (win && nodeVersion.lessThan(version, 0, 8)) { | ||
// before node 0.8 we need to manually link to node.lib | ||
@@ -174,3 +183,3 @@ async++ | ||
} | ||
if (!win && version < 0.8) { | ||
if (!win && nodeVersion.lessThan(version, 0, 8)) { | ||
async++ | ||
@@ -177,0 +186,0 @@ copy2722(deref) |
@@ -120,3 +120,3 @@ | ||
console.error(usage) | ||
console.log(usage) | ||
process.exit(4) | ||
@@ -123,0 +123,0 @@ } |
@@ -13,2 +13,3 @@ | ||
, path = require('path') | ||
, nodeVersion = require('./util/node_version') | ||
@@ -22,4 +23,4 @@ function remove (gyp, argv, callback) { | ||
var version = parseFloat(argv[0] || gyp.opts.target) | ||
, versionPath = path.join(nodeGypDir, version.toString()) | ||
var version = nodeVersion.parse(argv[0] || gyp.opts.target) | ||
, versionPath = path.join(nodeGypDir, version) | ||
@@ -26,0 +27,0 @@ gyp.verbose('removing development files for version', version) |
{ "name": "node-gyp" | ||
, "description": "Node.js native addon build tool" | ||
, "keywords": [ "native", "addon", "module", "c", "c++", "bindings", "gyp" ] | ||
, "version": "0.1.0" | ||
, "version": "0.1.1" | ||
, "author": "Nathan Rajlich <nathan@tootallnate.net> (http://tootallnate.net)" | ||
@@ -6,0 +6,0 @@ , "repository": { "type": "git", "url": "git://github.com/TooTallNate/node-gyp.git" } |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
47343
19
1065
16