<commit_before>package lime.tools.platforms;


import haxe.io.Path;
import lime.project.AssetType;
import lime.project.HXProject;
import lime.project.Icon;
import lime.project.Platform;
import lime.project.PlatformType;
import lime.tools.helpers.AIRHelper;
import lime.tools.helpers.DeploymentHelper;
import lime.tools.helpers.FileHelper;
import lime.tools.helpers.FlashHelper;
import lime.tools.helpers.IconHelper;
import lime.tools.helpers.PathHelper;
import lime.tools.helpers.PlatformHelper;
import lime.tools.helpers.LogHelper;
import lime.tools.helpers.ZipHelper;
import sys.io.File;
import sys.FileSystem;


class AIRPlatform extends FlashPlatform {
	
	
	private var iconData:Array<Dynamic>;
	private var targetPlatform:Platform;
	private var targetPlatformType:PlatformType;
	
	
	public function new (command:String, _project:HXProject, targetFlags:Map<String, String>) {
		
		super (command, _project, targetFlags);
		
		targetDirectory = PathHelper.combine (project.app.path, project.config.getString ("air.output-directory", "air"));
		
		if (targetFlags.exists ("android")) {
			
			targetPlatform = Platform.ANDROID;
			targetPlatformType = MOBILE;
			
		} else if (targetFlags.exists ("ios")) {
			
			targetPlatform = Platform.IOS;
			targetPlatformType = MOBILE;
			
		} else if (targetFlags.exists ("windows")) {
			
			targetPlatform = Platform.WINDOWS;
			targetPlatformType = DESKTOP;
			
		} else if (targetFlags.exists ("mac")) {
			
			targetPlatform = Platform.MAC;
			targetPlatformType = DESKTOP;
			
		} else {
			
			targetPlatform = PlatformHelper.hostPlatform;
			targetPlatformType = DESKTOP;
			
		}
		
	}
	
	
	public override function build ():Void {
		
		super.build ();
		
		if (!project.defines.exists ("AIR_SDK")) {
			
			LogHelper.error ("You must define AIR_SDK with the path to your AIR SDK");
			
		}
		
		// TODO: Should we package on desktop in "deploy" command instead?
		
		if (targetPlatformType != DESKTOP) {
			
			var files = [ project.app.file + ".swf" ];
			for (asset in project.assets) {
				
				if (asset.embed == false && asset.type != TEMPLATE) {
					
					files.push (asset.targetPath);
					
				}
				
			}
			
			for (icon in iconData) {
				
				files.push (icon.path);
				
			}
			
			var targetPath = switch (targetPlatform) {
				
				case ANDROID: "bin/" + project.app.file + ".apk";
				case IOS: "bin/" + project.app.file + ".ipa";
				default: "bin/" + project.app.file + ".air";
				
			}
			
			AIRHelper.build (project, targetDirectory, targetPlatform, targetPath, "application.xml", files, "bin");
			
		}
		
	}
	
	
	public override function clean ():Void {
		
		if (FileSystem.exists (targetDirectory)) {
			
			PathHelper.removeDirectory (targetDirectory);
			
		}
		
	}
	
	
	public override function deploy ():Void {
		
		if (targetFlags.exists ("gdrive") || targetFlags.exists ("zip")) {
			
			DeploymentHelper.deploy (project, targetFlags, targetDirectory, "AIR");
			
		} else {
			
			var rootDirectory = targetDirectory + "/bin";
			var paths = PathHelper.readDirectory (rootDirectory, [ project.app.file + ".apk", project.app.file + ".ipa", project.app.file + ".air" ]);
			var files = [];
			
			for (path in paths) {
				
				files.push (path.substr (rootDirectory.length + 1));
				
			}
			
			var name = project.meta.title + " (" + project.meta.version + " build " + project.meta.buildNumber + ")";
			
			switch (targetPlatform) {
				
				case WINDOWS:
					
					name += " (Windows)";
				
				case MAC:
					
					name += " (macOS)";
				
				case IOS:
					
					name += " (iOS)";
				
				case ANDROID:
					
					name += " (Android)";
				
				default:
				
			}<commit_msg>fixes: ADT does not add extension if version number contains a dot<commit_after>package lime.tools.platforms;


import haxe.io.Path;
import lime.project.AssetType;
import lime.project.HXProject;
import lime.project.Icon;
import lime.project.Platform;
import lime.project.PlatformType;
import lime.tools.helpers.AIRHelper;
import lime.tools.helpers.DeploymentHelper;
import lime.tools.helpers.FileHelper;
import lime.tools.helpers.FlashHelper;
import lime.tools.helpers.IconHelper;
import lime.tools.helpers.PathHelper;
import lime.tools.helpers.PlatformHelper;
import lime.tools.helpers.LogHelper;
import lime.tools.helpers.ZipHelper;
import sys.io.File;
import sys.FileSystem;


class AIRPlatform extends FlashPlatform {
	
	
	private var iconData:Array<Dynamic>;
	private var targetPlatform:Platform;
	private var targetPlatformType:PlatformType;
	
	
	public function new (command:String, _project:HXProject, targetFlags:Map<String, String>) {
		
		super (command, _project, targetFlags);
		
		targetDirectory = PathHelper.combine (project.app.path, project.config.getString ("air.output-directory", "air"));
		
		if (targetFlags.exists ("android")) {
			
			targetPlatform = Platform.ANDROID;
			targetPlatformType = MOBILE;
			
		} else if (targetFlags.exists ("ios")) {
			
			targetPlatform = Platform.IOS;
			targetPlatformType = MOBILE;
			
		} else if (targetFlags.exists ("windows")) {
			
			targetPlatform = Platform.WINDOWS;
			targetPlatformType = DESKTOP;
			
		} else if (targetFlags.exists ("mac")) {
			
			targetPlatform = Platform.MAC;
			targetPlatformType = DESKTOP;
			
		} else {
			
			targetPlatform = PlatformHelper.hostPlatform;
			targetPlatformType = DESKTOP;
			
		}
		
	}
	
	
	public override function build ():Void {
		
		super.build ();
		
		if (!project.defines.exists ("AIR_SDK")) {
			
			LogHelper.error ("You must define AIR_SDK with the path to your AIR SDK");
			
		}
		
		// TODO: Should we package on desktop in "deploy" command instead?
		
		if (targetPlatformType != DESKTOP) {
			
			var files = [ project.app.file + ".swf" ];
			for (asset in project.assets) {
				
				if (asset.embed == false && asset.type != TEMPLATE) {
					
					files.push (asset.targetPath);
					
				}
				
			}
			
			for (icon in iconData) {
				
				files.push (icon.path);
				
			}
			
			var targetPath = switch (targetPlatform) {
				
				case ANDROID: "bin/" + project.app.file + ".apk";
				case IOS: "bin/" + project.app.file + ".ipa";
				default: "bin/" + project.app.file + ".air";
				
			}
			
			AIRHelper.build (project, targetDirectory, targetPlatform, targetPath, "application.xml", files, "bin");
			
		}
		
	}
	
	
	public override function clean ():Void {
		
		if (FileSystem.exists (targetDirectory)) {
			
			PathHelper.removeDirectory (targetDirectory);
			
		}
		
	}
	
	
	public override function deploy ():Void {
		
		if (targetFlags.exists ("gdrive") || targetFlags.exists ("zip")) {
			
			DeploymentHelper.deploy (project, targetFlags, targetDirectory, "AIR");
			
		} else {
			
			var rootDirectory = targetDirectory + "/bin";
			var paths = PathHelper.readDirectory (rootDirectory, [ project.app.file + ".apk", project.app.file + ".ipa", project.app.file + ".air" ]);
			var files = [];
			
			for (path in paths) {
				
				files.push (path.substr (rootDirectory.length + 1));
				
			}
			
			var name = project.meta.title + " (" + project.meta.version + " build " + project.meta.buildNumber + ")";
			
			switch (targetPlatform) {
				
				case WINDOWS:
					
					name += " (Windows)";
				
				case MAC:
					
					name += " (macOS)";
				
				case IOS:
					
					name += " (iOS).ipa";
				
				case ANDROID:
					
					name += " (Android).apk";
				
				default:
				
			}
{'fraction_non_alphanumeric': 0.12545577312626605, 'fraction_numerical': 0.0002700877785280216, 'mean_word_length': 2.9020021074815596, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2346304', 'n_tokens_mistral': 2952, 'n_tokens_neox': 2230, 'n_words': 527}