Initial improvements to 'rebuild' command and '-rebuild' flag, walking through actual project dependencies
This commit is contained in:
@@ -13,6 +13,9 @@ import sys.FileSystem;
|
||||
class CPPHelper {
|
||||
|
||||
|
||||
private static var rebuiltLibraries = new Map <String, Bool> ();
|
||||
|
||||
|
||||
public static function compile (project:HXProject, path:String, flags:Array<String> = null, buildFile:String = "Build.xml"):Void {
|
||||
|
||||
if (project.config.getBool ("cpp.requireBuild", true)) {
|
||||
@@ -117,7 +120,31 @@ class CPPHelper {
|
||||
public static function rebuild (project:HXProject, commands:Array<Array<String>>, path:String = null, buildFile:String = null):Void {
|
||||
|
||||
var buildRelease = (!project.targetFlags.exists ("debug"));
|
||||
var buildDebug = (project.targetFlags.exists ("debug") || (!project.targetFlags.exists ("release") && project.config.exists ("project.rebuild.fulldebug")));
|
||||
var buildDebug = (project.targetFlags.exists ("debug") || (!project.targetFlags.exists ("rebuild") && !project.targetFlags.exists ("release") && project.config.exists ("project.rebuild.fulldebug")));
|
||||
|
||||
for (haxelib in project.haxelibs) {
|
||||
|
||||
if (!rebuiltLibraries.exists (haxelib.name)) {
|
||||
|
||||
var defines = StringMapHelper.copy (project.defines);
|
||||
defines.set ("rebuild", 1);
|
||||
var haxelibProject = HXProject.fromHaxelib (haxelib, defines);
|
||||
|
||||
if (haxelibProject == null) {
|
||||
|
||||
haxelibProject = new HXProject ();
|
||||
haxelibProject.config.set ("project.rebuild.path", PathHelper.combine (PathHelper.getHaxelib (haxelib), "project"));
|
||||
|
||||
}
|
||||
|
||||
StringMapHelper.copyKeys (project.targetFlags, haxelibProject.targetFlags);
|
||||
|
||||
rebuiltLibraries.set (haxelib.name, true);
|
||||
rebuild (haxelibProject, commands);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (project.targetFlags.exists ("clean")) {
|
||||
|
||||
@@ -171,6 +198,8 @@ class CPPHelper {
|
||||
|
||||
}
|
||||
|
||||
if (!FileSystem.exists (path)) return;
|
||||
|
||||
if (buildFile == null && project.config.exists ("project.rebuild.file")) {
|
||||
|
||||
buildFile = project.config.get ("project.rebuild.file");
|
||||
@@ -179,6 +208,8 @@ class CPPHelper {
|
||||
|
||||
if (buildFile == null) buildFile = "Build.xml";
|
||||
|
||||
if (!FileSystem.exists (PathHelper.combine (path, buildFile))) return;
|
||||
|
||||
var args = [ "run", project.config.getString ("cpp.buildLibrary", "hxcpp"), buildFile ];
|
||||
|
||||
if (flags != null) {
|
||||
|
||||
@@ -193,10 +193,17 @@ class AndroidPlatform extends PlatformTarget {
|
||||
|
||||
public override function rebuild ():Void {
|
||||
|
||||
var armv5 = [ "-Dandroid", "-DPLATFORM=android-9" ];
|
||||
var armv7 = [ "-Dandroid", "-DHXCPP_ARMV7", "-DHXCPP_ARM7", "-DPLATFORM=android-9" ];
|
||||
var armv5 = (command == "rebuild" || ArrayHelper.containsValue (project.architectures, Architecture.ARMV5) || ArrayHelper.containsValue (project.architectures, Architecture.ARMV6));
|
||||
var armv7 = (command == "rebuild" || ArrayHelper.containsValue (project.architectures, Architecture.ARMV7));
|
||||
var x86 = (command == "rebuild" || ArrayHelper.containsValue (project.architectures, Architecture.X86));
|
||||
|
||||
CPPHelper.rebuild (project, [ armv5, armv7 ]);
|
||||
var commands = [];
|
||||
|
||||
if (armv5) commands.push ([ "-Dandroid", "-DPLATFORM=android-9" ]);
|
||||
if (armv7) commands.push ([ "-Dandroid", "-DHXCPP_ARMV7", "-DHXCPP_ARM7", "-DPLATFORM=android-9" ]);
|
||||
if (x86) commands.push ([ "-Dandroid", "-DHXCPP_X86", "-DPLATFORM=android-9" ]);
|
||||
|
||||
CPPHelper.rebuild (project, commands);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -204,10 +204,15 @@ class BlackBerryPlatform extends PlatformTarget {
|
||||
|
||||
public override function rebuild ():Void {
|
||||
|
||||
var device = [ "-Dblackberry" ];
|
||||
var simulator = [ "-Dblackberry", "-Dsimulator" ];
|
||||
var device = (command == "rebuild" || !targetFlags.exists ("simulator"));
|
||||
var simulator = (command == "rebuild" || targetFlags.exists ("simulator"));
|
||||
|
||||
CPPHelper.rebuild (project, [ device, simulator ]);
|
||||
var commands = [];
|
||||
|
||||
if (device) commands.push ([ "-Dblackberry" ]);
|
||||
if (simulator) commands.push ([ "-Dblackberry", "-Dsimulator" ]);
|
||||
|
||||
CPPHelper.rebuild (project, commands);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -325,11 +325,17 @@ class IOSPlatform extends PlatformTarget {
|
||||
|
||||
public override function rebuild ():Void {
|
||||
|
||||
var armv6 = [ "-Diphoneos", "-DHXCPP_CPP11" ];
|
||||
var armv7 = [ "-Diphoneos", "-DHXCPP_CPP11", "-DHXCPP_ARMV7" ];
|
||||
var simulator = [ "-Diphonesim", "-DHXCPP_CPP11" ];
|
||||
var armv6 = (command == "rebuild" || (project.architectures.indexOf (Architecture.ARMV6) > -1 && !project.targetFlags.exists ("simulator")));
|
||||
var armv7 = (command == "rebuild" || (project.architectures.indexOf (Architecture.ARMV7) > -1 && !project.targetFlags.exists ("simulator")));
|
||||
var simulator = (command == "rebuild" || project.targetFlags.exists ("simulator"));
|
||||
|
||||
CPPHelper.rebuild (project, [ armv6, armv7, simulator ]);
|
||||
var commands = [];
|
||||
|
||||
if (armv6) commands.push ([ "-Diphoneos", "-DHXCPP_CPP11" ]);
|
||||
if (armv7) commands.push ([ "-Diphoneos", "-DHXCPP_CPP11", "-DHXCPP_ARMV7" ]);
|
||||
if (simulator) commands.push ([ "-Diphonesim", "-DHXCPP_CPP11" ]);
|
||||
|
||||
CPPHelper.rebuild (project, commands);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -249,7 +249,7 @@ class LinuxPlatform extends PlatformTarget {
|
||||
|
||||
}
|
||||
|
||||
if (!targetFlags.exists ("64")) {
|
||||
if (!targetFlags.exists ("64") && (command == "rebuild" || PlatformHelper.hostArchitecture == Architecture.X86)) {
|
||||
|
||||
commands.push ([ "-Dlinux" ]);
|
||||
|
||||
|
||||
@@ -200,13 +200,13 @@ class MacPlatform extends PlatformTarget {
|
||||
|
||||
var commands = [];
|
||||
|
||||
if (!targetFlags.exists ("64")) {
|
||||
if (!targetFlags.exists ("64") && (command == "rebuild" || PlatformHelper.hostArchitecture == Architecture.X64)) {
|
||||
|
||||
commands.push ([ "-Dmac", "-DHXCPP_M64" ]);
|
||||
|
||||
}
|
||||
|
||||
if (!targetFlags.exists ("32")) {
|
||||
if (!targetFlags.exists ("32") && (command == "rebuild" || PlatformHelper.hostArchitecture == Architecture.X86)) {
|
||||
|
||||
commands.push ([ "-Dmac" ]);
|
||||
|
||||
|
||||
@@ -119,10 +119,15 @@ class TizenPlatform extends PlatformTarget {
|
||||
|
||||
public override function rebuild ():Void {
|
||||
|
||||
var device = [ "-Dtizen" ];
|
||||
var simulator = [ "-Dtizen", "-Dsimulator" ];
|
||||
var device = (command == "rebuild" || !targetFlags.exists ("simulator"));
|
||||
var simulator = (command == "rebuild" || targetFlags.exists ("simulator"));
|
||||
|
||||
CPPHelper.rebuild (project, [ device, simulator ]);
|
||||
var commands = [];
|
||||
|
||||
if (device) commands.push ([ "-Dtizen" ]);
|
||||
if (simulator) commands.push ([ "-Dtizen", "-Dsimulator" ]);
|
||||
|
||||
CPPHelper.rebuild (project, commands);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user