From 287b94e6dd33e54bded4ab361a05754774dce699 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Thu, 25 Dec 2014 21:20:32 -0800 Subject: [PATCH] Use a standardized 'targetDirectory' value in the target handlers, and pass this onto the library processors for use with caching --- tools/helpers/AssetHelper.hx | 8 +++- tools/platforms/AndroidPlatform.hx | 46 ++++++++++---------- tools/platforms/BlackBerryPlatform.hx | 61 +++++++++++++-------------- tools/platforms/EmscriptenPlatform.hx | 59 ++++++++++++-------------- tools/platforms/FirefoxPlatform.hx | 12 +++--- tools/platforms/FlashPlatform.hx | 26 ++++++------ tools/platforms/HTML5Platform.hx | 37 ++++++++-------- tools/platforms/IOSPlatform.hx | 19 ++++----- tools/platforms/LinuxPlatform.hx | 1 - tools/platforms/MacPlatform.hx | 1 - tools/platforms/TizenPlatform.hx | 34 +++++++-------- tools/platforms/WebOSPlatform.hx | 30 +++++++------ tools/platforms/WindowsPlatform.hx | 1 - tools/project/PlatformTarget.hx | 3 +- 14 files changed, 165 insertions(+), 173 deletions(-) diff --git a/tools/helpers/AssetHelper.hx b/tools/helpers/AssetHelper.hx index 56e7a73ee..0f47b1c2a 100644 --- a/tools/helpers/AssetHelper.hx +++ b/tools/helpers/AssetHelper.hx @@ -48,7 +48,7 @@ class AssetHelper { } - public static function processLibraries (project:HXProject):Void { + public static function processLibraries (project:HXProject, targetDirectory:String = null):Void { var handlers = new Array (); @@ -91,6 +91,12 @@ class AssetHelper { } + if (targetDirectory != null) { + + args.push ("--targetDirectory=" + PathHelper.tryFullPath (targetDirectory)); + + } + ProcessHelper.runCommand ("", "haxelib", args); if (FileSystem.exists (outputFile)) { diff --git a/tools/platforms/AndroidPlatform.hx b/tools/platforms/AndroidPlatform.hx index 4743eba86..8c068f4ca 100644 --- a/tools/platforms/AndroidPlatform.hx +++ b/tools/platforms/AndroidPlatform.hx @@ -50,12 +50,14 @@ class AndroidPlatform extends PlatformTarget { } + targetDirectory = project.app.path + "/android"; + } public override function build ():Void { - var destination = project.app.path + "/android/bin"; + var destination = targetDirectory + "/bin"; var type = "release"; @@ -69,7 +71,7 @@ class AndroidPlatform extends PlatformTarget { } - var hxml = project.app.path + "/android/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; var hasARMV5 = (ArrayHelper.containsValue (project.architectures, Architecture.ARMV5) || ArrayHelper.containsValue (project.architectures, Architecture.ARMV6)); var hasARMV7 = ArrayHelper.containsValue (project.architectures, Architecture.ARMV7); @@ -85,7 +87,7 @@ class AndroidPlatform extends PlatformTarget { var haxeParams = [ hxml, "-D", "android", "-D", "android-9" ]; var cppParams = [ "-Dandroid", "-Dandroid-9" ]; - var path = project.app.path + "/android/bin/libs/armeabi"; + var path = targetDirectory + "/bin/libs/armeabi"; var suffix = ".so"; if (architecture == Architecture.ARMV7) { @@ -96,7 +98,7 @@ class AndroidPlatform extends PlatformTarget { if (hasARMV5) { - path = project.app.path + "/android/bin/libs/armeabi-v7"; + path = targetDirectory + "/bin/libs/armeabi-v7"; } @@ -107,7 +109,7 @@ class AndroidPlatform extends PlatformTarget { haxeParams.push ("-D"); haxeParams.push ("HXCPP_X86"); cppParams.push ("-DHXCPP_X86"); - path = project.app.path + "/android/bin/libs/x86"; + path = targetDirectory + "/bin/libs/x86"; suffix = "-x86.so"; } @@ -119,17 +121,17 @@ class AndroidPlatform extends PlatformTarget { } ProcessHelper.runCommand ("", "haxe", haxeParams); - CPPHelper.compile (project, project.app.path + "/android/obj", cppParams); + CPPHelper.compile (project, targetDirectory + "/obj", cppParams); - FileHelper.copyIfNewer (project.app.path + "/android/obj/libApplicationMain" + (project.debug ? "-debug" : "") + suffix, path + "/libApplicationMain.so"); + FileHelper.copyIfNewer (targetDirectory + "/obj/libApplicationMain" + (project.debug ? "-debug" : "") + suffix, path + "/libApplicationMain.so"); } if (!ArrayHelper.containsValue (project.architectures, Architecture.ARMV7) || !hasARMV5) { - if (FileSystem.exists (project.app.path + "/android/bin/libs/armeabi-v7")) { + if (FileSystem.exists (targetDirectory + "/bin/libs/armeabi-v7")) { - PathHelper.removeDirectory (project.app.path + "/android/bin/libs/armeabi-v7"); + PathHelper.removeDirectory (targetDirectory + "/bin/libs/armeabi-v7"); } @@ -137,9 +139,9 @@ class AndroidPlatform extends PlatformTarget { if (!hasX86) { - if (FileSystem.exists (project.app.path + "/android/bin/libs/x86")) { + if (FileSystem.exists (targetDirectory + "/bin/libs/x86")) { - PathHelper.removeDirectory (project.app.path + "/android/bin/libs/x86"); + PathHelper.removeDirectory (targetDirectory + "/bin/libs/x86"); } @@ -152,11 +154,9 @@ class AndroidPlatform extends PlatformTarget { public override function clean ():Void { - var targetPath = project.app.path + "/android"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -168,7 +168,7 @@ class AndroidPlatform extends PlatformTarget { var hxml = PathHelper.findTemplate (project.templatePaths, "android/hxml/" + (project.debug ? "debug" : "release") + ".hxml"); var context = project.templateContext; - context.CPP_DIR = project.app.path + "/android/obj"; + context.CPP_DIR = targetDirectory + "/obj"; var template = new Template (File.getContent (hxml)); Sys.println (template.execute (context)); @@ -186,7 +186,7 @@ class AndroidPlatform extends PlatformTarget { } - deviceID = AndroidHelper.install (project, FileSystem.fullPath (project.app.path) + "/android/bin/bin/" + project.app.file + "-" + build + ".apk", deviceID); + deviceID = AndroidHelper.install (project, FileSystem.fullPath (targetDirectory) + "/bin/bin/" + project.app.file + "-" + build + ".apk", deviceID); } @@ -235,7 +235,7 @@ class AndroidPlatform extends PlatformTarget { //initialize (project); - var destination = project.app.path + "/android/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); PathHelper.mkdir (destination + "/res/drawable-ldpi/"); PathHelper.mkdir (destination + "/res/drawable-mdpi/"); @@ -277,13 +277,13 @@ class AndroidPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/android/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; - context.CPP_DIR = project.app.path + "/android/obj"; + context.CPP_DIR = targetDirectory + "/obj"; context.ANDROID_INSTALL_LOCATION = project.config.getString ("android.install-location", "preferExternal"); 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", 16); @@ -331,8 +331,6 @@ class AndroidPlatform extends PlatformTarget { packageDirectory = destination + "/src/" + packageDirectory.split (".").join ("/"); PathHelper.mkdir (packageDirectory); - //SWFHelper.generateSWFClasses (project, project.app.path + "/android/haxe"); - for (javaPath in project.javaPaths) { try { @@ -371,8 +369,8 @@ class AndroidPlatform extends PlatformTarget { FileHelper.recursiveCopyTemplate (project.templatePaths, "android/template", destination, context); FileHelper.copyFileTemplate (project.templatePaths, "android/MainActivity.java", packageDirectory + "/MainActivity.java", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", project.app.path + "/android/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "android/hxml", project.app.path + "/android/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "android/hxml", targetDirectory + "/haxe", context); for (asset in project.assets) { diff --git a/tools/platforms/BlackBerryPlatform.hx b/tools/platforms/BlackBerryPlatform.hx index b9b784c47..4760e60ee 100644 --- a/tools/platforms/BlackBerryPlatform.hx +++ b/tools/platforms/BlackBerryPlatform.hx @@ -24,7 +24,6 @@ import sys.FileSystem; class BlackBerryPlatform extends PlatformTarget { - private var outputDirectory:String; private var outputFile:String; @@ -44,13 +43,13 @@ class BlackBerryPlatform extends PlatformTarget { if (!project.targetFlags.exists ("html5")) { - outputDirectory = project.app.path + "/blackberry/cpp"; - outputFile = outputDirectory + "/bin/" + PathHelper.safeFileName (project.app.file); + targetDirectory = project.app.path + "/blackberry/cpp"; + outputFile = targetDirectory + "/bin/" + PathHelper.safeFileName (project.app.file); } else { - outputDirectory = project.app.path + "/blackberry/html5"; - outputFile = outputDirectory + "/src/" + project.app.file + ".js"; + targetDirectory = project.app.path + "/blackberry/html5"; + outputFile = targetDirectory + "/src/" + project.app.file + ".js"; } @@ -77,14 +76,14 @@ class BlackBerryPlatform extends PlatformTarget { } - var hxml = outputDirectory + "/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; ProcessHelper.runCommand ("", "haxe", [ hxml, "-D", "blackberry" ] ); } if (!project.targetFlags.exists ("html5")) { - var destination = outputDirectory + "/bin/"; + var destination = targetDirectory + "/bin/"; var arch = ""; if (project.targetFlags.exists ("simulator")) { @@ -134,19 +133,19 @@ class BlackBerryPlatform extends PlatformTarget { } - CPPHelper.compile (project, outputDirectory + "/obj", [ "-Dblackberry" ]); - FileHelper.copyIfNewer (outputDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : ""), outputFile); - BlackBerryHelper.createPackage (project, outputDirectory, "bin/bar-descriptor.xml", project.meta.packageName + "_" + project.meta.version + ".bar"); + CPPHelper.compile (project, targetDirectory + "/obj", [ "-Dblackberry" ]); + FileHelper.copyIfNewer (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : ""), outputFile); + BlackBerryHelper.createPackage (project, targetDirectory, "bin/bar-descriptor.xml", project.meta.packageName + "_" + project.meta.version + ".bar"); } else { if (project.targetFlags.exists ("minify")) { - HTML5Helper.minify (project, project.app.path + "/blackberry/html5/src/" + project.app.file + ".js"); + HTML5Helper.minify (project, targetDirectory + "/src/" + project.app.file + ".js"); } - BlackBerryHelper.createWebWorksPackage (project, outputDirectory + "/src", outputDirectory + "/bin"); + BlackBerryHelper.createWebWorksPackage (project, targetDirectory + "/src", targetDirectory + "/bin"); } @@ -155,9 +154,9 @@ class BlackBerryPlatform extends PlatformTarget { public override function clean ():Void { - if (FileSystem.exists (outputDirectory)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (outputDirectory); + PathHelper.removeDirectory (targetDirectory); } @@ -185,13 +184,13 @@ class BlackBerryPlatform extends PlatformTarget { hxml = PathHelper.findTemplate (project.templatePaths, "blackberry/hxml/" + type + ".hxml"); - context.CPP_DIR = outputDirectory + "/obj"; + context.CPP_DIR = targetDirectory + "/obj"; } else { hxml = PathHelper.findTemplate (project.templatePaths, "html5/hxml/" + type + ".hxml"); - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; } @@ -221,11 +220,11 @@ class BlackBerryPlatform extends PlatformTarget { if (!project.targetFlags.exists ("html5")) { - BlackBerryHelper.deploy (project, outputDirectory, project.meta.packageName + "_" + project.meta.version + ".bar"); + BlackBerryHelper.deploy (project, targetDirectory, project.meta.packageName + "_" + project.meta.version + ".bar"); } else { - BlackBerryHelper.deploy (project, outputDirectory + "/bin/" + (project.targetFlags.exists ("simulator") ? "simulator" : "device"), PathHelper.safeFileName (project.app.file) + ".bar"); + BlackBerryHelper.deploy (project, targetDirectory + "/bin/" + (project.targetFlags.exists ("simulator") ? "simulator" : "device"), PathHelper.safeFileName (project.app.file) + ".bar"); } @@ -236,11 +235,11 @@ class BlackBerryPlatform extends PlatformTarget { if (!project.targetFlags.exists ("html5")) { - BlackBerryHelper.trace (project, outputDirectory, project.meta.packageName + "_" + project.meta.version + ".bar"); + BlackBerryHelper.trace (project, targetDirectory, project.meta.packageName + "_" + project.meta.version + ".bar"); } else { - //BlackBerryHelper.trace (project, outputDirectory + "/bin/" + (project.targetFlags.exists ("simulator") ? "simulator" : "device"), PathHelper.safeFileName (project.app.file) + ".bar"); + //BlackBerryHelper.trace (project, targetDirectory + "/bin/" + (project.targetFlags.exists ("simulator") ? "simulator" : "device"), PathHelper.safeFileName (project.app.file) + ".bar"); } @@ -284,28 +283,28 @@ class BlackBerryPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + outputDirectory + "/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; - var destination = outputDirectory + "/bin/"; + var destination = targetDirectory + "/bin/"; if (!project.targetFlags.exists ("html5")) { - context.CPP_DIR = outputDirectory + "/obj"; + context.CPP_DIR = targetDirectory + "/obj"; } else { - destination = outputDirectory + "/src/"; + destination = targetDirectory + "/src/"; context.WIN_FLASHBACKGROUND = StringTools.hex (project.window.background, 6); - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; } - context.BLACKBERRY_AUTHOR_ID = BlackBerryHelper.processDebugToken (project, project.app.path + "/blackberry").authorID; + context.BLACKBERRY_AUTHOR_ID = BlackBerryHelper.processDebugToken (project, targetDirectory).authorID; context.APP_FILE_SAFE = PathHelper.safeFileName (project.app.file); PathHelper.mkdir (destination); @@ -327,8 +326,8 @@ class BlackBerryPlatform extends PlatformTarget { if (!project.targetFlags.exists ("html5")) { FileHelper.copyFileTemplate (project.templatePaths, "blackberry/template/bar-descriptor.xml", destination + "/bar-descriptor.xml", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "blackberry/hxml", outputDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "blackberry/hxml", targetDirectory + "/haxe", context); } else { @@ -337,9 +336,9 @@ class BlackBerryPlatform extends PlatformTarget { if (project.app.main != null) { - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/haxe", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/hxml", outputDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/hxml", targetDirectory + "/haxe", context); } diff --git a/tools/platforms/EmscriptenPlatform.hx b/tools/platforms/EmscriptenPlatform.hx index da46dc088..d9c845a15 100644 --- a/tools/platforms/EmscriptenPlatform.hx +++ b/tools/platforms/EmscriptenPlatform.hx @@ -22,7 +22,6 @@ import sys.FileSystem; class EmscriptenPlatform extends PlatformTarget { - private var outputDirectory:String; private var outputFile:String; @@ -30,8 +29,8 @@ class EmscriptenPlatform extends PlatformTarget { super (command, _project, targetFlags); - outputDirectory = project.app.path + "/emscripten"; - outputFile = outputDirectory + "/bin/" + project.app.file + ".js"; + targetDirectory = project.app.path + "/emscripten"; + outputFile = targetDirectory + "/bin/" + project.app.file + ".js"; } @@ -50,10 +49,10 @@ class EmscriptenPlatform extends PlatformTarget { } - var hxml = outputDirectory + "/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; ProcessHelper.runCommand ("", "haxe", [ hxml, "-D", "emscripten", "-D", "webgl" ] ); - CPPHelper.compile (project, outputDirectory + "/obj", [ "-Demscripten", "-Dwebgl" ]); + CPPHelper.compile (project, targetDirectory + "/obj", [ "-Demscripten", "-Dwebgl" ]); if (project.environment.exists ("EMSCRIPTEN_SDK")) { @@ -63,7 +62,7 @@ class EmscriptenPlatform extends PlatformTarget { Sys.putEnv ("EMCC_LLVM_TARGET", "i386-pc-linux-gnu"); - ProcessHelper.runCommand ("", "emcc", [ outputDirectory + "/obj/Main.cpp", "-o", outputDirectory + "/obj/Main.o" ], true, false, true); + ProcessHelper.runCommand ("", "emcc", [ targetDirectory + "/obj/Main.cpp", "-o", targetDirectory + "/obj/Main.o" ], true, false, true); var args = [ "Main.o" ]; @@ -75,7 +74,7 @@ class EmscriptenPlatform extends PlatformTarget { } args = args.concat ([ "ApplicationMain" + (project.debug ? "-debug" : "") + ".a", "-o", "ApplicationMain.o" ]); - ProcessHelper.runCommand (outputDirectory + "/obj", "emcc", args, true, false, true); + ProcessHelper.runCommand (targetDirectory + "/obj", "emcc", args, true, false, true); args = [ "ApplicationMain.o", "-s", "FULL_ES2=1" ]; @@ -132,7 +131,7 @@ class EmscriptenPlatform extends PlatformTarget { //args.push ("--jcache"); //args.push ("-g"); - if (FileSystem.exists (outputDirectory + "/obj/assets")) { + if (FileSystem.exists (targetDirectory + "/obj/assets")) { args.push ("--preload-file"); args.push ("assets"); @@ -158,31 +157,31 @@ class EmscriptenPlatform extends PlatformTarget { //args.push ("../bin/index.html"); - ProcessHelper.runCommand (outputDirectory + "/obj", "emcc", args, true, false, true); + ProcessHelper.runCommand (targetDirectory + "/obj", "emcc", args, true, false, true); if (project.targetFlags.exists ("minify")) { - HTML5Helper.minify (project, outputDirectory + "/bin/" + project.app.file + ".js"); + HTML5Helper.minify (project, targetDirectory + "/bin/" + project.app.file + ".js"); } if (project.targetFlags.exists ("compress")) { - if (FileSystem.exists (outputDirectory + "/bin/" + project.app.file + ".data")) { + if (FileSystem.exists (targetDirectory + "/bin/" + project.app.file + ".data")) { - //var byteArray = ByteArray.readFile (outputDirectory + "/bin/" + project.app.file + ".data"); + //var byteArray = ByteArray.readFile (targetDirectory + "/bin/" + project.app.file + ".data"); //byteArray.compress (CompressionAlgorithm.GZIP); - //File.saveBytes (outputDirectory + "/bin/" + project.app.file + ".data.compress", byteArray); + //File.saveBytes (targetDirectory + "/bin/" + project.app.file + ".data.compress", byteArray); } - //var byteArray = ByteArray.readFile (outputDirectory + "/bin/" + project.app.file + ".js"); + //var byteArray = ByteArray.readFile (targetDirectory + "/bin/" + project.app.file + ".js"); //byteArray.compress (CompressionAlgorithm.GZIP); - //File.saveBytes (outputDirectory + "/bin/" + project.app.file + ".js.compress", byteArray); + //File.saveBytes (targetDirectory + "/bin/" + project.app.file + ".js.compress", byteArray); } else { - File.saveContent (outputDirectory + "/bin/.htaccess", "SetOutputFilter DEFLATE"); + File.saveContent (targetDirectory + "/bin/.htaccess", "SetOutputFilter DEFLATE"); } @@ -191,11 +190,9 @@ class EmscriptenPlatform extends PlatformTarget { public override function clean ():Void { - var targetPath = project.app.path + "/emscripten"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -219,7 +216,7 @@ class EmscriptenPlatform extends PlatformTarget { var hxml = PathHelper.findTemplate (project.templatePaths, "emscripten/hxml/" + type + ".hxml"); var context = project.templateContext; - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; var template = new Template (File.getContent (hxml)); @@ -237,7 +234,7 @@ class EmscriptenPlatform extends PlatformTarget { public override function run ():Void { - HTML5Helper.launch (project, project.app.path + "/emscripten/bin"); + HTML5Helper.launch (project, targetDirectory + "/bin"); } @@ -252,7 +249,7 @@ class EmscriptenPlatform extends PlatformTarget { } - var destination = outputDirectory + "/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); //for (asset in project.assets) { @@ -267,21 +264,21 @@ class EmscriptenPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/emscripten/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; context.WIN_FLASHBACKGROUND = StringTools.hex (project.window.background, 6); - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; - context.CPP_DIR = project.app.path + "/emscripten/obj"; + context.CPP_DIR = targetDirectory + "/obj"; context.USE_COMPRESSION = project.targetFlags.exists ("compress"); for (asset in project.assets) { - var path = PathHelper.combine (outputDirectory + "/obj/assets", asset.targetPath); + var path = PathHelper.combine (targetDirectory + "/obj/assets", asset.targetPath); if (asset.type != AssetType.TEMPLATE) { @@ -297,9 +294,9 @@ class EmscriptenPlatform extends PlatformTarget { } FileHelper.recursiveCopyTemplate (project.templatePaths, "emscripten/template", destination, context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "emscripten/hxml", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "emscripten/cpp", outputDirectory + "/obj", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "emscripten/hxml", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "emscripten/cpp", targetDirectory + "/obj", context); for (asset in project.assets) { @@ -314,7 +311,7 @@ class EmscriptenPlatform extends PlatformTarget { } - AssetHelper.createManifest (project, PathHelper.combine (outputDirectory + "/obj/assets", "manifest")); + AssetHelper.createManifest (project, PathHelper.combine (targetDirectory + "/obj/assets", "manifest")); } diff --git a/tools/platforms/FirefoxPlatform.hx b/tools/platforms/FirefoxPlatform.hx index 459e9c214..b1b33aad9 100644 --- a/tools/platforms/FirefoxPlatform.hx +++ b/tools/platforms/FirefoxPlatform.hx @@ -22,11 +22,9 @@ class FirefoxPlatform extends HTML5Platform { public override function clean ():Void { - var targetPath = project.app.path + "/firefox"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -35,8 +33,8 @@ class FirefoxPlatform extends HTML5Platform { private override function initialize (command:String, project:HXProject):Void { - outputDirectory = project.app.path + "/firefox"; - outputFile = outputDirectory + "/bin/" + project.app.file + ".js"; + targetDirectory = project.app.path + "/firefox"; + outputFile = targetDirectory + "/bin/" + project.app.file + ".js"; } @@ -52,7 +50,7 @@ class FirefoxPlatform extends HTML5Platform { super.update (); - var destination = outputDirectory + "/bin/"; + var destination = targetDirectory + "/bin/"; var context = project.templateContext; FileHelper.recursiveCopyTemplate (project.templatePaths, "firefoxos/hxml", destination, context, true, false); diff --git a/tools/platforms/FlashPlatform.hx b/tools/platforms/FlashPlatform.hx index 287b3856a..72b09c6be 100644 --- a/tools/platforms/FlashPlatform.hx +++ b/tools/platforms/FlashPlatform.hx @@ -29,12 +29,14 @@ class FlashPlatform extends PlatformTarget { super (command, _project, targetFlags); + targetDirectory = project.app.path + "/flash"; + } public override function build ():Void { - var destination = project.app.path + "/flash/bin"; + var destination = targetDirectory + "/bin"; var type = "release"; @@ -50,7 +52,7 @@ class FlashPlatform extends PlatformTarget { if (embedded) { - var hxml = File.getContent (project.app.path + "/flash/haxe/" + type + ".hxml"); + var hxml = File.getContent (targetDirectory + "/haxe/" + type + ".hxml"); var args = new Array (); for (line in ~/[\r\n]+/g.split (hxml)) { @@ -97,7 +99,7 @@ class FlashPlatform extends PlatformTarget { } else { - var hxml = project.app.path + "/flash/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; ProcessHelper.runCommand ("", "haxe", [ hxml ] ); } @@ -125,7 +127,7 @@ class FlashPlatform extends PlatformTarget { public override function clean ():Void { - var targetPath = project.app.path + "/flash"; + var targetPath = targetDirectory + ""; if (FileSystem.exists (targetPath)) { @@ -167,7 +169,7 @@ class FlashPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/flash/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } @@ -204,7 +206,7 @@ class FlashPlatform extends PlatformTarget { } else { - var destination = project.app.path + "/flash/bin"; + var destination = targetDirectory + "/bin"; var targetPath = project.app.file + ".swf"; if (project.targetFlags.exists ("web")) { @@ -222,18 +224,18 @@ class FlashPlatform extends PlatformTarget { public override function update ():Void { - var destination = project.app.path + "/flash/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); embedded = FlashHelper.embedAssets (project); var context = generateContext (); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", project.app.path + "/flash/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "flash/hxml", project.app.path + "/flash/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "flash/haxe", project.app.path + "/flash/haxe", context, true, false); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "flash/hxml", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "flash/haxe", targetDirectory + "/haxe", context, true, false); - //SWFHelper.generateSWFClasses (project, project.app.path + "/flash/haxe"); + //SWFHelper.generateSWFClasses (project, targetDirectory + "/haxe"); var usesNME = false; @@ -247,7 +249,7 @@ class FlashPlatform extends PlatformTarget { if (haxelib.name == "openfl") { - CompatibilityHelper.patchAssetLibrary (project, haxelib, project.app.path + "/flash/haxe/DefaultAssetLibrary.hx", context); + CompatibilityHelper.patchAssetLibrary (project, haxelib, targetDirectory + "/haxe/DefaultAssetLibrary.hx", context); } diff --git a/tools/platforms/HTML5Platform.hx b/tools/platforms/HTML5Platform.hx index 5d20e2c57..68bbfbb51 100644 --- a/tools/platforms/HTML5Platform.hx +++ b/tools/platforms/HTML5Platform.hx @@ -19,7 +19,6 @@ import sys.FileSystem; class HTML5Platform extends PlatformTarget { - private var outputDirectory:String; private var outputFile:String; @@ -48,20 +47,20 @@ class HTML5Platform extends PlatformTarget { } - var hxml = outputDirectory + "/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; ProcessHelper.runCommand ("", "haxe", [ hxml ] ); } if (project.targetFlags.exists ("webgl")) { - FileHelper.copyFile (outputDirectory + "/obj/ApplicationMain.js", outputFile); + FileHelper.copyFile (targetDirectory + "/obj/ApplicationMain.js", outputFile); } if (project.targetFlags.exists ("minify")) { - HTML5Helper.minify (project, outputDirectory + "/bin/" + project.app.file + ".js"); + HTML5Helper.minify (project, targetDirectory + "/bin/" + project.app.file + ".js"); } @@ -70,11 +69,9 @@ class HTML5Platform extends PlatformTarget { public override function clean ():Void { - var targetPath = project.app.path + "/html5"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -98,7 +95,7 @@ class HTML5Platform extends PlatformTarget { var hxml = PathHelper.findTemplate (project.templatePaths, "html5/hxml/" + type + ".hxml"); var context = project.templateContext; - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; var template = new Template (File.getContent (hxml)); @@ -109,15 +106,15 @@ class HTML5Platform extends PlatformTarget { private function initialize (command:String, project:HXProject):Void { - outputDirectory = project.app.path + "/html5"; - outputFile = outputDirectory + "/bin/" + project.app.file + ".js"; + targetDirectory = project.app.path + "/html5"; + outputFile = targetDirectory + "/bin/" + project.app.file + ".js"; } public override function run ():Void { - HTML5Helper.launch (project, project.app.path + "/html5/bin"); + HTML5Helper.launch (project, targetDirectory + "/bin"); } @@ -126,7 +123,7 @@ class HTML5Platform extends PlatformTarget { project = project.clone (); - var destination = outputDirectory + "/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); var useWebfonts = true; @@ -162,19 +159,19 @@ class HTML5Platform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/html5/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; context.WIN_FLASHBACKGROUND = StringTools.hex (project.window.background, 6); - context.OUTPUT_DIR = outputDirectory; + context.OUTPUT_DIR = targetDirectory; context.OUTPUT_FILE = outputFile; if (project.targetFlags.exists ("webgl")) { - context.CPP_DIR = project.app.path + "/html5/obj"; + context.CPP_DIR = targetDirectory + "/obj"; } @@ -238,13 +235,13 @@ class HTML5Platform extends PlatformTarget { if (project.app.main != null) { - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", outputDirectory + "/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/haxe", outputDirectory + "/haxe", context, true, false); - FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/hxml", outputDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/haxe", targetDirectory + "/haxe", context, true, false); + FileHelper.recursiveCopyTemplate (project.templatePaths, "html5/hxml", targetDirectory + "/haxe", context); if (project.targetFlags.exists ("webgl")) { - FileHelper.recursiveCopyTemplate (project.templatePaths, "webgl/hxml", outputDirectory + "/haxe", context, true, false); + FileHelper.recursiveCopyTemplate (project.templatePaths, "webgl/hxml", targetDirectory + "/haxe", context, true, false); } diff --git a/tools/platforms/IOSPlatform.hx b/tools/platforms/IOSPlatform.hx index b9a764a09..412735753 100644 --- a/tools/platforms/IOSPlatform.hx +++ b/tools/platforms/IOSPlatform.hx @@ -36,14 +36,14 @@ class IOSPlatform extends PlatformTarget { super (command, _project, targetFlags); + targetDirectory = PathHelper.combine (project.app.path, "ios"); + } public override function build ():Void { - var targetDirectory = PathHelper.combine (project.app.path, "ios"); - - IOSHelper.build (project, project.app.path + "/ios"); + IOSHelper.build (project, targetDirectory); if (!project.targetFlags.exists ("simulator")) { @@ -57,11 +57,9 @@ class IOSPlatform extends PlatformTarget { public override function clean ():Void { - var targetPath = project.app.path + "/ios"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -82,7 +80,7 @@ class IOSPlatform extends PlatformTarget { project = project.clone (); project.sources.unshift (""); - project.sources = PathHelper.relocatePaths (project.sources, PathHelper.combine (project.app.path, "ios/" + project.app.file + "/haxe")); + project.sources = PathHelper.relocatePaths (project.sources, PathHelper.combine (targetDirectory, project.app.file + "/haxe")); //project.dependencies.push ("stdc++"); if (project.certificate == null || project.certificate.identity == null) { @@ -94,7 +92,7 @@ class IOSPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/ios/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } @@ -312,7 +310,7 @@ class IOSPlatform extends PlatformTarget { public override function run ():Void { - IOSHelper.launch (project, PathHelper.combine (project.app.path, "ios")); + IOSHelper.launch (project, targetDirectory); } @@ -330,7 +328,6 @@ class IOSPlatform extends PlatformTarget { var context = generateContext (); - var targetDirectory = PathHelper.combine (project.app.path, "ios"); var projectDirectory = targetDirectory + "/" + project.app.file + "/"; PathHelper.mkdir (targetDirectory); diff --git a/tools/platforms/LinuxPlatform.hx b/tools/platforms/LinuxPlatform.hx index 71dde3e45..65e843f9d 100644 --- a/tools/platforms/LinuxPlatform.hx +++ b/tools/platforms/LinuxPlatform.hx @@ -28,7 +28,6 @@ class LinuxPlatform extends PlatformTarget { private var executablePath:String; private var is64:Bool; private var isRaspberryPi:Bool; - private var targetDirectory:String; private var targetType:String; diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index 981e24968..2c37f80c8 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -31,7 +31,6 @@ class MacPlatform extends PlatformTarget { private var executableDirectory:String; private var executablePath:String; private var is64:Bool; - private var targetDirectory:String; private var targetType:String; diff --git a/tools/platforms/TizenPlatform.hx b/tools/platforms/TizenPlatform.hx index d76e2e9ae..8b39d23e1 100644 --- a/tools/platforms/TizenPlatform.hx +++ b/tools/platforms/TizenPlatform.hx @@ -27,12 +27,14 @@ class TizenPlatform extends PlatformTarget { super (command, _project, targetFlags); + targetDirectory = project.app.path + "/tizen"; + } public override function build ():Void { - var destination = project.app.path + "/tizen/bin/"; + var destination = targetDirectory + "/bin/"; var arch = ""; @@ -60,7 +62,7 @@ class TizenPlatform extends PlatformTarget { } - var hxml = project.app.path + "/tizen/haxe/" + type + ".hxml"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; ProcessHelper.runCommand ("", "haxe", [ hxml, "-D", "tizen" ] ); @@ -72,20 +74,18 @@ class TizenPlatform extends PlatformTarget { } - CPPHelper.compile (project, project.app.path + "/tizen/obj", args); - FileHelper.copyIfNewer (project.app.path + "/tizen/obj/ApplicationMain" + (project.debug ? "-debug" : "") + ".exe", project.app.path + "/tizen/bin/CommandLineBuild/" + project.app.file + ".exe"); - TizenHelper.createPackage (project, project.app.path + "/tizen/bin/CommandLineBuild", ""); + CPPHelper.compile (project, targetDirectory + "/obj", args); + FileHelper.copyIfNewer (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : "") + ".exe", targetDirectory + "/bin/CommandLineBuild/" + project.app.file + ".exe"); + TizenHelper.createPackage (project, targetDirectory + "/bin/CommandLineBuild", ""); } public override function clean ():Void { - var targetPath = project.app.path + "/tizen"; - - if (FileSystem.exists (targetPath)) { + if (FileSystem.exists (targetDirectory)) { - PathHelper.removeDirectory (targetPath); + PathHelper.removeDirectory (targetDirectory); } @@ -109,7 +109,7 @@ class TizenPlatform extends PlatformTarget { var hxml = PathHelper.findTemplate (project.templatePaths, "tizen/hxml/" + type + ".hxml"); var context = project.templateContext; - context.CPP_DIR = project.app.path + "/tizen/obj"; + context.CPP_DIR = targetDirectory + "/obj"; var template = new Template (File.getContent (hxml)); Sys.println (template.execute (context)); @@ -134,7 +134,7 @@ class TizenPlatform extends PlatformTarget { public override function run ():Void { - TizenHelper.install (project, project.app.path + "/tizen/bin/CommandLineBuild"); + TizenHelper.install (project, targetDirectory + "/bin/CommandLineBuild"); TizenHelper.launch (project); } @@ -150,7 +150,7 @@ class TizenPlatform extends PlatformTarget { public override function update ():Void { project = project.clone (); - var destination = project.app.path + "/tizen/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); for (asset in project.assets) { @@ -161,12 +161,12 @@ class TizenPlatform extends PlatformTarget { if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/tizen/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; - context.CPP_DIR = project.app.path + "/tizen/obj"; + context.CPP_DIR = targetDirectory + "/obj"; context.APP_PACKAGE = TizenHelper.getUUID (project); context.SIMULATOR = project.targetFlags.exists ("simulator"); @@ -179,10 +179,8 @@ class TizenPlatform extends PlatformTarget { } FileHelper.recursiveCopyTemplate (project.templatePaths, "tizen/template", destination, context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", project.app.path + "/tizen/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "tizen/hxml", project.app.path + "/tizen/haxe", context); - - //SWFHelper.generateSWFClasses (project, project.app.path + "/tizen/haxe"); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "tizen/hxml", targetDirectory + "/haxe", context); for (asset in project.assets) { diff --git a/tools/platforms/WebOSPlatform.hx b/tools/platforms/WebOSPlatform.hx index c3a0ac331..b71dd96a9 100644 --- a/tools/platforms/WebOSPlatform.hx +++ b/tools/platforms/WebOSPlatform.hx @@ -24,6 +24,8 @@ class WebOSPlatform extends PlatformTarget { super (command, _project, targetFlags); + targetDirectory = project.app.path + "/webos"; + } @@ -41,8 +43,8 @@ class WebOSPlatform extends PlatformTarget { } - var hxml = project.app.path + "/webos/haxe/" + type + ".hxml"; - var destination = project.app.path + "/webos/bin/"; + var hxml = targetDirectory + "/haxe/" + type + ".hxml"; + var destination = targetDirectory + "/bin/"; for (ndll in project.ndlls) { @@ -51,18 +53,18 @@ class WebOSPlatform extends PlatformTarget { } ProcessHelper.runCommand ("", "haxe", [ hxml, "-D", "webos", "-D", "HXCPP_LOAD_DEBUG", "-D", "HXCPP_RTLD_LAZY" ] ); - CPPHelper.compile (project, project.app.path + "/webos/obj", [ "-Dwebos", "-DHXCPP_LOAD_DEBUG", "-DHXCPP_RTLD_LAZY" ]); + CPPHelper.compile (project, targetDirectory + "/obj", [ "-Dwebos", "-DHXCPP_LOAD_DEBUG", "-DHXCPP_RTLD_LAZY" ]); - FileHelper.copyIfNewer (project.app.path + "/webos/obj/ApplicationMain" + (project.debug ? "-debug" : ""), project.app.path + "/webos/bin/" + project.app.file); + FileHelper.copyIfNewer (targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-debug" : ""), targetDirectory + "/bin/" + project.app.file); - WebOSHelper.createPackage (project, project.app.path + "/webos", "bin"); + WebOSHelper.createPackage (project, targetDirectory + "", "bin"); } public override function clean ():Void { - var targetPath = project.app.path + "/webos"; + var targetPath = targetDirectory + ""; if (FileSystem.exists (targetPath)) { @@ -90,7 +92,7 @@ class WebOSPlatform extends PlatformTarget { var hxml = PathHelper.findTemplate (project.templatePaths, "webos/hxml/" + type + ".hxml"); var context = project.templateContext; - context.CPP_DIR = project.app.path + "/webos/obj"; + context.CPP_DIR = targetDirectory + "/obj"; var template = new Template (File.getContent (hxml)); Sys.println (template.execute (context)); @@ -100,7 +102,7 @@ class WebOSPlatform extends PlatformTarget { public override function install ():Void { - WebOSHelper.install (project, project.app.path + "/webos"); + WebOSHelper.install (project, targetDirectory + ""); } @@ -129,17 +131,17 @@ class WebOSPlatform extends PlatformTarget { public override function update ():Void { project = project.clone (); - var destination = project.app.path + "/webos/bin/"; + var destination = targetDirectory + "/bin/"; PathHelper.mkdir (destination); if (project.targetFlags.exists ("xml")) { - project.haxeflags.push ("-xml " + project.app.path + "/webos/types.xml"); + project.haxeflags.push ("-xml " + targetDirectory + "/types.xml"); } var context = project.templateContext; - context.CPP_DIR = project.app.path + "/webos/obj"; + context.CPP_DIR = targetDirectory + "/obj"; if (IconHelper.createIcon (project.icons, 64, 64, PathHelper.combine (destination, "icon.png"))) { @@ -148,10 +150,10 @@ class WebOSPlatform extends PlatformTarget { } FileHelper.recursiveCopyTemplate (project.templatePaths, "webos/template", destination, context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", project.app.path + "/webos/haxe", context); - FileHelper.recursiveCopyTemplate (project.templatePaths, "webos/hxml", project.app.path + "/webos/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "haxe", targetDirectory + "/haxe", context); + FileHelper.recursiveCopyTemplate (project.templatePaths, "webos/hxml", targetDirectory + "/haxe", context); - //SWFHelper.generateSWFClasses (project, project.app.path + "/webos/haxe"); + //SWFHelper.generateSWFClasses (project, targetDirectory + "/haxe"); for (asset in project.assets) { diff --git a/tools/platforms/WindowsPlatform.hx b/tools/platforms/WindowsPlatform.hx index 5974955dd..115c2f329 100644 --- a/tools/platforms/WindowsPlatform.hx +++ b/tools/platforms/WindowsPlatform.hx @@ -25,7 +25,6 @@ class WindowsPlatform extends PlatformTarget { private var applicationDirectory:String; private var executablePath:String; - private var targetDirectory:String; private var targetType:String; diff --git a/tools/project/PlatformTarget.hx b/tools/project/PlatformTarget.hx index 42c379535..3acd3b56b 100644 --- a/tools/project/PlatformTarget.hx +++ b/tools/project/PlatformTarget.hx @@ -12,6 +12,7 @@ class PlatformTarget { public var additionalArguments:Array ; public var command:String; public var project:HXProject; + public var targetDirectory:String; public var targetFlags:Map ; public var traceEnabled = true; @@ -65,7 +66,7 @@ class PlatformTarget { if (!Reflect.hasField (metaFields.update, "ignore") && (command == "update" || command == "build" || command == "test")) { LogHelper.info ("", "\n" + LogHelper.accentColor + "Running command: UPDATE" + LogHelper.resetColor); - AssetHelper.processLibraries (project); + AssetHelper.processLibraries (project, targetDirectory); update (); }