Sync tool platform changes from HXP

This commit is contained in:
Joshua Granick
2018-07-24 16:18:49 -07:00
parent 70f17324ca
commit c0b3692402
9 changed files with 1518 additions and 1420 deletions

View File

@@ -9,7 +9,6 @@ import haxe.Unserializer;
import haxe.io.Path;
import haxe.rtti.Meta;
import hxp.helpers.*;
import hxp.platforms.*;
import hxp.project.*;
import lime.system.CFFI;
import sys.io.File;
@@ -704,9 +703,9 @@ class CommandLineTools {
platform = new HTML5Platform (command, project, targetFlags);
case FIREFOX:
// case FIREFOX:
platform = new FirefoxPlatform (command, project, targetFlags);
// platform = new FirefoxPlatform (command, project, targetFlags);
case EMSCRIPTEN:

View File

@@ -2,6 +2,7 @@ package;
import haxe.io.Path;
import haxe.Template;
import hxp.project.AssetType;
import hxp.project.HXProject;
import hxp.project.Icon;
@@ -24,6 +25,7 @@ class AIRPlatform extends FlashPlatform {
private var iconData:Array<Dynamic>;
private var splashScreenData:Array<Dynamic>;
private var targetPlatform:Platform;
private var targetPlatformType:PlatformType;
@@ -95,6 +97,12 @@ class AIRPlatform extends FlashPlatform {
}
for (splashScreen in splashScreenData) {
files.push (splashScreen.path);
}
var targetPath = switch (targetPlatform) {
case ANDROID: "bin/" + project.app.file + ".apk";
@@ -180,6 +188,31 @@ class AIRPlatform extends FlashPlatform {
}
private override function getDisplayHXML ():String {
var hxml = PathHelper.findTemplate (project.templatePaths, "flash/hxml/" + buildType + ".hxml");
var context = project.templateContext;
context.WIN_FLASHBACKGROUND = StringTools.hex (project.window.background, 6);
context.OUTPUT_DIR = targetDirectory;
for (dependency in project.dependencies) {
if (StringTools.endsWith (dependency.path, ".ane")) {
context.HAXE_FLAGS += "\n-swf-lib " + dependency.path;
}
}
var template = new Template (File.getContent (hxml));
return template.execute (context) + "\n-D display";
}
public override function install ():Void {
// TODO: Make separate install step
@@ -257,6 +290,14 @@ class AIRPlatform extends FlashPlatform {
}
var targetDevice = project.config.getString ("ios.device", "universal");
var targetDevices = [];
if (targetDevice != "ipad") targetDevices.push (1); // iphone
if (targetDevice != "iphone") targetDevices.push (2); // ipad
context.IOS_TARGET_DEVICES = targetDevices;
var iconSizes = [ 16, 29, 32, 36, 40, 48, 50, 57, 58, 60, 72, 75, 76, 80, 87, 96, 100, 114, 120, 128, 144, 152, 167, 180, 192, 512, 1024 ];
var icons = project.icons;
iconData = [];
@@ -344,6 +385,20 @@ class AIRPlatform extends FlashPlatform {
}
splashScreenData = [];
if (project.splashScreens != null) {
for (splashScreen in project.splashScreens) {
var path = Path.withoutDirectory (splashScreen.path);
FileHelper.copyFile (splashScreen.path, PathHelper.combine (destination, path), context);
splashScreenData.push ({ path: path });
}
}
}

View File

@@ -66,12 +66,14 @@ class AndroidPlatform extends PlatformTarget {
var hasARMV5 = (ArrayHelper.containsValue (project.architectures, Architecture.ARMV5) || ArrayHelper.containsValue (project.architectures, Architecture.ARMV6));
var hasARMV7 = ArrayHelper.containsValue (project.architectures, Architecture.ARMV7);
var hasARM64 = ArrayHelper.containsValue (project.architectures, Architecture.ARM64);
var hasX86 = ArrayHelper.containsValue (project.architectures, Architecture.X86);
var architectures = [];
if (hasARMV5) architectures.push (Architecture.ARMV5);
if (hasARMV7 || (!hasARMV5 && !hasX86)) architectures.push (Architecture.ARMV7);
if (hasARM64) architectures.push (Architecture.ARM64);
if (hasX86) architectures.push (Architecture.X86);
for (architecture in architectures) {
@@ -95,6 +97,17 @@ class AndroidPlatform extends PlatformTarget {
suffix = "-v7.so";
} else if (architecture == Architecture.ARM64) {
haxeParams = [ hxml, "-D", "android", "-D", "PLATFORM=android-21" ];
cppParams = [ "-Dandroid", "-DPLATFORM=android-21" ];
haxeParams.push ("-D");
haxeParams.push ("HXCPP_ARM64");
cppParams.push ("-DHXCPP_ARM64");
path = sourceSet + "/jniLibs/arm64-v8a";
suffix = "-64.so";
} else if (architecture == Architecture.X86) {
haxeParams.push ("-D");
@@ -131,6 +144,16 @@ class AndroidPlatform extends PlatformTarget {
}
if (!hasARM64) {
if (FileSystem.exists (sourceSet + "/jniLibs/arm64-v8a")) {
PathHelper.removeDirectory (sourceSet + "/jniLibs/arm64-v8a");
}
}
if (!hasX86) {
if (FileSystem.exists (sourceSet + "/jniLibs/x86")) {
@@ -221,12 +244,14 @@ class AndroidPlatform extends PlatformTarget {
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 arm64 = (command == "rebuild" || ArrayHelper.containsValue (project.architectures, Architecture.ARM64));
var x86 = (command == "rebuild" || ArrayHelper.containsValue (project.architectures, Architecture.X86));
var commands = [];
if (armv5) commands.push ([ "-Dandroid", "-DPLATFORM=android-14" ]);
if (armv7) commands.push ([ "-Dandroid", "-DHXCPP_ARMV7", "-DHXCPP_ARM7", "-DPLATFORM=android-14" ]);
if (arm64) commands.push ([ "-Dandroid", "-DHXCPP_ARM64", "-DPLATFORM=android-21" ]);
if (x86) commands.push ([ "-Dandroid", "-DHXCPP_X86", "-DPLATFORM=android-14" ]);
CPPHelper.rebuild (project, commands);
@@ -326,8 +351,8 @@ class AndroidPlatform extends PlatformTarget {
context.CPP_DIR = targetDirectory + "/obj";
context.OUTPUT_DIR = targetDirectory;
context.ANDROID_INSTALL_LOCATION = project.config.getString ("android.install-location", "auto");
context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt ("android.minimum-sdk-version", 9);
context.ANDROID_TARGET_SDK_VERSION = project.config.getInt ("android.target-sdk-version", 19);
context.ANDROID_MINIMUM_SDK_VERSION = project.config.getInt ("android.minimum-sdk-version", 14);
context.ANDROID_TARGET_SDK_VERSION = project.config.getInt ("android.target-sdk-version", 26);
context.ANDROID_EXTENSIONS = project.config.getArrayString ("android.extension");
context.ANDROID_PERMISSIONS = project.config.getArrayString ("android.permission", [ "android.permission.WAKE_LOCK", "android.permission.INTERNET", "android.permission.VIBRATE", "android.permission.ACCESS_NETWORK_STATE" ]);
context.ANDROID_GRADLE_VERSION = project.config.getString ("android.gradle-version", "2.10");
@@ -336,7 +361,7 @@ class AndroidPlatform extends PlatformTarget {
if (!project.environment.exists ("ANDROID_SDK") || !project.environment.exists ("ANDROID_NDK_ROOT")) {
var command = "lime";
var command = #if lime "lime" #else "hxp" #end;
var toolsBase = Type.resolveClass ("CommandLineTools");
if (toolsBase != null)
command = Reflect.field (toolsBase, "commandName");

View File

@@ -4,7 +4,6 @@ package;
import haxe.io.Path;
import haxe.Json;
import haxe.Template;
import hxp.helpers.CompatibilityHelper;
import hxp.helpers.DeploymentHelper;
import hxp.helpers.FileHelper;
import hxp.helpers.FlashHelper;

View File

@@ -3,7 +3,9 @@ package;
import haxe.io.Path;
import haxe.Template;
// import lime.text.Font;
#if lime
import lime.text.Font;
#end
import hxp.helpers.DeploymentHelper;
import hxp.helpers.ElectronHelper;
import hxp.helpers.FileHelper;
@@ -387,24 +389,16 @@ class HTML5Platform extends PlatformTarget {
if (embeddedAsset.type == "font" && embeddedAsset.sourcePath == asset.sourcePath) {
// var font = Font.fromFile (asset.sourcePath);
#if lime
var font = Font.fromFile (asset.sourcePath);
// embeddedAsset.ascender = font.ascender;
// embeddedAsset.descender = font.descender;
// embeddedAsset.height = font.height;
// embeddedAsset.numGlyphs = font.numGlyphs;
// embeddedAsset.underlinePosition = font.underlinePosition;
// embeddedAsset.underlineThickness = font.underlineThickness;
// embeddedAsset.unitsPerEM = font.unitsPerEM;
embeddedAsset.ascender = 0;
embeddedAsset.descender = 0;
embeddedAsset.height = 0;
embeddedAsset.numGlyphs = 0;
embeddedAsset.underlinePosition = 0;
embeddedAsset.underlineThickness = 0;
embeddedAsset.unitsPerEM = 0;
embeddedAsset.fontName = "sans";
embeddedAsset.ascender = font.ascender;
embeddedAsset.descender = font.descender;
embeddedAsset.height = font.height;
embeddedAsset.numGlyphs = font.numGlyphs;
embeddedAsset.underlinePosition = font.underlinePosition;
embeddedAsset.underlineThickness = font.underlineThickness;
embeddedAsset.unitsPerEM = font.unitsPerEM;
if (shouldEmbedFont) {
@@ -426,6 +420,7 @@ class HTML5Platform extends PlatformTarget {
}
break;
#end
}

View File

@@ -17,7 +17,9 @@ import hxp.helpers.PlatformHelper;
import hxp.helpers.ProcessHelper;
import hxp.helpers.StringHelper;
import hxp.helpers.WatchHelper;
#if lime
import lime.graphics.Image;
#end
import hxp.project.Architecture;
import hxp.project.Asset;
import hxp.project.AssetType;
@@ -573,12 +575,14 @@ class IOSPlatform extends PlatformTarget {
if (!FileSystem.exists (imagePath)) {
#if lime
LogHelper.info ("", " - \x1b[1mGenerating image:\x1b[0m " + imagePath);
var image = new Image (null, 0, 0, size.w, size.h, (0xFF << 24) | (project.window.background & 0xFFFFFF));
var bytes = image.encode ("png");
var bytes = image.encode (PNG);
File.saveBytes (imagePath, bytes);
#end
}

View File

@@ -1,4 +1,4 @@
package lime.tools.platforms;
package;
//import openfl.display.BitmapData;
@@ -17,7 +17,9 @@ import hxp.helpers.PlatformHelper;
import hxp.helpers.ProcessHelper;
import hxp.helpers.StringHelper;
import hxp.helpers.WatchHelper;
#if lime
import lime.graphics.Image;
#end
import hxp.project.Architecture;
import hxp.project.Asset;
import hxp.project.AssetType;
@@ -460,12 +462,14 @@ class TVOSPlatform extends PlatformTarget {
if (!FileSystem.exists (imagePath)) {
#if lime
LogHelper.info ("", " - \x1b[1mGenerating image:\x1b[0m " + imagePath);
var image = new Image (null, 0, 0, size.w, size.h, (0xFF << 24) | (project.window.background & 0xFFFFFF));
var bytes = image.encode ("png");
var bytes = image.encode (PNG);
File.saveBytes (imagePath, bytes);
#end
}
@@ -483,6 +487,7 @@ class TVOSPlatform extends PlatformTarget {
FileHelper.recursiveSmartCopyTemplate (project, "haxe", projectDirectory + "/haxe", context);
FileHelper.recursiveSmartCopyTemplate (project, "tvos/PROJ/Classes", projectDirectory + "/Classes", context);
FileHelper.recursiveSmartCopyTemplate (project, "tvos/PROJ/Images.xcassets", projectDirectory + "/Images.xcassets", context);
FileHelper.copyFileTemplate (project.templatePaths, "tvos/PROJ/PROJ-Entitlements.plist", projectDirectory + "/" + project.app.file + "-Entitlements.plist", context);
FileHelper.copyFileTemplate (project.templatePaths, "tvos/PROJ/PROJ-Info.plist", projectDirectory + "/" + project.app.file + "-Info.plist", context);
FileHelper.copyFileTemplate (project.templatePaths, "tvos/PROJ/PROJ-Prefix.pch", projectDirectory + "/" + project.app.file + "-Prefix.pch", context);
FileHelper.recursiveSmartCopyTemplate (project, "tvos/PROJ.xcodeproj", targetDirectory + "/" + project.app.file + ".xcodeproj", context);

View File

@@ -298,7 +298,7 @@ class WindowsPlatform extends PlatformTarget {
if (IconHelper.createWindowsIcon (icons, iconPath) && PlatformHelper.hostPlatform == Platform.WINDOWS) {
var templates = [ PathHelper.getHaxelib (new Haxelib ("lime")) + "/templates" ].concat (project.templatePaths);
var templates = [ PathHelper.getHaxelib (new Haxelib (#if lime "lime" #else "hxp" #end)) + "/templates" ].concat (project.templatePaths);
ProcessHelper.runCommand ("", PathHelper.findTemplate (templates, "bin/ReplaceVistaIcon.exe"), [ executablePath, iconPath, "1" ], true, true);
}
@@ -403,13 +403,31 @@ class WindowsPlatform extends PlatformTarget {
var commands = [];
if (targetFlags.exists ("64")) {
if (!targetFlags.exists ("32") && PlatformHelper.hostArchitecture == X64) {
commands.push ([ "-Dwindow", "-DHXCPP_M64" ]);
if (targetFlags.exists ("winrt")) {
commands.push ([ "-Dwinrt", "-DHXCPP_M64" ]);
} else {
commands.push ([ "-Dwindow", "-DHXCPP_M32" ]);
commands.push ([ "-Dwindows", "-DHXCPP_M64" ]);
}
}
if (!targetFlags.exists ("64") && (command == "rebuild" || PlatformHelper.hostArchitecture == Architecture.X86)) {
if (targetFlags.exists ("winrt")) {
commands.push ([ "-Dwinrt", "-DHXCPP_M32" ]);
} else {
commands.push ([ "-Dwindows", "-DHXCPP_M32" ]);
}
}
@@ -552,19 +570,16 @@ class WindowsPlatform extends PlatformTarget {
if (targetType == "cpp" && project.targetFlags.exists ("static")) {
// TODO: Better way to detect the suffix HXCPP will use?
var programFiles = project.environment.get ("ProgramFiles(x86)");
var hasVSCommunity = (programFiles != null && FileSystem.exists (PathHelper.combine (programFiles, "Microsoft Visual Studio/Installer/vswhere.exe")));
var hxcppMSVC = project.environment.get ("HXCPP_MSVC");
var vs140 = project.environment.get ("VS140COMNTOOLS");
var msvc19 = true;
var olderVersions = [ "120", "110", "100", "90", "80", "71", "70" ];
for (olderVersion in olderVersions) {
if (project.environment.exists ("VS" + olderVersion + "COMNTOOLS")) {
if ((!hasVSCommunity && vs140 == null) || (hxcppMSVC != null && hxcppMSVC != vs140)) {
msvc19 = false;
break;
}
}

View File

@@ -3,6 +3,7 @@
-D lime-curl
-D lime-cffi
-D lime
-cp platforms
-cp ../src
-lib format
-lib hxp