From 66db8b243991b71bd1ee2f12d049595deaa8bfea Mon Sep 17 00:00:00 2001 From: isaacs Date: Tue, 6 Mar 2012 19:48:22 -0800 Subject: Automatically node-gyp build stuff with a bindings.gyp --- lib/utils/read-json.js | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/lib/utils/read-json.js b/lib/utils/read-json.js index 8fdd60f66..ceeebdf27 100644 --- a/lib/utils/read-json.js +++ b/lib/utils/read-json.js @@ -34,6 +34,18 @@ function readJson (jsonFile, opts, cb) { var wscript = null , contributors = null , serverjs = null + , gypfile = null + + if (options.gypfile !== null && opts.gypfile !== undefined) { + gypfile = opts.gypfile + next() + } else { + fs.readFile( path.join(path.dirname(jsonFile), "bindings.gyp") + , function (er, data) { + opts.gypfile = !er + next() + }) + } if (opts.wscript !== null && opts.wscript !== undefined) { wscript = opts.wscript @@ -76,9 +88,10 @@ function readJson (jsonFile, opts, cb) { }) function next () { - if (wscript === null - || contributors === null - || serverjs === null) { + if (wscript === null || + contributors === null || + gypfile === null || + serverjs === null) { return } @@ -332,6 +345,15 @@ function processObject (opts, cb) { return function (er, json) { var scripts = json.scripts || {} + // if it has a bindings.gyp, then build with node-gyp + if (opts.gypfile && !json.prebuilt) { + log.verbose([json.prebuilt, opts], "has bindings.gyp") + if (!scripts.install && !scripts.preinstall) { + scripts.preinstall = "node-gyp clean || (exit 0); node-gyp configure ; node-gyp build" + json.scripts = scripts + } + } + // if it has a wscript, then build it. if (opts.wscript && !json.prebuilt) { log.verbose([json.prebuilt, opts], "has wscript") -- cgit v1.2.3