Skip to content

Commit

Permalink
support for native modules (aka node-waf action)
Browse files Browse the repository at this point in the history
	modified:   TODO.md
	modified:   nmod
  • Loading branch information
jeromeetienne committed Mar 1, 2011
1 parent c71d291 commit 01eae06
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 20 deletions.
12 changes: 8 additions & 4 deletions TODO.md
@@ -1,5 +1,11 @@
### BUGS


* nmod install notexistingpkg do a crash...
* allow a search
* curl "http://search.npmjs.org/_view/search?startkey=%22express%22&endkey=%22expressZZZZZZZZZZZZZZZZZZZ%22&reduce=false"
* http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options for docs

* complete npm install url
* support tar+zip
* support any url but be better when you can (e.g. github url)
Expand All @@ -10,10 +16,6 @@
* something like "tags" == all available versions


* nmod install notexistingpkg do a crash...
* allow a search
* curl "http://search.npmjs.org/_view/search?startkey=%22express%22&endkey=%22expressZZZZZZZZZZZZZZZZZZZ%22&reduce=false"
* http://wiki.apache.org/couchdb/HTTP_view_API#Querying_Options for docs
* possible to put url in dependancies. but only .tgz, but github is tar ok
* maybe find a shortcut like this
* github to get the tgz... not perfect at all... but workable now
Expand Down Expand Up @@ -41,6 +43,8 @@
* i install all deps at the same time
* may be faster but disturb the user (and who care about speed in install)
* unsure i did some work. not sure on the status but seems to work
* DONE do the native package compilation
* rm -rf ./build && node-waf configure && node-waf build
* DONE put the semver in nmod file
* DONE name: im not sure about the S in nmods
* i prefere to type nmod when i use it
Expand Down
69 changes: 53 additions & 16 deletions nmod
Expand Up @@ -152,6 +152,27 @@ var utils = {
require('fs').unlinkSync(tmpName);
})
},

/**
* do node-waf to build the native extension
*/
nodeWafBuild : function(dirName, successCb, failureCb){
successCb = successCb || function(){};
failureCb = failureCb || function(error){console.assert(false);}
var cmdline = "(cd '"+dirName+"' && node-waf distclean configure build)"
var child = require('child_process').exec(cmdline,
function (error, stdout, stderr) {
//console.log('stdout: ' + stdout);
//console.log('stderr: ' + stderr);
if (error !== null) {
process.stdout.write(tty_color.code("node-waf failed to build in "+dirName+"\n"));
process.stdout.write(stderr);
failureCb(error);
}else{
successCb();
}
});
}
};

var tty_color = {};
Expand Down Expand Up @@ -523,24 +544,40 @@ var nmod = function(cmdline, cmdopts){
if( typeof pkgJson !== "undefined" ){
require('fs').writeFileSync(dstDirname+"/package.json", JSON.stringify(pkgJson), "binary")
}
// compile native extensions if needed
if( utils.existSync(dstDirname+"wscript") ){
// ( cd ./node_modules/$pkg &>/dev/null; node-waf clean configure build )
// - example of native package nTPL
// - do this one like the untar
console.assert(false, "not yet implemented")


/**
* to install dependancies
*/
var installDeps = function(){
nmod(["deps"], {
rootdir : dstDirname,
prefixStr: prefixStr,
successCb: function(){
// display for the user
process.stdout.write(tty_color.code(prefixStr+pkgName)+": installation completed\n");
// notify the caller
successCb();
}
});
}
// install the dependancies
nmod(["deps"], {
rootdir : dstDirname,
prefixStr: prefixStr,
successCb: function(){

console.log("dstDirname", dstDirname)
// compile native extensions if needed
// - e.g. bigint or nTpl
if( utils.existSync(dstDirname+"/wscript") ){
// display for the user
process.stdout.write(tty_color.code(prefixStr+pkgName)+": Building native code (node-waf)\n");

utils.nodeWafBuild(dstDirname, function(){
// display for the user
process.stdout.write(tty_color.code(prefixStr+pkgName)+": installation completed\n");
// notify the caller
successCb();
}
});
process.stdout.write(tty_color.code(prefixStr+pkgName)+": native code built\n");
installDeps();
})
}else{
// install the dependancies
installDeps();
}
})
})
}
Expand Down

0 comments on commit 01eae06

Please sign in to comment.