function build (gyp, argv, callback) {
var makeCommand = gyp.opts.make || process.env.MAKE
- || (process.platform.indexOf('bsd') != -1 ? 'gmake' : 'make')
+ || (process.platform.indexOf('bsd') != -1 && process.platform.indexOf('kfreebsd') == -1 ? 'gmake' : 'make')
, command = win ? 'msbuild' : makeCommand
, buildDir = path.resolve('build')
, configPath = path.resolve(buildDir, 'config.gypi')
function findMsbuild () {
log.verbose('could not find "msbuild.exe" in PATH - finding location in registry')
var notfoundErr = new Error('Can\'t find "msbuild.exe". Do you have Microsoft Visual Studio C++ 2008+ installed?')
- exec('reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s', function (err, stdout, stderr) {
- var reVers = /Software\\Microsoft\\MSBuild\\ToolsVersions\\([^\r]+)\r\n\s+MSBuildToolsPath\s+REG_SZ\s+([^\r]+)/gi
+ var cmd = 'reg query "HKLM\\Software\\Microsoft\\MSBuild\\ToolsVersions" /s'
+ if (process.arch !== 'ia32')
+ cmd += ' /reg:32'
+ exec(cmd, function (err, stdout, stderr) {
+ var reVers = /ToolsVersions\\([^\\]+)$/i
+ , rePath = /\r\n[ \t]+MSBuildToolsPath[ \t]+REG_SZ[ \t]+([^\r]+)/i
, msbuilds = []
, r
, msbuildPath
if (err) {
return callback(notfoundErr)
}
- while (r = reVers.exec(stdout)) {
- if (parseFloat(r[1], 10) >= 3.5) {
- msbuilds.push({
- version: parseFloat(r[1], 10),
- path: r[2]
- })
+ stdout.split('\r\n\r\n').forEach(function(l) {
+ if (!l) return
+ l = l.trim()
+ if (r = reVers.exec(l.substring(0, l.indexOf('\r\n')))) {
+ var ver = parseFloat(r[1], 10)
+ if (ver >= 3.5) {
+ if (r = rePath.exec(l)) {
+ msbuilds.push({
+ version: ver,
+ path: r[1]
+ })
+ }
+ }
}
- }
+ })
msbuilds.sort(function (x, y) {
return (x.version < y.version ? -1 : 1)
})
;(function verifyMsbuild () {
+ if (!msbuilds.length) return callback(notfoundErr)
msbuildPath = path.resolve(msbuilds.pop().path, 'msbuild.exe')
fs.stat(msbuildPath, function (err, stat) {
if (err) {
}
/**
- * Copies the node.lib file for the current target architecture into the
+ * Copies the iojs.lib file for the current target architecture into the
* current proper dev dir location.
*/
if (!win || !copyDevLib) return doBuild()
var buildDir = path.resolve(nodeDir, buildType)
- , archNodeLibPath = path.resolve(nodeDir, arch, 'node.lib')
- , buildNodeLibPath = path.resolve(buildDir, 'node.lib')
+ , archNodeLibPath = path.resolve(nodeDir, arch, 'iojs.lib')
+ , buildNodeLibPath = path.resolve(buildDir, 'iojs.lib')
mkdirp(buildDir, function (err, isNew) {
if (err) return callback(err)
log.verbose('"' + buildType + '" dir needed to be created?', isNew)
var rs = fs.createReadStream(archNodeLibPath)
, ws = fs.createWriteStream(buildNodeLibPath)
- log.verbose('copying "node.lib" for ' + arch, buildNodeLibPath)
+ log.verbose('copying "iojs.lib" for ' + arch, buildNodeLibPath)
rs.pipe(ws)
rs.on('error', callback)
ws.on('error', callback)
var p = arch === 'x64' ? 'x64' : 'Win32'
argv.push('/p:Configuration=' + buildType + ';Platform=' + p)
if (jobs) {
- if (!isNaN(parseInt(jobs, 10))) {
- argv.push('/m:' + parseInt(jobs, 10))
+ var j = parseInt(jobs, 10)
+ if (!isNaN(j) && j > 0) {
+ argv.push('/m:' + j)
} else if (jobs.toUpperCase() === 'MAX') {
argv.push('/m:' + require('os').cpus().length)
}
argv.push('-C')
argv.push('build')
if (jobs) {
- if (!isNaN(parseInt(jobs, 10))) {
+ var j = parseInt(jobs, 10)
+ if (!isNaN(j) && j > 0) {
argv.push('--jobs')
- argv.push(parseInt(jobs, 10))
+ argv.push(j)
} else if (jobs.toUpperCase() === 'MAX') {
argv.push('--jobs')
argv.push(require('os').cpus().length)
if (signal) {
return callback(new Error('`' + command + '` got signal: ' + signal))
}
- //symlinkNodeBinding()
callback()
}
- function symlinkNodeBinding () {
- var source, target
- var buildDir = 'build/' + buildType + '/*.node'
- log.verbose('globbing for files', buildDir)
- glob(buildDir, function (err, nodeFiles) {
- if (err) return callback(err)
- log.silly('symlink', 'linking files', nodeFiles)
- function link () {
- var file = nodeFiles.shift()
- if (!file) {
- // no more files to link... done!
- return callback()
- }
- if (win) {
- // windows requires absolute paths for junctions
- source = path.resolve('build', path.basename(file))
- target = path.resolve(file)
- } else {
- // on unix, use only relative paths since they're nice
- source = path.join('build', path.basename(file))
- target = path.relative('build', file)
- }
- log.info('symlink', 'creating %s "%s" pointing to "%s"', win ? 'junction' : 'symlink', source, target)
- fs.symlink(target, source, 'junction', 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()
- })
- }
-
}