Initial iojs support.
This commit is contained in:
+53
-5
@@ -162,6 +162,12 @@ exports.compile = function (options, complete) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Download a version of node
|
||||
*
|
||||
* @param {string} version, version of node to download
|
||||
* @param {string} directory, where to store the downloaded src
|
||||
* @param {string} runtime, iojs or node !NOTE! Not implemented.
|
||||
* @param {function} complete, callback
|
||||
*/
|
||||
|
||||
function _downloadNode (version, directory, complete) {
|
||||
@@ -194,13 +200,13 @@ function _downloadNode (version, directory, complete) {
|
||||
function downloadNode (next) {
|
||||
if (fs.existsSync(nodeFilePath)) return next();
|
||||
|
||||
var url, prefix = "https://nodejs.org/dist";
|
||||
var url, prefix = "https://iojs.org/dist";
|
||||
|
||||
// pick which url depending on the version
|
||||
if (version === "latest") {
|
||||
url = prefix + "/node-" + version + ".tar.gz";
|
||||
url = prefix + "/iojs-" + version + ".tar.gz";
|
||||
} else {
|
||||
url = prefix + "/v" + version + "/node-v" + version + ".tar.gz";
|
||||
url = prefix + "/v" + version + "/iojs-v" + version + ".tar.gz";
|
||||
}
|
||||
|
||||
_log("downloading %s", url);
|
||||
@@ -252,6 +258,8 @@ function _downloadNode (version, directory, complete) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the compilier we will use for whatever platform we may be on and configure
|
||||
* it.
|
||||
*/
|
||||
|
||||
function _getNodeCompiler (nodeFileDir, complete) {
|
||||
@@ -262,7 +270,7 @@ function _getNodeCompiler (nodeFileDir, complete) {
|
||||
complete(null, {
|
||||
dir: dir,
|
||||
version: path.basename(nodeFileDir),
|
||||
releasePath: path.join(dir, "Release", "node.exe"),
|
||||
releasePath: path.join(dir, "Release", "iojs.exe"),
|
||||
make: function(next) {
|
||||
// create a new env with minimal impact on old one
|
||||
var newEnv = process.env
|
||||
@@ -288,7 +296,7 @@ function _getNodeCompiler (nodeFileDir, complete) {
|
||||
complete(null, {
|
||||
dir: dir,
|
||||
version: path.basename(nodeFileDir),
|
||||
releasePath: path.join(dir, "out", "Release", "node"),
|
||||
releasePath: path.join(dir, "out", "Release", "iojs"),
|
||||
make: function (next) {
|
||||
var cfg = "./configure", configure;
|
||||
if(isPy !== "python") {
|
||||
@@ -297,9 +305,49 @@ function _getNodeCompiler (nodeFileDir, complete) {
|
||||
configure = spawn(cfg, [], { cwd: dir });
|
||||
}
|
||||
|
||||
// local function, move to top eventually
|
||||
function _loop(dir) {
|
||||
/* eventually try every python file */
|
||||
var pdir = fs.readdirSync(dir);
|
||||
|
||||
pdir.forEach(function(v, i) {
|
||||
var stat = fs.statSync(dir+"/"+v);
|
||||
if(stat.isFile()) {
|
||||
// only process Makefiles and .mk targets.
|
||||
if(v !== "Makefile" && path.extname(v) !== ".mk") {
|
||||
return;
|
||||
}
|
||||
|
||||
_log("patching "+v);
|
||||
|
||||
/* patch the file */
|
||||
var py = fs.readFileSync(dir+"/"+v, {encoding: 'utf8'});
|
||||
//py = py.replace(/^#!\/usr\/bin\/env python$/gm, "#!"+isPy); // may not be needed
|
||||
//py = py.replace(/^#!\/usr\/bin\/python$/gm, "#!"+isPy); // may not be needed
|
||||
py = py.replace(/([a-z]|\/)*python(\w|)/gm, isPy); // this is definently needed
|
||||
//py = py.replace(/^PYTHON \?= python$/gm, "PYTHON ?= "+isPy); // may not be needed (pre-hook)
|
||||
fs.writeFileSync(dir+"/"+v, py, {encoding: 'utf8'});
|
||||
|
||||
delete pv;
|
||||
} else if(stat.isDirectory()) {
|
||||
// must be dir?
|
||||
// skip tests because we don't need them here
|
||||
if(v !== "test") {
|
||||
_loop(dir+"/"+v)
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
configure.stdout.pipe(process.stdout);
|
||||
configure.stderr.pipe(process.stderr);
|
||||
configure.on("close", function () {
|
||||
if(isPy !== "python") {
|
||||
_log("preparing python");
|
||||
|
||||
// loop over depends
|
||||
_loop(dir);
|
||||
}
|
||||
var platformMake = "make";
|
||||
if (os.platform().match(/bsd$/) != null) {
|
||||
platformMake = "gmake";
|
||||
|
||||
Reference in New Issue
Block a user