diff options
Diffstat (limited to 'deps/npm/node_modules/node-gyp/lib/build.js')
-rw-r--r-- | deps/npm/node_modules/node-gyp/lib/build.js | 45 |
1 files changed, 43 insertions, 2 deletions
diff --git a/deps/npm/node_modules/node-gyp/lib/build.js b/deps/npm/node_modules/node-gyp/lib/build.js index c29b97e63c..f38ec993a4 100644 --- a/deps/npm/node_modules/node-gyp/lib/build.js +++ b/deps/npm/node_modules/node-gyp/lib/build.js @@ -6,19 +6,20 @@ module.exports = exports = build */ var fs = require('graceful-fs') + , rm = require('rimraf') , path = require('path') , glob = require('glob') , log = require('npmlog') , which = require('which') , mkdirp = require('mkdirp') , win = process.platform == 'win32' - , openbsd = process.platform == 'openbsd' exports.usage = 'Invokes `' + (win ? 'msbuild' : 'make') + '` and builds the module' function build (gyp, argv, callback) { - var makeCommand = openbsd ? 'gmake' : 'make' + var makeCommand = gyp.opts.make || process.env.MAKE + || (process.platform.indexOf('bsd') != -1 ? 'gmake' : 'make') var command = win ? 'msbuild' : makeCommand , buildDir = path.resolve('build') , configPath = path.resolve(buildDir, 'config.gypi') @@ -216,7 +217,47 @@ function build (gyp, argv, callback) { if (signal) { return callback(new Error('`' + command + '` got signal: ' + signal)) } + //symlinkNodeBinding() callback() } + function symlinkNodeBinding () { + var buildDir = path.join('build', buildType, '*.node') + log.verbose('globbing for files', buildDir) + glob(buildDir, function (err, nodeFiles) { + if (err) return callback(err) + function link () { + var file = nodeFiles.shift() + if (!file) { + // no more files to link... done! + return callback() + } + var dest = path.join('build', path.basename(file)) + log.info('symlink', 'creating link %j pointing to %j', file, dest) + var rel = path.relative('build', file) + log.verbose('symlink data', rel) + fs.symlink(rel, dest, 'file', function (err) { + if (err) { + if (err.code === 'EEXIST') { + log.verbose('destination already exists; deleting', dest) + rm(dest, function (err) { + if (err) return callback(err) + log.verbose('delete successful; trying symlink again') + nodeFiles.unshift(file) + link() + }) + } else { + callback(err) + } + return + } + // process the next file, if any + link() + }) + } + // start linking + link() + }) + } + } |