Add -dryrun flag for testing, improve the behavior of 'rebuild'
This commit is contained in:
@@ -19,8 +19,6 @@
|
||||
|
||||
<section unless="display || lime-legacy">
|
||||
|
||||
<haxelib name="hxcpp" if="cpp" />
|
||||
|
||||
<ndll name="std" haxelib="hxcpp" if="cpp" />
|
||||
<ndll name="regexp" haxelib="hxcpp" if="cpp" />
|
||||
<ndll name="zlib" haxelib="hxcpp" if="cpp" />
|
||||
|
||||
@@ -1560,6 +1560,10 @@ class CommandLineTools {
|
||||
argument = "-verbose";
|
||||
LogHelper.verbose = true;
|
||||
|
||||
} else if (argument == "-dryrun") {
|
||||
|
||||
ProcessHelper.dryRun = true;
|
||||
|
||||
} else if (argument == "-notrace") {
|
||||
|
||||
traceEnabled = false;
|
||||
|
||||
@@ -14,6 +14,7 @@ class CPPHelper {
|
||||
|
||||
|
||||
private static var rebuiltLibraries = new Map <String, Bool> ();
|
||||
private static var rebuiltPaths = new Map <String, Bool> ();
|
||||
|
||||
|
||||
public static function compile (project:HXProject, path:String, flags:Array<String> = 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 ];
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
|
||||
}
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user