diff --git a/scripts/AliasScript.hx b/scripts/AliasScript.hx index ec34b33..342c494 100644 --- a/scripts/AliasScript.hx +++ b/scripts/AliasScript.hx @@ -7,6 +7,6 @@ class AliasScript public static function main() { var args = ["run", Compiler.getDefine("command")].concat(Sys.args()); - Sys.exit(Sys.command("haxelib", args)); + Sys.exit(Sys.command("haxelib " + args.join(" "))); } } diff --git a/src/hxp/HXML.hx b/src/hxp/HXML.hx index 45082ba..945120b 100644 --- a/src/hxp/HXML.hx +++ b/src/hxp/HXML.hx @@ -332,9 +332,9 @@ abstract HXML(Array) /** Builds the current HXML using Haxe. **/ - public function build():Int + public function build(workingDirectory:String = ""):Int { - return System.runCommand("", "haxe " + this.join(" ")); + return System.runCommand(workingDirectory, "haxe " + this.join(" ")); } /** @@ -390,6 +390,46 @@ abstract HXML(Array) this.push("-D " + name + (value == null ? "" : "=" + Std.string(value))); } + public static function buildFile(path:String, fromDirectory:String = ""):Int + { + var hxml:HXML = fromFile(path); + var hxmlDirectory = Path.directory(path); + + if (hxml == null) + { + Log.error("The specified target path \"" + path + "\" does not exist"); + } + + if (fromDirectory != "" && fromDirectory != hxmlDirectory) + { + var lines:Array = cast hxml; + + for (i in 0...lines.length) + { + if (lines[i].indexOf("-cp ") == 0) + { + var quote:Int = lines[i].indexOf('"'); + var cp:String; + + if (quote > 0) + { + cp = lines[i].substring(quote + 1, lines[i].lastIndexOf("\"")); + } + else + { + cp = lines[i].substr("-cp ".length); + } + + lines[i] = "-cp \"" + Path.normalize(hxmlDirectory + "/" + cp) + "\""; + } + } + + lines.push('-cp "$hxmlDirectory"'); + } + + return hxml.build(fromDirectory); + } + public static function fromFile(path:String):HXML { if (FileSystem.exists(path)) @@ -410,7 +450,12 @@ abstract HXML(Array) for (line in lines) { - value.push(StringTools.trim(line)); + line = StringTools.trim(line); + + if (!StringTools.startsWith(line, "#")) + { + value.push(line); + } } } diff --git a/src/hxp/Haxelib.hx b/src/hxp/Haxelib.hx index 0db5ddc..bbeb6a9 100644 --- a/src/hxp/Haxelib.hx +++ b/src/hxp/Haxelib.hx @@ -405,6 +405,8 @@ class Haxelib public static function runCommand(path:String, args:Array, safeExecute:Bool = true, ignoreErrors:Bool = false, print:Bool = false):Int { + var command:String; + if (pathOverrides.exists("haxelib")) { var script = Path.combine(pathOverrides.get("haxelib"), "run.n"); @@ -414,26 +416,21 @@ class Haxelib Log.error("Cannot find haxelib script: " + script); } - return System.runCommand(path, "neko", [script].concat(args), safeExecute, ignoreErrors, print); + command = 'neko "$script"'; } else { - // var haxe = Sys.getEnv ("HAXEPATH"); - var command = "haxelib"; - - // if (haxe != null) { - - // command = Path.combine (haxe, command); - - // } - - return System.runCommand(path, command, args, safeExecute, ignoreErrors, print); + command = "haxelib"; } + + return System.runCommand(path, command + " " + args.join(" "), safeExecute, ignoreErrors, print); } public static function runProcess(path:String, args:Array, waitForOutput:Bool = true, safeExecute:Bool = true, ignoreErrors:Bool = false, print:Bool = false, returnErrorValue:Bool = false):String { + var command:String; + if (pathOverrides.exists("haxelib")) { var script = Path.combine(pathOverrides.get("haxelib"), "run.n"); @@ -443,21 +440,14 @@ class Haxelib Log.error("Cannot find haxelib script: " + script); } - return System.runProcess(path, "neko", [script].concat(args), waitForOutput, safeExecute, ignoreErrors, print, returnErrorValue); + command = 'neko "$script"'; } else { - // var haxe = Sys.getEnv ("HAXEPATH"); - var command = "haxelib"; - - // if (haxe != null) { - - // command = Path.combine (haxe, command); - - // } - - return System.runProcess(path, command, args, waitForOutput, safeExecute, ignoreErrors, print, returnErrorValue); + command = "haxelib"; } + + return System.runProcess(path, command + " " + args.join(" "), waitForOutput, safeExecute, ignoreErrors, print, returnErrorValue); } public static function setOverridePath(haxelib:Haxelib, path:String):Void diff --git a/src/hxp/PlatformTools.hx b/src/hxp/PlatformTools.hx index e3d6629..683f971 100644 --- a/src/hxp/PlatformTools.hx +++ b/src/hxp/PlatformTools.hx @@ -50,7 +50,7 @@ class PlatformTools { Log.info("", " - \x1b[1mStarting local web server:\x1b[0m http://localhost:" + port); - var args = ["run", "http-server", path, "-p", Std.string(port), "-c-1", "--cors"]; + var args = ["run", "http-server", '"$path"', "-p", Std.string(port), "-c-1", "--cors"]; if (!openBrowser && !Log.verbose) { diff --git a/src/hxp/System.hx b/src/hxp/System.hx index 64788a8..3bde4a5 100644 --- a/src/hxp/System.hx +++ b/src/hxp/System.hx @@ -1299,7 +1299,7 @@ class System // try { - // var process = new Process ("haxe", [ "-version" ]); + // var process = new Process ("haxe -version"); // _haxeVersion = StringTools.trim (process.stderr.readAll ().toString ()); // if (_haxeVersion == "") {