diff --git a/include.xml b/include.xml index 41ea390e5..8b1baa3eb 100644 --- a/include.xml +++ b/include.xml @@ -19,8 +19,6 @@
- - diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index c68d669fc..5a114fb01 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -1560,6 +1560,10 @@ class CommandLineTools { argument = "-verbose"; LogHelper.verbose = true; + } else if (argument == "-dryrun") { + + ProcessHelper.dryRun = true; + } else if (argument == "-notrace") { traceEnabled = false; diff --git a/tools/helpers/CPPHelper.hx b/tools/helpers/CPPHelper.hx index aa68f00be..d84e5abcf 100644 --- a/tools/helpers/CPPHelper.hx +++ b/tools/helpers/CPPHelper.hx @@ -14,6 +14,7 @@ class CPPHelper { private static var rebuiltLibraries = new Map (); + private static var rebuiltPaths = new Map (); public static function compile (project:HXProject, path:String, flags:Array = null, buildFile:String = "Build.xml"):Void { @@ -128,6 +129,7 @@ class CPPHelper { var defines = StringMapHelper.copy (project.defines); defines.set ("rebuild", 1); + var haxelibProject = HXProject.fromHaxelib (haxelib, defines); if (haxelibProject == null) { @@ -140,7 +142,13 @@ class CPPHelper { StringMapHelper.copyKeys (project.targetFlags, haxelibProject.targetFlags); rebuiltLibraries.set (haxelib.name, true); - rebuild (haxelibProject, commands); + + if (!rebuiltPaths.exists (haxelibProject.config.get ("project.rebuild.path"))) { + + rebuiltPaths.set (haxelibProject.config.get ("project.rebuild.path"), true); + rebuild (haxelibProject, commands); + + } } @@ -198,7 +206,11 @@ class CPPHelper { } - if (!FileSystem.exists (path)) return; + if (path == null || !FileSystem.exists (path)) { + + return; + + } if (buildFile == null && project.config.exists ("project.rebuild.file")) { @@ -208,7 +220,11 @@ class CPPHelper { if (buildFile == null) buildFile = "Build.xml"; - if (!FileSystem.exists (PathHelper.combine (path, buildFile))) return; + if (!FileSystem.exists (PathHelper.combine (path, buildFile))) { + + return; + + } var args = [ "run", project.config.getString ("cpp.buildLibrary", "hxcpp"), buildFile ]; diff --git a/tools/helpers/PathHelper.hx b/tools/helpers/PathHelper.hx index c894be7b9..a081ac942 100644 --- a/tools/helpers/PathHelper.hx +++ b/tools/helpers/PathHelper.hx @@ -188,8 +188,13 @@ class PathHelper { try { + var cacheDryRun = ProcessHelper.dryRun; + ProcessHelper.dryRun = false; + output = ProcessHelper.runProcess (Sys.getEnv ("HAXEPATH"), "haxelib", [ "path", name ], true, true, true); + ProcessHelper.dryRun = cacheDryRun; + } catch (e:Dynamic) { } LogHelper.verbose = cache; diff --git a/tools/helpers/ProcessHelper.hx b/tools/helpers/ProcessHelper.hx index f1dc39882..519728197 100644 --- a/tools/helpers/ProcessHelper.hx +++ b/tools/helpers/ProcessHelper.hx @@ -12,6 +12,7 @@ import sys.FileSystem; class ProcessHelper { + public static var dryRun:Bool = false; public static var processorCores (get_processorCores, null):Int; private static var _processorCores:Int = 0; @@ -183,8 +184,12 @@ class ProcessHelper { LogHelper.info ("", " - \x1b[1mChanging directory:\x1b[0m " + path + ""); - oldPath = Sys.getCwd (); - Sys.setCwd (path); + if (!dryRun) { + + oldPath = Sys.getCwd (); + Sys.setCwd (path); + + } } @@ -212,19 +217,23 @@ class ProcessHelper { var result = 0; - if (args != null && args.length > 0) { + if (!dryRun) { - result = Sys.command (command, args); + if (args != null && args.length > 0) { + + result = Sys.command (command, args); + + } else { + + result = Sys.command (command); + + } - } else { - - result = Sys.command (command); - - } - - if (oldPath != "") { - - Sys.setCwd (oldPath); + if (oldPath != "") { + + Sys.setCwd (oldPath); + + } } @@ -306,8 +315,12 @@ class ProcessHelper { LogHelper.info ("", " - \x1b[1mChanging directory:\x1b[0m " + path + ""); - oldPath = Sys.getCwd (); - Sys.setCwd (path); + if (!dryRun) { + + oldPath = Sys.getCwd (); + Sys.setCwd (path); + + } } @@ -332,72 +345,76 @@ class ProcessHelper { var output = ""; var result = 0; - var process = new Process (command, args); - var buffer = new BytesOutput (); - - if (waitForOutput) { + if (!dryRun) { - var waiting = true; + var process = new Process (command, args); + var buffer = new BytesOutput (); - while (waiting) { + if (waitForOutput) { - try { + var waiting = true; + + while (waiting) { - var current = process.stdout.readAll (1024); - buffer.write (current); - - if (current.length == 0) { + try { + + var current = process.stdout.readAll (1024); + buffer.write (current); + + if (current.length == 0) { + + waiting = false; + + } + + } catch (e:Eof) { waiting = false; } - } catch (e:Eof) { - - waiting = false; - } - } - - result = process.exitCode (); - process.close(); - - //if (result == 0) { + result = process.exitCode (); + process.close(); - output = buffer.getBytes ().toString (); - - if (output == "") { + //if (result == 0) { - var error = process.stderr.readAll ().toString (); + output = buffer.getBytes ().toString (); - if (ignoreErrors) { + if (output == "") { - output = error; + var error = process.stderr.readAll ().toString (); - } else { + if (ignoreErrors) { + + output = error; + + } else { + + LogHelper.error (error); + + } - LogHelper.error (error); + return null; + + /*if (error != "") { + + LogHelper.error (error); + + }*/ } - return null; - - /*if (error != "") { - - LogHelper.error (error); - - }*/ - - } + //} - //} + } - } - - if (oldPath != "") { - - Sys.setCwd (oldPath); + if (oldPath != "") { + + Sys.setCwd (oldPath); + + } } @@ -415,6 +432,9 @@ class ProcessHelper { public static function get_processorCores ():Int { + var cacheDryRun = dryRun; + dryRun = false; + if (_processorCores < 1) { var result = null; @@ -471,6 +491,8 @@ class ProcessHelper { } + dryRun = cacheDryRun; + return _processorCores; } diff --git a/tools/project/PlatformTarget.hx b/tools/project/PlatformTarget.hx index b373906e7..42c379535 100644 --- a/tools/project/PlatformTarget.hx +++ b/tools/project/PlatformTarget.hx @@ -49,6 +49,15 @@ class PlatformTarget { if (!Reflect.hasField (metaFields.rebuild, "ignore") && (command == "rebuild" || project.targetFlags.exists ("rebuild"))) { LogHelper.info ("", "\n" + LogHelper.accentColor + "Running command: REBUILD" + LogHelper.resetColor); + + // hack for now, need to move away from project.rebuild.path, probably + + if (project.targetFlags.exists ("rebuild")) { + + project.config.set ("project.rebuild.path", null); + + } + rebuild (); }