Merge pull request #52 from jhbruhn/master

Windows support
This commit is contained in:
Craig Condon
2014-05-12 14:40:28 -07:00
3 changed files with 58 additions and 34 deletions
+2 -2
View File
@@ -15,12 +15,12 @@ Nexe is a command-line utility that compiles your Node.js application into a sin
## Requirements
- Linux / Mac / BSD
- Linux / Mac / BSD / Windows
- Windows: Python 2.6 or 2.7 (in PATH), Visual Studio 2010 or 2012
## Caveats
- Doesn't support native modules (yet).
- Doesn't support windows (yet).
## Installation
+54 -31
View File
@@ -10,12 +10,15 @@ child_process = require("child_process"),
glob = require("glob"),
sardines = require("sardines"),
os = require("os"),
targz = require('tar.gz'),
spawn = child_process.spawn;
var _log = require("./log"),
_monkeypatch = require("./monkeypatch");
var isWin = /^win/.test(process.platform);
/**
*/
@@ -105,8 +108,8 @@ exports.compile = function (options, complete) {
function _downloadNode (version, directory, complete) {
var nodeFileDir = path.join(directory, version),
nodeFilePath = path.join(nodeFileDir, "node-" + version + ".tar.gz");
var nodeFileDir = path.resolve(path.join(process.cwd(), directory, version)),
nodeFilePath = path.resolve(path.join(nodeFileDir, "node-" + version + ".tar.gz"));
// might already be downloaded, and unzipped
@@ -122,7 +125,8 @@ function _downloadNode (version, directory, complete) {
*/
function makeDirectory (next) {
mkdirp(path.dirname(nodeFilePath), function () { next(); })
mkdirp.sync(path.dirname(nodeFilePath));
next();
},
/**
@@ -130,7 +134,6 @@ function _downloadNode (version, directory, complete) {
*/
function downloadNode (next) {
if (fs.existsSync(nodeFilePath)) return next();
var url, prefix = "http://nodejs.org/dist";
@@ -156,15 +159,19 @@ function _downloadNode (version, directory, complete) {
*/
function unzipNodeTarball (next) {
if(isWin) {
_log("Extracting the .tar.gz.");
new targz().extract(nodeFilePath, nodeFileDir, next);
} else {
var cmd = ["tar", "-xf", nodeFilePath, "-C", nodeFileDir];
_log(cmd.join(" "));
var cmd = ["tar", "-xf", nodeFilePath, "-C", nodeFileDir];
_log(cmd.join(" "));
var tar = spawn(cmd.shift(), cmd);
tar.stdout.pipe(process.stdout);
tar.stderr.pipe(process.stderr);
var tar = spawn(cmd.shift(), cmd);
tar.stdout.pipe(process.stdout);
tar.stderr.pipe(process.stderr);
tar.on("close", function () { next(); })
tar.on("close", function () { next(); })
}
},
/**
@@ -185,28 +192,44 @@ function _getNodeCompiler (nodeFileDir, complete) {
var dir = _getFirstDirectory(nodeFileDir);
if (dir) {
complete(null, {
dir: dir,
version: path.basename(nodeFileDir),
releasePath: path.join(dir, "out", "Release", "node"),
make: function (next) {
var configure = spawn("./configure", [], { cwd: dir });
configure.stdout.pipe(process.stdout);
configure.stderr.pipe(process.stderr);
configure.on("close", function () {
var platformMake = "make";
if (os.platform().match(/bsd$/) != null) {
platformMake = "gmake";
}
var make = spawn(platformMake, [], { cwd: dir });
make.stdout.pipe(process.stdout);
make.stderr.pipe(process.stderr);
make.on("close", function () {
if(isWin) {
complete(null, {
dir: dir,
version: path.basename(nodeFileDir),
releasePath: path.join(dir, "Release", "node.exe"),
make: function(next) {
var vcbuild = spawn("vcbuild.bat", ["nosign", "release"], { cwd: dir });
vcbuild.stdout.pipe(process.stdout);
vcbuild.stderr.pipe(process.stderr);
vcbuild.on("close", function() {
next();
});
})
}
});
}
});
} else {
complete(null, {
dir: dir,
version: path.basename(nodeFileDir),
releasePath: path.join(dir, "out", "Release", "node"),
make: function (next) {
var configure = spawn("./configure", [], { cwd: dir });
configure.stdout.pipe(process.stdout);
configure.stderr.pipe(process.stderr);
configure.on("close", function () {
var platformMake = "make";
if (os.platform().match(/bsd$/) != null) {
platformMake = "gmake";
}
var make = spawn(platformMake, [], { cwd: dir });
make.stdout.pipe(process.stdout);
make.stderr.pipe(process.stderr);
make.on("close", function () {
next();
});
})
}
});
}
return true;
}
+2 -1
View File
@@ -20,7 +20,8 @@
"async": "~0.2.10",
"colors": "~0.6.2",
"glob": "~3.2.9",
"progress": "~1.1.3"
"progress": "~1.1.3",
"tar.gz": "^0.1.1"
},
"preferGlobal": "true",
"bin": {