<commit_before>package platforms;


import haxe.io.Path;
import haxe.Json;
import haxe.Template;
import helpers.CompatibilityHelper;
import helpers.FileHelper;
import helpers.FlashHelper;
import helpers.PathHelper;
import helpers.ProcessHelper;
import project.AssetType;
import project.Haxelib;
import project.HXProject;
import project.PlatformTarget;
import sys.io.File;
import sys.FileSystem;


class FlashPlatform extends PlatformTarget {
	
	
	private var embedded:Bool;
	
	
	public function new (command:String, _project:HXProject, targetFlags:Map <String, String>) {
		
		super (command, _project, targetFlags);
		
	}
	
	
	public override function build ():Void {
		
		var destination = project.app.path + "/flash/bin";
		
		var type = "release";
		
		if (project.debug) {
			
			type = "debug";
			
		} else if (project.targetFlags.exists ("final")) {
			
			type = "final";
			
		}
		
		if (embedded) {
			
			var hxml = File.getContent (project.app.path + "/flash/haxe/" + type + ".hxml");
			hxml = StringTools.replace (hxml, "\r\n", "\n");
			hxml = StringTools.replace (hxml, "\n", " ");
			hxml = StringTools.trim (hxml);
			
			var args = hxml.split (" ");
			var strip;
			
			while ((strip = args.indexOf ("-swf-header")) > -1) {
				
				args.splice (strip, 2);
				
			}
			
			for (i in 0...args.length) {
				
				if (args[i].indexOf ("(") > -1) {
					
					args[i] = "'" + args[i] + "'";
					
				}
				
			}
			
			ProcessHelper.runCommand ("", "haxe", args);
			
		} else {
			
			var hxml = project.app.path + "/flash/haxe/" + type + ".hxml";
			ProcessHelper.runCommand ("", "haxe", [ hxml ] );
			
		}
		
		/*var usesOpenFL = false;
		
		for (haxelib in project.haxelibs) {
			
			if (haxelib.name == "nme" || haxelib.name == "openfl") {
				
				usesOpenFL = true;
				
			}
			<commit_msg>Tools fix for flash target when compiling on windows<commit_after>package platforms;


import haxe.io.Path;
import haxe.Json;
import haxe.Template;
import helpers.CompatibilityHelper;
import helpers.FileHelper;
import helpers.FlashHelper;
import helpers.PathHelper;
import helpers.PlatformHelper;
import helpers.ProcessHelper;
import project.AssetType;
import project.Haxelib;
import project.HXProject;
import project.PlatformTarget;
import project.Platform;
import sys.io.File;
import sys.FileSystem;


class FlashPlatform extends PlatformTarget {
	
	
	private var embedded:Bool;
	
	
	public function new (command:String, _project:HXProject, targetFlags:Map <String, String>) {
		
		super (command, _project, targetFlags);
		
	}
	
	
	public override function build ():Void {
		
		var destination = project.app.path + "/flash/bin";
		
		var type = "release";
		
		if (project.debug) {
			
			type = "debug";
			
		} else if (project.targetFlags.exists ("final")) {
			
			type = "final";
			
		}
		
		if (embedded) {
			
			var hxml = File.getContent (project.app.path + "/flash/haxe/" + type + ".hxml");
			hxml = StringTools.replace (hxml, "\r\n", "\n");
			hxml = StringTools.replace (hxml, "\n", " ");
			hxml = StringTools.trim (hxml);
			
			var args = hxml.split (" ");
			var strip;
			
			while ((strip = args.indexOf ("-swf-header")) > -1) {
				
				args.splice (strip, 2);
				
			}
			
			if (PlatformHelper.hostPlatform != Platform.WINDOWS) {
                
                for (i in 0...args.length) {
                    
                    if (args[i].indexOf ("(") > -1) {
                        
                        args[i] = "'" + args[i] + "'";
                        
                    }
                    
                }
               
			} 
			
			ProcessHelper.runCommand ("", "haxe", args);
			
		} else {
			
			var hxml = project.app.path + "/flash/haxe/" + type + ".hxml";
			ProcessHelper.runCommand ("", "haxe", [ hxml ] );
			
		}
		
		/*var usesOpenFL = false;
		
		for (haxelib in project.haxelibs) {
			
			if (haxelib.name == "nme" || haxelib.name == "openfl") {
				
				usesOpenFL = true;
				
			}
			
{'fraction_non_alphanumeric': 0.14238993710691825, 'fraction_numerical': 0.002012578616352201, 'mean_word_length': 2.296849087893864, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 24}, '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': '4917124', 'n_tokens_mistral': 1616, 'n_tokens_neox': 1271, 'n_words': 297}