Update for HXP API change

This commit is contained in:
Joshua Granick
2018-08-04 18:09:44 -07:00
parent 46ab854e8e
commit bd9abc4c2a
50 changed files with 1343 additions and 1272 deletions

View File

@@ -2,17 +2,17 @@ package;
//import openfl.display.BitmapData;
import haxe.io.Path;
import hxp.Path;
import haxe.Json;
import haxe.Template;
import lime.tools.Architecture;
import hxp.ArrayHelper;
import hxp.ArrayTools;
import lime.tools.Asset;
import lime.tools.AssetHelper;
import lime.tools.AssetType;
import lime.tools.CPPHelper;
import lime.tools.DeploymentHelper;
import hxp.FileHelper;
import hxp.System;
import hxp.Haxelib;
import lime.tools.Icon;
import lime.tools.IconHelper;
@@ -20,15 +20,15 @@ import lime.tools.IOSHelper;
import lime.tools.Keystore;
import hxp.Log;
import hxp.NDLL;
import hxp.PathHelper;
import hxp.Path;
import lime.tools.Platform;
import hxp.PlatformHelper;
import hxp.System;
import lime.tools.PlatformTarget;
import hxp.ProcessHelper;
import hxp.System;
import lime.tools.Project;
import lime.tools.ProjectHelper;
import hxp.StringHelper;
import hxp.WatchHelper;
import hxp.StringTools;
import hxp.System;
#if lime
import lime.graphics.Image;
#end
@@ -43,16 +43,16 @@ class IOSPlatform extends PlatformTarget {
super (command, _project, targetFlags);
targetDirectory = PathHelper.combine (project.app.path, project.config.getString ("ios.output-directory", "ios"));
targetDirectory = Path.combine (project.app.path, project.config.getString ("ios.output-directory", "ios"));
}
public override function build ():Void {
if (project.targetFlags.exists ("xcode") && PlatformHelper.hostPlatform == MAC) {
if (project.targetFlags.exists ("xcode") && System.hostPlatform == MAC) {
ProcessHelper.runCommand ("", "open", [ targetDirectory + "/" + project.app.file + ".xcodeproj" ] );
System.runCommand ("", "open", [ targetDirectory + "/" + project.app.file + ".xcodeproj" ] );
} else {
@@ -75,7 +75,7 @@ class IOSPlatform extends PlatformTarget {
if (FileSystem.exists (targetDirectory)) {
PathHelper.removeDirectory (targetDirectory);
System.removeDirectory (targetDirectory);
}
@@ -101,7 +101,7 @@ class IOSPlatform extends PlatformTarget {
//project = project.clone ();
project.sources.unshift ("");
project.sources = PathHelper.relocatePaths (project.sources, PathHelper.combine (targetDirectory, project.app.file + "/haxe"));
project.sources = Path.relocatePaths (project.sources, Path.combine (targetDirectory, project.app.file + "/haxe"));
//project.dependencies.push ("stdc++");
if (project.targetFlags.exists ("xml")) {
@@ -143,7 +143,7 @@ class IOSPlatform extends PlatformTarget {
if (project.config.exists ("ios.provisioning-profile")) {
context.IOS_PROVISIONING_PROFILE = PathHelper.tryFullPath (project.config.getString ("ios.provisioning-profile"));
context.IOS_PROVISIONING_PROFILE = Path.tryFullPath (project.config.getString ("ios.provisioning-profile"));
}
@@ -204,7 +204,7 @@ class IOSPlatform extends PlatformTarget {
if (project.config.getFloat ("ios.deployment", 8) < 5) {
ArrayHelper.addUnique (architectures, Architecture.ARMV6);
ArrayTools.addUnique (architectures, Architecture.ARMV6);
}
@@ -267,7 +267,7 @@ class IOSPlatform extends PlatformTarget {
context.IOS_COMPILER = project.config.getString ("ios.compiler", "clang");
context.CPP_BUILD_LIBRARY = project.config.getString ("cpp.buildLibrary", "hxcpp");
var json = Json.parse (File.getContent (PathHelper.getHaxelib (new Haxelib ("hxcpp"), true) + "/haxelib.json"));
var json = Json.parse (File.getContent (Haxelib.getPath (new Haxelib ("hxcpp"), true) + "/haxelib.json"));
var version = Std.string (json.version);
var versionSplit = version.split (".");
@@ -330,17 +330,17 @@ class IOSPlatform extends PlatformTarget {
} else if (Path.extension (dependency.path) == "framework") {
name = Path.withoutDirectory (dependency.path);
path = PathHelper.tryFullPath (dependency.path);
path = Path.tryFullPath (dependency.path);
fileType = "wrapper.framework";
}
if (name != null) {
var frameworkID = "11C0000000000018" + StringHelper.getUniqueID ();
var fileID = "11C0000000000018" + StringHelper.getUniqueID ();
var frameworkID = "11C0000000000018" + StringTools.getUniqueID ();
var fileID = "11C0000000000018" + StringTools.getUniqueID ();
ArrayHelper.addUnique (context.frameworkSearchPaths, Path.directory (path));
ArrayTools.addUnique (context.frameworkSearchPaths, Path.directory (path));
context.ADDL_PBX_BUILD_FILE += " " + frameworkID + " /* " + name + " in Frameworks */ = {isa = PBXBuildFile; fileRef = " + fileID + " /* " + name + " */; };\n";
context.ADDL_PBX_FILE_REFERENCE += " " + fileID + " /* " + name + " */ = {isa = PBXFileReference; lastKnownFileType = \"" + fileType + "\"; name = \"" + name + "\"; path = \"" + path + "\"; sourceTree = SDKROOT; };\n";
@@ -351,8 +351,8 @@ class IOSPlatform extends PlatformTarget {
}
context.HXML_PATH = PathHelper.findTemplate (project.templatePaths, "iphone/PROJ/haxe/Build.hxml", false);
if (context.HXML_PATH == null) context.HXML_PATH = PathHelper.findTemplate (project.templatePaths, "ios/template/{{app.file}}/haxe/Build.hxml");
context.HXML_PATH = System.findTemplate (project.templatePaths, "iphone/PROJ/haxe/Build.hxml", false);
if (context.HXML_PATH == null) context.HXML_PATH = System.findTemplate (project.templatePaths, "ios/template/{{app.file}}/haxe/Build.hxml");
context.PRERENDERED_ICON = project.config.getBool ("ios.prerenderedIcon", false);
var allowInsecureHTTP = project.config.getString ("ios.allow-insecure-http", "*");
@@ -396,8 +396,8 @@ class IOSPlatform extends PlatformTarget {
private function getDisplayHXML ():String {
var hxml = PathHelper.findTemplate (project.templatePaths, "iphone/PROJ/haxe/Build.hxml", false);
if (hxml == null) hxml = PathHelper.findTemplate (project.templatePaths, "iphone/template/{{app.file}}/Build.hxml", true);
var hxml = System.findTemplate (project.templatePaths, "iphone/PROJ/haxe/Build.hxml", false);
if (hxml == null) hxml = System.findTemplate (project.templatePaths, "iphone/template/{{app.file}}/Build.hxml", true);
var template = new Template (File.getContent (hxml));
// project = project.clone ();
@@ -472,8 +472,8 @@ class IOSPlatform extends PlatformTarget {
if (asset.embed && asset.sourcePath == "") {
var path = PathHelper.combine (targetDirectory + "/" + project.app.file + "/obj/tmp", asset.targetPath);
PathHelper.mkdir (Path.directory (path));
var path = Path.combine (targetDirectory + "/" + project.app.file + "/obj/tmp", asset.targetPath);
System.mkdir (Path.directory (path));
AssetHelper.copyAsset (asset, path);
asset.sourcePath = path;
@@ -493,10 +493,10 @@ class IOSPlatform extends PlatformTarget {
var projectDirectory = targetDirectory + "/" + project.app.file + "/";
PathHelper.mkdir (targetDirectory);
PathHelper.mkdir (projectDirectory);
PathHelper.mkdir (projectDirectory + "/haxe");
PathHelper.mkdir (projectDirectory + "/haxe/lime/installer");
System.mkdir (targetDirectory);
System.mkdir (projectDirectory);
System.mkdir (projectDirectory + "/haxe");
System.mkdir (projectDirectory + "/haxe/lime/installer");
var iconSizes:Array<IconSize> = [
{ name: "Icon-20.png", size: 20 },
@@ -524,20 +524,20 @@ class IOSPlatform extends PlatformTarget {
context.HAS_ICON = true;
var iconPath = PathHelper.combine (projectDirectory, "Images.xcassets/AppIcon.appiconset");
PathHelper.mkdir (iconPath);
var iconPath = Path.combine (projectDirectory, "Images.xcassets/AppIcon.appiconset");
System.mkdir (iconPath);
var icons = project.icons;
if (icons.length == 0) {
icons = [ new Icon (PathHelper.findTemplate (project.templatePaths, "default/icon.svg")) ];
icons = [ new Icon (System.findTemplate (project.templatePaths, "default/icon.svg")) ];
}
for (iconSize in iconSizes) {
if (!IconHelper.createIcon (icons, iconSize.size, iconSize.size, PathHelper.combine (iconPath, iconSize.name))) {
if (!IconHelper.createIcon (icons, iconSize.size, iconSize.size, Path.combine (iconPath, iconSize.name))) {
context.HAS_ICON = false;
@@ -560,8 +560,8 @@ class IOSPlatform extends PlatformTarget {
{ name: "Default-Landscape-812h@3x.png", w: 2436, h: 1125 } // iPhone X, landscape
];
var splashScreenPath = PathHelper.combine (projectDirectory, "Images.xcassets/LaunchImage.launchimage");
PathHelper.mkdir (splashScreenPath);
var splashScreenPath = Path.combine (projectDirectory, "Images.xcassets/LaunchImage.launchimage");
System.mkdir (splashScreenPath);
for (size in splashSizes) {
@@ -571,7 +571,7 @@ class IOSPlatform extends PlatformTarget {
if (splashScreen.width == size.w && splashScreen.height == size.h && Path.extension (splashScreen.path) == "png") {
FileHelper.copyFile (splashScreen.path, PathHelper.combine (splashScreenPath, size.name));
System.copyFile (splashScreen.path, Path.combine (splashScreenPath, size.name));
match = true;
}
@@ -580,7 +580,7 @@ class IOSPlatform extends PlatformTarget {
if (!match) {
var imagePath = PathHelper.combine (splashScreenPath, size.name);
var imagePath = Path.combine (splashScreenPath, size.name);
if (!FileSystem.exists (imagePath)) {
@@ -601,8 +601,8 @@ class IOSPlatform extends PlatformTarget {
context.HAS_LAUNCH_IMAGE = true;
PathHelper.mkdir (projectDirectory + "/resources");
PathHelper.mkdir (projectDirectory + "/haxe/build");
System.mkdir (projectDirectory + "/resources");
System.mkdir (projectDirectory + "/haxe/build");
// Long deprecated template path
@@ -618,11 +618,11 @@ class IOSPlatform extends PlatformTarget {
ProjectHelper.recursiveSmartCopyTemplate (project, "haxe", projectDirectory + "/haxe", context, true, false);
ProjectHelper.recursiveSmartCopyTemplate (project, "iphone/PROJ/Classes", projectDirectory + "/Classes", context, true, false);
ProjectHelper.recursiveSmartCopyTemplate (project, "iphone/PROJ/Images.xcassets", projectDirectory + "/Images.xcassets", context, true, false);
FileHelper.copyFileTemplate (project.templatePaths, "iphone/PROJ/PROJ-Info.plist", projectDirectory + "/" + project.app.file + "-Info.plist", context, true, false);
FileHelper.copyFileTemplate (project.templatePaths, "iphone/PROJ/PROJ-Prefix.pch", projectDirectory + "/" + project.app.file + "-Prefix.pch", context, true, false);
System.copyFileTemplate (project.templatePaths, "iphone/PROJ/PROJ-Info.plist", projectDirectory + "/" + project.app.file + "-Info.plist", context, true, false);
System.copyFileTemplate (project.templatePaths, "iphone/PROJ/PROJ-Prefix.pch", projectDirectory + "/" + project.app.file + "-Prefix.pch", context, true, false);
ProjectHelper.recursiveSmartCopyTemplate (project, "iphone/PROJ.xcodeproj", targetDirectory + "/" + project.app.file + ".xcodeproj", context, true, false);
PathHelper.mkdir (projectDirectory + "/lib");
System.mkdir (projectDirectory + "/lib");
for (archID in 0...6) {
@@ -642,30 +642,30 @@ class IOSPlatform extends PlatformTarget {
var libExt = [ ".iphoneos.a", ".iphoneos-v7.a", ".iphoneos-v7s.a", ".iphoneos-64.a", ".iphonesim.a", ".iphonesim-64.a" ][archID];
PathHelper.mkdir (projectDirectory + "/lib/" + arch);
PathHelper.mkdir (projectDirectory + "/lib/" + arch + "-debug");
System.mkdir (projectDirectory + "/lib/" + arch);
System.mkdir (projectDirectory + "/lib/" + arch + "-debug");
for (ndll in project.ndlls) {
//if (ndll.haxelib != null) {
var releaseLib = PathHelper.getLibraryPath (ndll, "iPhone", "lib", libExt);
var debugLib = PathHelper.getLibraryPath (ndll, "iPhone", "lib", libExt, true);
var releaseLib = NDLL.getLibraryPath (ndll, "iPhone", "lib", libExt);
var debugLib = NDLL.getLibraryPath (ndll, "iPhone", "lib", libExt, true);
var releaseDest = projectDirectory + "/lib/" + arch + "/lib" + ndll.name + ".a";
var debugDest = projectDirectory + "/lib/" + arch + "-debug/lib" + ndll.name + ".a";
if (!FileSystem.exists (releaseLib)) {
releaseLib = PathHelper.getLibraryPath (ndll, "iPhone", "lib", ".iphoneos.a");
debugLib = PathHelper.getLibraryPath (ndll, "iPhone", "lib", ".iphoneos.a", true);
releaseLib = NDLL.getLibraryPath (ndll, "iPhone", "lib", ".iphoneos.a");
debugLib = NDLL.getLibraryPath (ndll, "iPhone", "lib", ".iphoneos.a", true);
}
FileHelper.copyIfNewer (releaseLib, releaseDest);
System.copyIfNewer (releaseLib, releaseDest);
if (FileSystem.exists (debugLib) && debugLib != releaseLib) {
FileHelper.copyIfNewer (debugLib, debugDest);
System.copyIfNewer (debugLib, debugDest);
} else if (FileSystem.exists (debugDest)) {
@@ -689,7 +689,7 @@ class IOSPlatform extends PlatformTarget {
}
FileHelper.copyIfNewer (dependency.path, projectDirectory + "/lib/" + arch + "/" + fileName);
System.copyIfNewer (dependency.path, projectDirectory + "/lib/" + arch + "/" + fileName);
}
@@ -697,36 +697,36 @@ class IOSPlatform extends PlatformTarget {
}
PathHelper.mkdir (projectDirectory + "/assets");
System.mkdir (projectDirectory + "/assets");
for (asset in project.assets) {
if (asset.type != AssetType.TEMPLATE) {
var targetPath = PathHelper.combine (projectDirectory + "/assets/", asset.resourceName);
var targetPath = Path.combine (projectDirectory + "/assets/", asset.resourceName);
//var sourceAssetPath:String = projectDirectory + "haxe/" + asset.sourcePath;
PathHelper.mkdir (Path.directory (targetPath));
System.mkdir (Path.directory (targetPath));
AssetHelper.copyAssetIfNewer (asset, targetPath);
//PathHelper.mkdir (Path.directory (sourceAssetPath));
//FileHelper.linkFile (flatAssetPath, sourceAssetPath, true, true);
//System.mkdir (Path.directory (sourceAssetPath));
//System.linkFile (flatAssetPath, sourceAssetPath, true, true);
} else {
var targetPath = PathHelper.combine (projectDirectory, asset.targetPath);
var targetPath = Path.combine (projectDirectory, asset.targetPath);
PathHelper.mkdir (Path.directory (targetPath));
System.mkdir (Path.directory (targetPath));
AssetHelper.copyAsset (asset, targetPath, context);
}
}
if (project.targetFlags.exists ("xcode") && PlatformHelper.hostPlatform == MAC && command == "update") {
if (project.targetFlags.exists ("xcode") && System.hostPlatform == MAC && command == "update") {
ProcessHelper.runCommand ("", "open", [ targetDirectory + "/" + project.app.file + ".xcodeproj" ] );
System.runCommand ("", "open", [ targetDirectory + "/" + project.app.file + ".xcodeproj" ] );
}
@@ -736,7 +736,7 @@ class IOSPlatform extends PlatformTarget {
/*private function updateLaunchImage () {
var destination = buildDirectory + "/ios";
PathHelper.mkdir (destination);
System.mkdir (destination);
var has_launch_image = false;
if (launchImages.length > 0) has_launch_image = true;
@@ -745,7 +745,7 @@ class IOSPlatform extends PlatformTarget {
var splitPath = launchImage.name.split ("/");
var path = destination + "/" + splitPath[splitPath.length - 1];
FileHelper.copyFile (launchImage.name, path, context, false);
System.copyFile (launchImage.name, path, context, false);
}
@@ -756,9 +756,9 @@ class IOSPlatform extends PlatformTarget {
public override function watch ():Void {
var dirs = WatchHelper.processHXML (getDisplayHXML (), project.app.path);
var dirs = []; // WatchHelper.processHXML (getDisplayHXML (), project.app.path);
var command = ProjectHelper.getCurrentCommand ();
WatchHelper.watch (command, dirs);
System.watch (command, dirs);
}