More progress. Initial 'build' command working on non-windows.

This commit is contained in:
Nathan Rajlich 2012-02-03 12:15:14 -08:00
parent ce92ccda0e
commit 2d32ff37da
5 changed files with 80 additions and 24 deletions

View file

@ -10,10 +10,18 @@ process.title = 'node-gyp'
* Module dependencies.
*/
var gyp = require('../lib/node-gyp')()
var gyp = require('../lib/node-gyp')
/**
* Process and execute the selected command.
*/
gyp.run(process.argv, function () {})
var prog = gyp()
prog.run(process.argv, function (err) {
if (err) throw err
})
prog.on('spawn', function (command, args, proc) {
//console.error('spawn', command, args)
proc.stdout.pipe(process.stdout, { end: false })
proc.stderr.pipe(process.stderr, { end: false })
})

View file

@ -1,6 +1,42 @@
module.exports = exports = build
function build (argv) {
/**
* Module dependencies.
*/
var which = require('which')
, win = process.platform == 'win32'
function build (gyp, argv, callback) {
console.error('build')
var command
if (win) {
// invoke "msbuild"
command = 'msbuild'
} else {
// invoke "make"
command = 'make'
}
// First make sure we have the build command in the PATH
which(command, function (err, execPath) {
if (err) return callback(err)
//console.error(execPath)
var args = []
// Enable Verbose build
if (gyp.opts.verbose) {
args.push('V=1')
}
// Specify the build type, Release by default
args.push('BUILDTYPE=' + (gyp.opts.debug ? 'Debug' : 'Release'))
var proc = gyp.spawn(command, args)
})
}

View file

@ -6,7 +6,6 @@ module.exports = exports = configure
*/
var path = require('path')
, spawn = require('child_process').spawn
, win = process.platform == 'win32'
exports.usage = 'Creates the project files to build the native addon.'
@ -17,6 +16,11 @@ function configure (gyp, argv, callback) {
//console.error(argv)
//console.error(gyp.argv)
gyp.commands.install(['0.7'], go)
function go () {
console.error('starting "configure"')
// TODO: Detect and add support for a "current" dev version,
// so `target` would be implicit.
var target = String(gyp.opts.target)
@ -29,12 +33,15 @@ function configure (gyp, argv, callback) {
argv.unshift('-f')
}
var cp = spawn(gyp_addon, argv, {
customFds: [ 0, 1, 2 ]
console.error(gyp_addon)
var cp = gyp.spawn(gyp_addon, argv)
cp.on('exit', function (code, signal) {
if (code !== 0) {
callback(new Error('gyp_addon failed with exit code: ' + code))
}
})
cp.on('end', function () {
console.error('end')
})
}
}

View file

@ -32,11 +32,16 @@ function install (gyp, argv, callback) {
// now download the node tarball
// TODO: download the newest version instead of the .0 release
var tarballUrl = distUrl + '/v' + version + '.0/node-v' + version + '.0.tar.gz'
, parser = tar.Parse()
console.error('downloading:', tarballUrl)
request(tarballUrl, downloadError)
.pipe(zlib.createGunzip())
.pipe(tar.Parse())
.on('entry', onEntry)
.pipe(parser)
parser.on('entry', onEntry)
parser.on('end', function () {
// TODO: Ensure no multiple-callback
callback()
})
// something went wrong downloading the tarball?
function downloadError (err, res) {

View file

@ -74,7 +74,7 @@ proto.parseArgv = function parseOpts (argv) {
proto.spawn = function spawn () {
var cp = child_process.spawn.apply(child_process, arguments)
this.emit('spawn', cp)
this.emit('spawn', arguments[0], arguments[1], cp)
return cp
}