From 48bb8548eb5f64880cd17f1521df6792dc965ead Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 24 Aug 2017 17:42:07 -0700 Subject: [PATCH] Improvements to AIR target (icons, 'lime deploy' to generate .air on desktop) --- lime/tools/helpers/AIRHelper.hx | 19 ++++- lime/tools/platforms/AIRPlatform.hx | 76 +++++++++++++----- templates/air/template/application.xml | 102 +++++++++++++------------ 3 files changed, 124 insertions(+), 73 deletions(-) diff --git a/lime/tools/helpers/AIRHelper.hx b/lime/tools/helpers/AIRHelper.hx index 6e9ccbe03..d0dc432a3 100644 --- a/lime/tools/helpers/AIRHelper.hx +++ b/lime/tools/helpers/AIRHelper.hx @@ -9,7 +9,7 @@ import sys.FileSystem; class AIRHelper { - public static function build (project:HXProject, targetPlatform:Platform, workingDirectory:String, targetPath:String, applicationXML:String, files:Array):Void { + public static function build (project:HXProject, workingDirectory:String, targetPlatform:Platform, targetPath:String, applicationXML:String, files:Array, fileDirectory:String = null):Void { var airTarget = "air"; var extension = ".air"; @@ -142,6 +142,13 @@ class AIRHelper { } + if (fileDirectory != null && fileDirectory != "") { + + args.push ("-C"); + args.push (fileDirectory); + + } + args = args.concat (files); ProcessHelper.runCommand (workingDirectory, project.defines.get ("AIR_SDK") + "/bin/adt", args); @@ -149,7 +156,7 @@ class AIRHelper { } - public static function run (project:HXProject, targetPlatform:Platform, workingDirectory:String):Void { + public static function run (project:HXProject, workingDirectory:String, targetPlatform:Platform, applicationXML:String, rootDirectory:String = null):Void { if (targetPlatform == ANDROID) { @@ -190,7 +197,13 @@ class AIRHelper { } - args.push ("application.xml"); + args.push (applicationXML); + + if (rootDirectory != null && rootDirectory != "") { + + args.push (rootDirectory); + + } ProcessHelper.runCommand (workingDirectory, project.defines.get ("AIR_SDK") + "/bin/adl", args); diff --git a/lime/tools/platforms/AIRPlatform.hx b/lime/tools/platforms/AIRPlatform.hx index 99c9b0470..21655e569 100644 --- a/lime/tools/platforms/AIRPlatform.hx +++ b/lime/tools/platforms/AIRPlatform.hx @@ -22,6 +22,7 @@ import sys.FileSystem; class AIRPlatform extends FlashPlatform { + private var iconData:Array; private var targetPlatform:Platform; private var targetPlatformType:PlatformType; @@ -47,7 +48,9 @@ class AIRPlatform extends FlashPlatform { } - if (targetPlatformType != DESKTOP || project.targetFlags.exists ("final")) { + // TODO: Should we package on desktop in "deploy" command instead? + + if (targetPlatformType != DESKTOP) { var files = [ project.app.file + ".swf" ]; for (asset in project.assets) { @@ -60,7 +63,13 @@ class AIRPlatform extends FlashPlatform { } - AIRHelper.build (project, targetPlatform, targetDirectory + "/bin", project.app.file + ".air", "application.xml", files); + for (icon in iconData) { + + files.push (icon.path); + + } + + AIRHelper.build (project, targetDirectory, targetPlatform, "bin/" + project.app.file + ".air", "application.xml", files, "bin"); } @@ -80,14 +89,34 @@ class AIRPlatform extends FlashPlatform { public override function deploy ():Void { - DeploymentHelper.deploy (project, targetFlags, targetDirectory, "AIR"); + if (targetFlags.exists ("gdrive") || targetFlags.exists ("zip")) { + + DeploymentHelper.deploy (project, targetFlags, targetDirectory, "AIR"); + + } else { + + var name = project.meta.title + " (" + project.meta.version + " build " + project.meta.buildNumber + ").air"; + + var rootDirectory = targetDirectory + "/bin"; + var paths = PathHelper.readDirectory (rootDirectory); + var files = []; + + for (path in paths) { + + files.push (path.substr (rootDirectory.length + 1)); + + } + + AIRHelper.build (project, targetDirectory, targetPlatform, name, "application.xml", files, "bin"); + + } } public override function run ():Void { - AIRHelper.run (project, targetPlatform, targetDirectory + "/bin"); + AIRHelper.run (project, targetDirectory, targetPlatform, "application.xml", "bin"); } @@ -104,9 +133,31 @@ class AIRPlatform extends FlashPlatform { var context = generateContext (); context.OUTPUT_DIR = targetDirectory; + var iconSizes = [ 16, 32, 48, 128 ]; + var icons = project.icons; + iconData = []; + + if (icons.length == 0) { + + icons = [ new Icon (PathHelper.findTemplate (project.templatePaths, "default/icon.svg")) ]; + + } + + for (size in iconSizes) { + + if (IconHelper.createIcon (icons, size, size, targetDirectory + "/bin/_res/icon-" + size + ".png")) { + + iconData.push ({ size: size, path: "_res/icon-" + size + ".png" }); + + } + + } + + if (iconData.length > 0) context.icons = iconData; + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); FileHelper.recursiveCopyTemplate (project.templatePaths, "air/hxml", targetDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "air/template", targetDirectory + "/bin", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "air/template", targetDirectory, context); if (embedded) { @@ -155,21 +206,6 @@ class AIRPlatform extends FlashPlatform { } - //var sizes = [ 32, 48, 60, 64, 128, 512 ]; - //var icons = project.icons; - // - //if (icons.length == 0) { - // - //icons = [ new Icon (PathHelper.findTemplate (project.templatePaths, "default/icon.svg")) ]; - // - //} - // - //for (size in sizes) { - // - //IconHelper.createIcon (icons, size, size, PathHelper.combine (destination, "icon-" + size + ".png")); - // - //} - } diff --git a/templates/air/template/application.xml b/templates/air/template/application.xml index 77625ff9b..8079f2e97 100644 --- a/templates/air/template/application.xml +++ b/templates/air/template/application.xml @@ -1,59 +1,61 @@ - ::APP_PACKAGE:: - ::APP_VERSION:: - ::APP_FILE:: - ::APP_TITLE:: - ::APP_DESCRIPTION:: - - - ::APP_TITLE:: - ::APP_FILE::.swf - standard - false - true - true - false - ::WIN_RESIZABLE:: - - - ::APP_COMPANY::/::APP_TITLE:: - ::APP_TITLE:: - - false - false - + ::APP_PACKAGE:: + ::APP_VERSION:: + ::APP_FILE:: + ::APP_TITLE:: + ::APP_DESCRIPTION:: + + + ::APP_TITLE:: + ::APP_FILE::.swf + standard + false + true + true + false + ::WIN_RESIZABLE:: + + direct + + true + + ::APP_COMPANY::/::APP_TITLE:: + ::APP_TITLE:: + ::if (icons != null)::::foreach icons:: + ::path::::end:: + ::end:: + false + false + - - + + - - ]]> - + + ]]> + \ No newline at end of file