mirror of
https://github.com/electron/node-gyp.git
synced 2025-09-15 21:53:38 +02:00
More progress. Initial 'build' command working on non-windows.
This commit is contained in:
parent
ce92ccda0e
commit
2d32ff37da
5 changed files with 80 additions and 24 deletions
|
@ -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 })
|
||||
})
|
||||
|
|
38
lib/build.js
38
lib/build.js
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
|
@ -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,24 +16,32 @@ function configure (gyp, argv, callback) {
|
|||
//console.error(argv)
|
||||
//console.error(gyp.argv)
|
||||
|
||||
// TODO: Detect and add support for a "current" dev version,
|
||||
// so `target` would be implicit.
|
||||
var target = String(gyp.opts.target)
|
||||
, devDir = path.join(process.env.HOME, '.node-gyp', target)
|
||||
, gyp_addon = path.join(devDir, 'tools', 'gyp_addon')
|
||||
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)
|
||||
, devDir = path.join(process.env.HOME, '.node-gyp', target)
|
||||
, gyp_addon = path.join(devDir, 'tools', 'gyp_addon')
|
||||
|
||||
// Force the 'make' target for non-Windows
|
||||
if (!win) {
|
||||
argv.unshift('make')
|
||||
argv.unshift('-f')
|
||||
}
|
||||
|
||||
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))
|
||||
}
|
||||
})
|
||||
|
||||
// Force the 'make' target for non-Windows
|
||||
if (!win) {
|
||||
argv.unshift('make')
|
||||
argv.unshift('-f')
|
||||
}
|
||||
|
||||
var cp = spawn(gyp_addon, argv, {
|
||||
customFds: [ 0, 1, 2 ]
|
||||
})
|
||||
|
||||
cp.on('end', function () {
|
||||
console.error('end')
|
||||
})
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue