From bd1152357efa29f13edb014ef3e7397f8487469d Mon Sep 17 00:00:00 2001 From: Jan-Henrik Date: Mon, 12 May 2014 20:29:02 +0200 Subject: [PATCH 1/2] Added Windows Support using vcbuild.bat --- lib/exe.js | 85 +++++++++++++++++++++++++++++++++------------------- package.json | 3 +- 2 files changed, 56 insertions(+), 32 deletions(-) diff --git a/lib/exe.js b/lib/exe.js index 3271bfe..31158ea 100644 --- a/lib/exe.js +++ b/lib/exe.js @@ -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; } diff --git a/package.json b/package.json index ad62889..22a9e61 100644 --- a/package.json +++ b/package.json @@ -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": { From e73804a4dd34874821a5f219a81d3abb7593efcf Mon Sep 17 00:00:00 2001 From: Jan-Henrik Date: Mon, 12 May 2014 20:33:04 +0200 Subject: [PATCH 2/2] Added Windows support to Readme --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 76f7ecb..8ec17f3 100644 --- a/README.md +++ b/README.md @@ -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