Merge HXProject defaults and exclude architectures at end
This commit is contained in:
@@ -10,3 +10,16 @@ typedef ApplicationData =
|
||||
@:optional var swfVersion:Float;
|
||||
@:optional var url:String;
|
||||
}
|
||||
|
||||
@:dox(hide) class _ApplicationDataType
|
||||
{
|
||||
public static var fields:ApplicationData = {
|
||||
file: "",
|
||||
init: "",
|
||||
main: "",
|
||||
path: "",
|
||||
preloader: "",
|
||||
swfVersion: 0.0,
|
||||
url: ""
|
||||
}
|
||||
}
|
||||
@@ -32,6 +32,7 @@ class HXProject extends Script
|
||||
// public var defines:Map<String, Dynamic>;
|
||||
public var dependencies:Array<Dependency>;
|
||||
public var environment:Map<String, String>;
|
||||
public var excludeArchitectures:Array<Architecture>;
|
||||
public var haxedefs:Map<String, Dynamic>;
|
||||
public var haxeflags:Array<String>;
|
||||
public var haxelibs:Array<Haxelib>;
|
||||
@@ -60,10 +61,6 @@ class HXProject extends Script
|
||||
@:isVar public var window(get, set):WindowData;
|
||||
public var windows:Array<WindowData>;
|
||||
|
||||
private var defaultApp:ApplicationData;
|
||||
private var defaultArchitectures:Array<Architecture>;
|
||||
private var defaultMeta:MetaData;
|
||||
private var defaultWindow:WindowData;
|
||||
private var needRerun:Bool;
|
||||
|
||||
public static var _command:String;
|
||||
@@ -73,6 +70,7 @@ class HXProject extends Script
|
||||
public static var _targetFlags:Map<String, String>;
|
||||
public static var _templatePaths:Array<String>;
|
||||
public static var _userDefines:Map<String, Dynamic>;
|
||||
|
||||
private static var initialized:Bool;
|
||||
|
||||
public static function main()
|
||||
@@ -128,184 +126,38 @@ class HXProject extends Script
|
||||
targetFlags = MapTools.copy(_targetFlags);
|
||||
templatePaths = _templatePaths.copy();
|
||||
|
||||
defaultMeta =
|
||||
{
|
||||
title: "MyApplication",
|
||||
description: "",
|
||||
packageName: "com.example.myapp",
|
||||
version: "1.0.0",
|
||||
company: "",
|
||||
companyUrl: "",
|
||||
buildNumber: null,
|
||||
companyId: ""
|
||||
}
|
||||
defaultApp =
|
||||
{
|
||||
main: "Main",
|
||||
file: "MyApplication",
|
||||
path: "bin",
|
||||
preloader: "",
|
||||
swfVersion: 17,
|
||||
url: "",
|
||||
init: null
|
||||
}
|
||||
defaultWindow =
|
||||
{
|
||||
width: 800,
|
||||
height: 600,
|
||||
parameters: "{}",
|
||||
background: 0xFFFFFF,
|
||||
fps: 30,
|
||||
hardware: true,
|
||||
display: 0,
|
||||
resizable: true,
|
||||
borderless: false,
|
||||
orientation: Orientation.AUTO,
|
||||
vsync: false,
|
||||
fullscreen: false,
|
||||
allowHighDPI: true,
|
||||
alwaysOnTop: false,
|
||||
antialiasing: 0,
|
||||
allowShaders: true,
|
||||
requireShaders: false,
|
||||
depthBuffer: true,
|
||||
stencilBuffer: true,
|
||||
colorDepth: 32,
|
||||
maximized: false,
|
||||
minimized: false,
|
||||
hidden: false,
|
||||
title: ""
|
||||
}
|
||||
|
||||
platformType = PlatformType.DESKTOP;
|
||||
architectures = [];
|
||||
excludeArchitectures = [];
|
||||
|
||||
switch (target)
|
||||
platformType = switch (target)
|
||||
{
|
||||
case AIR:
|
||||
if (targetFlags.exists("ios") || targetFlags.exists("android"))
|
||||
{
|
||||
platformType = PlatformType.MOBILE;
|
||||
case AIR if (targetFlags.exists("ios") || targetFlags.exists("android")):
|
||||
PlatformType.MOBILE;
|
||||
|
||||
defaultWindow.width = 0;
|
||||
defaultWindow.height = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
platformType = PlatformType.DESKTOP;
|
||||
}
|
||||
|
||||
architectures = [];
|
||||
|
||||
case FLASH:
|
||||
platformType = PlatformType.WEB;
|
||||
architectures = [];
|
||||
|
||||
case HTML5, FIREFOX:
|
||||
platformType = PlatformType.WEB;
|
||||
architectures = [];
|
||||
|
||||
defaultWindow.width = 0;
|
||||
defaultWindow.height = 0;
|
||||
defaultWindow.fps = 60;
|
||||
|
||||
case EMSCRIPTEN:
|
||||
platformType = PlatformType.WEB;
|
||||
architectures = [];
|
||||
|
||||
defaultWindow.fps = 60;
|
||||
defaultWindow.allowHighDPI = false;
|
||||
case FLASH, HTML5, FIREFOX, EMSCRIPTEN:
|
||||
PlatformType.WEB;
|
||||
|
||||
case ANDROID, BLACKBERRY, IOS, TIZEN, WEBOS, TVOS:
|
||||
platformType = PlatformType.MOBILE;
|
||||
PlatformType.MOBILE;
|
||||
|
||||
if (target == Platform.IOS)
|
||||
{
|
||||
architectures = [Architecture.ARMV7, Architecture.ARM64];
|
||||
}
|
||||
else if (target == Platform.ANDROID)
|
||||
{
|
||||
if (targetFlags.exists("simulator") || targetFlags.exists("emulator"))
|
||||
{
|
||||
architectures = [Architecture.X86];
|
||||
}
|
||||
else
|
||||
{
|
||||
architectures = [Architecture.ARMV7];
|
||||
if (target == ANDROID) architectures.push(Architecture.ARM64);
|
||||
}
|
||||
}
|
||||
else if (target == Platform.TVOS)
|
||||
{
|
||||
architectures = [Architecture.ARM64];
|
||||
}
|
||||
else
|
||||
{
|
||||
architectures = [Architecture.ARMV6];
|
||||
}
|
||||
|
||||
defaultWindow.width = 0;
|
||||
defaultWindow.height = 0;
|
||||
defaultWindow.fullscreen = true;
|
||||
defaultWindow.requireShaders = true;
|
||||
|
||||
case WINDOWS:
|
||||
platformType = PlatformType.DESKTOP;
|
||||
|
||||
if (targetFlags.exists("uwp") || targetFlags.exists("winjs"))
|
||||
{
|
||||
architectures = [];
|
||||
|
||||
targetFlags.set("uwp", "");
|
||||
targetFlags.set("winjs", "");
|
||||
|
||||
defaultWindow.width = 0;
|
||||
defaultWindow.height = 0;
|
||||
defaultWindow.fps = 60;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (System.hostArchitecture)
|
||||
{
|
||||
case ARMV6: architectures = [ARMV6];
|
||||
case ARMV7: architectures = [ARMV7];
|
||||
case X86: architectures = [X86];
|
||||
case X64: architectures = [X64];
|
||||
default: architectures = [];
|
||||
}
|
||||
}
|
||||
|
||||
defaultWindow.allowHighDPI = false;
|
||||
|
||||
case MAC, LINUX:
|
||||
platformType = PlatformType.DESKTOP;
|
||||
switch (System.hostArchitecture)
|
||||
{
|
||||
case ARMV6: architectures = [ARMV6];
|
||||
case ARMV7: architectures = [ARMV7];
|
||||
case X86: architectures = [X86];
|
||||
case X64: architectures = [X64];
|
||||
default: architectures = [];
|
||||
}
|
||||
|
||||
defaultWindow.allowHighDPI = false;
|
||||
case WINDOWS, MAC, LINUX, AIR:
|
||||
PlatformType.DESKTOP;
|
||||
|
||||
default:
|
||||
// TODO: Better handling of platform type for pluggable targets
|
||||
|
||||
platformType = PlatformType.CONSOLE;
|
||||
|
||||
defaultWindow.width = 0;
|
||||
defaultWindow.height = 0;
|
||||
defaultWindow.fps = 60;
|
||||
defaultWindow.fullscreen = true;
|
||||
PlatformType.CONSOLE;
|
||||
}
|
||||
|
||||
defaultArchitectures = architectures.copy();
|
||||
if (target == WINDOWS && targetFlags.exists("uwp") || targetFlags.exists("winjs"))
|
||||
{
|
||||
targetFlags.set("uwp", "");
|
||||
targetFlags.set("winjs", "");
|
||||
}
|
||||
|
||||
meta = ObjectTools.copyFields(defaultMeta, {});
|
||||
app = ObjectTools.copyFields(defaultApp, {});
|
||||
window = ObjectTools.copyFields(defaultWindow, {});
|
||||
meta = {};
|
||||
app = {};
|
||||
window = {};
|
||||
windows = [window];
|
||||
assets = new Array<Asset>();
|
||||
|
||||
@@ -379,6 +231,8 @@ class HXProject extends Script
|
||||
project.environment.set(key, environment.get(key));
|
||||
}
|
||||
|
||||
project.excludeArchitectures = excludeArchitectures.copy();
|
||||
|
||||
for (key in haxedefs.keys())
|
||||
{
|
||||
project.haxedefs.set(key, haxedefs.get(key));
|
||||
@@ -834,14 +688,14 @@ class HXProject extends Script
|
||||
{
|
||||
if (project != null)
|
||||
{
|
||||
ObjectTools.copyUniqueFields(project.meta, meta, project.defaultMeta);
|
||||
ObjectTools.copyUniqueFields(project.app, app, project.defaultApp);
|
||||
ObjectTools.copyFields(project.meta, meta);
|
||||
ObjectTools.copyFields(project.app, app);
|
||||
|
||||
for (i in 0...project.windows.length)
|
||||
{
|
||||
if (i < windows.length)
|
||||
{
|
||||
ObjectTools.copyUniqueFields(project.windows[i], windows[i], project.defaultWindow);
|
||||
ObjectTools.copyFields(project.windows[i], windows[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -853,31 +707,15 @@ class HXProject extends Script
|
||||
MapTools.copyUniqueKeys(project.environment, environment);
|
||||
MapTools.copyUniqueKeysDynamic(project.haxedefs, haxedefs);
|
||||
MapTools.copyUniqueKeys(project.libraryHandlers, libraryHandlers);
|
||||
MapTools.copyUniqueKeys(project.targetFlags, targetFlags);
|
||||
MapTools.copyUniqueKeys(project.targetHandlers, targetHandlers);
|
||||
|
||||
config.merge(project.config);
|
||||
|
||||
for (architecture in project.architectures)
|
||||
{
|
||||
if (defaultArchitectures.indexOf(architecture) == -1)
|
||||
{
|
||||
architectures.push(architecture);
|
||||
}
|
||||
}
|
||||
|
||||
if (project.architectures.length > 0)
|
||||
{
|
||||
for (architecture in defaultArchitectures)
|
||||
{
|
||||
if (project.architectures.indexOf(architecture) == -1)
|
||||
{
|
||||
architectures.remove(architecture);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
architectures = ArrayTools.concatUnique(architectures, project.architectures);
|
||||
assets = ArrayTools.concatUnique(assets, project.assets);
|
||||
dependencies = ArrayTools.concatUnique(dependencies, project.dependencies, true);
|
||||
excludeArchitectures = ArrayTools.concatUnique(excludeArchitectures, project.excludeArchitectures);
|
||||
haxeflags = ArrayTools.concatUnique(haxeflags, project.haxeflags);
|
||||
haxelibs = ArrayTools.concatUnique(haxelibs, project.haxelibs, true, "name");
|
||||
icons = ArrayTools.concatUnique(icons, project.icons);
|
||||
@@ -1046,14 +884,6 @@ class HXProject extends Script
|
||||
windows = [window];
|
||||
}
|
||||
|
||||
ObjectTools.copyMissingFields(defaultApp, app);
|
||||
ObjectTools.copyMissingFields(defaultMeta, meta);
|
||||
|
||||
for (item in windows)
|
||||
{
|
||||
ObjectTools.copyMissingFields(defaultWindow, item);
|
||||
}
|
||||
|
||||
// config.populate ();
|
||||
|
||||
for (field in Reflect.fields(app))
|
||||
@@ -1398,7 +1228,7 @@ class HXProject extends Script
|
||||
|
||||
if (main == null)
|
||||
{
|
||||
main = defaultApp.main;
|
||||
main = "Main";
|
||||
}
|
||||
|
||||
var indexOfPeriod = main.lastIndexOf(".");
|
||||
|
||||
@@ -11,3 +11,17 @@ typedef MetaData =
|
||||
@:optional var title:String;
|
||||
@:optional var version:String;
|
||||
}
|
||||
|
||||
@:dox(hide) class _MetaDataType
|
||||
{
|
||||
public static var fields:MetaData = {
|
||||
buildNumber: "",
|
||||
company: "",
|
||||
companyId: "",
|
||||
companyUrl: "",
|
||||
description: "",
|
||||
packageName: "",
|
||||
title: "",
|
||||
version: ""
|
||||
}
|
||||
}
|
||||
@@ -439,11 +439,11 @@ class ProjectXMLParser extends HXProject
|
||||
name = "packageName";
|
||||
}
|
||||
|
||||
if (Reflect.hasField(app, name))
|
||||
if (Reflect.hasField(ApplicationData._ApplicationDataType.fields, name))
|
||||
{
|
||||
Reflect.setField(app, name, value);
|
||||
}
|
||||
else if (Reflect.hasField(meta, name))
|
||||
else if (Reflect.hasField(MetaData._MetaDataType.fields, name))
|
||||
{
|
||||
Reflect.setField(meta, name, value);
|
||||
}
|
||||
@@ -856,7 +856,7 @@ class ProjectXMLParser extends HXProject
|
||||
name = "packageName";
|
||||
}
|
||||
|
||||
if (Reflect.hasField(meta, name))
|
||||
if (Reflect.hasField(MetaData._MetaDataType.fields, name))
|
||||
{
|
||||
Reflect.setField(meta, name, value);
|
||||
}
|
||||
@@ -1336,7 +1336,7 @@ class ProjectXMLParser extends HXProject
|
||||
|
||||
if (Reflect.hasField(Architecture, exclude.toUpperCase()))
|
||||
{
|
||||
architectures.remove(Reflect.field(Architecture, exclude.toUpperCase()));
|
||||
ArrayTools.addUnique(excludeArchitectures, Reflect.field(Architecture, exclude.toUpperCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1954,7 +1954,7 @@ class ProjectXMLParser extends HXProject
|
||||
|
||||
while (id >= windows.length)
|
||||
{
|
||||
windows.push(ObjectTools.copyFields(defaultWindow, {}));
|
||||
windows.push({});
|
||||
}
|
||||
|
||||
for (attribute in element.x.attributes())
|
||||
@@ -1994,35 +1994,23 @@ class ProjectXMLParser extends HXProject
|
||||
}
|
||||
|
||||
case "height", "width", "fps", "antialiasing":
|
||||
if (Reflect.hasField(windows[id], name))
|
||||
{
|
||||
Reflect.setField(windows[id], name, Std.parseInt(value));
|
||||
}
|
||||
Reflect.setField(windows[id], name, Std.parseInt(value));
|
||||
|
||||
case "parameters", "title":
|
||||
if (Reflect.hasField(windows[id], name))
|
||||
{
|
||||
Reflect.setField(windows[id], name, Std.string(value));
|
||||
}
|
||||
Reflect.setField(windows[id], name, Std.string(value));
|
||||
|
||||
case "allow-high-dpi":
|
||||
if (Reflect.hasField(windows[id], "allowHighDPI"))
|
||||
{
|
||||
Reflect.setField(windows[id], "allowHighDPI", value == "true");
|
||||
}
|
||||
Reflect.setField(windows[id], "allowHighDPI", value == "true");
|
||||
|
||||
case "color-depth":
|
||||
if (Reflect.hasField(windows[id], "colorDepth"))
|
||||
{
|
||||
Reflect.setField(windows[id], "colorDepth", Std.parseInt(value));
|
||||
}
|
||||
Reflect.setField(windows[id], "colorDepth", Std.parseInt(value));
|
||||
|
||||
default:
|
||||
if (Reflect.hasField(windows[id], name))
|
||||
if (Reflect.hasField(WindowData._WindowDataType.fields, name))
|
||||
{
|
||||
Reflect.setField(windows[id], name, value == "true");
|
||||
}
|
||||
else if (Reflect.hasField(windows[id], formatAttributeName(name)))
|
||||
else if (Reflect.hasField(WindowData._WindowDataType.fields, formatAttributeName(name)))
|
||||
{
|
||||
Reflect.setField(windows[id], formatAttributeName(name), value == "true");
|
||||
}
|
||||
|
||||
@@ -32,3 +32,38 @@ typedef WindowData =
|
||||
@:optional var maximized:Bool;
|
||||
@:optional var hidden:Bool;
|
||||
}
|
||||
|
||||
@:dox(hide) class _WindowDataType
|
||||
{
|
||||
public static var fields:WindowData = {
|
||||
width: 0,
|
||||
height: 0,
|
||||
x: 0.0,
|
||||
y: 0.0,
|
||||
background: 0,
|
||||
parameters: "",
|
||||
fps: 0,
|
||||
hardware: false,
|
||||
display: 0,
|
||||
resizable: false,
|
||||
borderless: false,
|
||||
vsync: false,
|
||||
fullscreen: false,
|
||||
allowHighDPI: false,
|
||||
alwaysOnTop: false,
|
||||
antialiasing: 0,
|
||||
orientation: Orientation.AUTO,
|
||||
allowShaders: false,
|
||||
requireShaders: false,
|
||||
depthBuffer: false,
|
||||
stencilBuffer: false,
|
||||
title: "",
|
||||
#if (js && html5)
|
||||
element: null,
|
||||
#end
|
||||
colorDepth: 0,
|
||||
minimized: false,
|
||||
maximized: false,
|
||||
hidden: false
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user