From 7b6dd93ddff838bbaccc2f3af06486502d20b957 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Mon, 17 Oct 2016 15:22:08 -0700 Subject: [PATCH] Move to Lime config (instead of HXCPP config) --- tools/CommandLineTools.hx | 58 ++++++++++++++--- tools/utils/JavaExternGenerator.hx | 2 +- tools/utils/PlatformSetup.hx | 79 +++++++++++++---------- tools/utils/publish/FirefoxMarketplace.hx | 2 +- 4 files changed, 96 insertions(+), 45 deletions(-) diff --git a/tools/CommandLineTools.hx b/tools/CommandLineTools.hx index 2d6b013d8..1baf0b161 100644 --- a/tools/CommandLineTools.hx +++ b/tools/CommandLineTools.hx @@ -984,7 +984,7 @@ class CommandLineTools { } else if (targetFlags.exists ("java-externs")) { - var config = getHXCPPConfig (); + var config = getLimeConfig (); var sourcePath = words[0]; var targetPath = words[1]; @@ -1074,14 +1074,14 @@ class CommandLineTools { } - public static function getHXCPPConfig ():HXProject { + public static function getLimeConfig ():HXProject { var environment = Sys.environment (); var config = ""; - if (environment.exists ("HXCPP_CONFIG")) { + if (environment.exists ("LIME_CONFIG")) { - config = environment.get ("HXCPP_CONFIG"); + config = environment.get ("LIME_CONFIG"); } else { @@ -1097,13 +1097,13 @@ class CommandLineTools { } else { - LogHelper.warn ("HXCPP config might be missing (Environment has no \"HOME\" variable)"); + LogHelper.warn ("Lime config might be missing (Environment has no \"HOME\" variable)"); return null; } - config = home + "/.hxcpp_config.xml"; + config = home + "/.lime/config.xml"; if (PlatformHelper.hostPlatform == Platform.WINDOWS) { @@ -1111,17 +1111,57 @@ class CommandLineTools { } + if (!FileSystem.exists (config)) { + + PathHelper.mkdir (Path.directory (config)); + + var hxcppConfig = null; + + if (environment.exists ("HXCPP_CONFIG")) { + + hxcppConfig = environment.get ("HXCPP_CONFIG"); + + } else { + + hxcppConfig = home + "/.hxcpp_config.xml"; + + } + + if (FileSystem.exists (hxcppConfig)) { + + var vars = new ProjectXMLParser (hxcppConfig); + + for (key in vars.defines.keys ()) { + + if (key != key.toUpperCase ()) { + + vars.defines.remove (key); + + } + + } + + PlatformSetup.writeConfig (config, vars.defines); + + } else { + + PlatformSetup.writeConfig (config, new Map ()); + + } + + } + } if (FileSystem.exists (config)) { - LogHelper.info ("", LogHelper.accentColor + "Reading HXCPP config: " + config + LogHelper.resetColor); + LogHelper.info ("", LogHelper.accentColor + "Reading Lime config: " + config + LogHelper.resetColor); return new ProjectXMLParser (config); } else { - LogHelper.warn ("", "Could not read HXCPP config: " + config); + LogHelper.warn ("", "Could not read Lime config: " + config); } @@ -1253,7 +1293,7 @@ class CommandLineTools { } - var config = getHXCPPConfig (); + var config = getLimeConfig (); if (config != null) { diff --git a/tools/utils/JavaExternGenerator.hx b/tools/utils/JavaExternGenerator.hx index 54c039525..484090ab6 100644 --- a/tools/utils/JavaExternGenerator.hx +++ b/tools/utils/JavaExternGenerator.hx @@ -154,7 +154,7 @@ class JavaExternGenerator } else { - throw "Could not find Android SDK directory. Check that ANDROID_SDK is defined in .hxcpp_config.xml"; + throw "Could not find Android SDK directory. Check that ANDROID_SDK is defined in ~/.lime/config.xml"; } } diff --git a/tools/utils/PlatformSetup.hx b/tools/utils/PlatformSetup.hx index 9e950d8b8..c48a891c3 100644 --- a/tools/utils/PlatformSetup.hx +++ b/tools/utils/PlatformSetup.hx @@ -255,7 +255,7 @@ class PlatformSetup { public static function getDefines (names:Array = null, descriptions:Array = null, ignored:Array = null):Map { - var config = CommandLineTools.getHXCPPConfig (); + var config = CommandLineTools.getLimeConfig (); var defines = null; var env = Sys.environment (); @@ -281,7 +281,7 @@ class PlatformSetup { } - if (!defines.exists ("HXCPP_CONFIG")) { + if (!defines.exists ("LIME_CONFIG")) { var home = ""; @@ -295,13 +295,13 @@ class PlatformSetup { } else { - LogHelper.println ("Warning : No 'HOME' variable set - .hxcpp_config.xml might be missing."); + LogHelper.println ("Warning : No 'HOME' variable set - ~/.lime/config.xml might be missing."); return null; } - defines.set ("HXCPP_CONFIG", home + "/.hxcpp_config.xml"); + defines.set ("LIME_CONFIG", home + "/.lime/config.xml"); } @@ -687,7 +687,7 @@ class PlatformSetup { setAIRSDK = true; defines.set ("AIR_SDK", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println (""); } @@ -712,7 +712,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -790,7 +790,7 @@ class PlatformSetup { setAndroidSDK = true; defines.set ("ANDROID_SDK", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println (""); } @@ -837,7 +837,7 @@ class PlatformSetup { setAndroidNDK = true; defines.set ("ANDROID_NDK_ROOT", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println (""); } @@ -917,7 +917,7 @@ class PlatformSetup { } - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -961,7 +961,7 @@ class PlatformSetup { setAndroidNDK = true; defines.set ("ANDROID_NDK_ROOT", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println ("");*/ } @@ -970,7 +970,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1019,7 +1019,7 @@ class PlatformSetup { setAndroidNDK = true; defines.set ("ANDROID_NDK_ROOT", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println ("");*/ } @@ -1028,7 +1028,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1239,7 +1239,7 @@ class PlatformSetup { var deviceIDs = []; var defines = getDefines (); - var config = CommandLineTools.getHXCPPConfig (); + var config = CommandLineTools.getLimeConfig (); BlackBerryHelper.initialize (config); var token = BlackBerryHelper.processDebugToken (config); @@ -1311,7 +1311,7 @@ class PlatformSetup { var defines = getDefines (); defines.set ("BLACKBERRY_DEBUG_TOKEN", debugTokenPath); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1337,7 +1337,7 @@ class PlatformSetup { if (defines != null) { defines.set ("BLACKBERRY_SETUP", "true"); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1391,7 +1391,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1399,7 +1399,7 @@ class PlatformSetup { var defines = getDefines (); defines.set ("BLACKBERRY_SETUP", "true"); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1425,7 +1425,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1571,7 +1571,7 @@ class PlatformSetup { setApacheCordova = true; defines.set ("CORDOVA_PATH", path); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println (""); } @@ -1602,7 +1602,7 @@ class PlatformSetup { ProcessHelper.runCommand (defines.get ("CORDOVA_PATH") + "/lib/ios", "make", [ "install" ], true, true); Sys.println ("Done.");*/ - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); ProcessHelper.runCommand ("", "haxelib", [ "install", "cordova" ], true, true); @@ -1679,7 +1679,7 @@ class PlatformSetup { var defines = getDefines (); defines.set ("MAC_USE_CURRENT_SDK", "1"); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1879,7 +1879,7 @@ class PlatformSetup { var defines = getDefines (); defines.set ("MAC_USE_CURRENT_SDK", "1"); - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -1907,7 +1907,7 @@ class PlatformSetup { if (defines != null) { - writeConfig (defines.get ("HXCPP_CONFIG"), defines); + writeConfig (defines.get ("LIME_CONFIG"), defines); } @@ -2119,7 +2119,7 @@ class PlatformSetup { } - public static function writeConfig (path:String, defines:Map ):Void { + public static function writeConfig (path:String, defines:Map ):Void { var newContent = ""; var definesText = ""; @@ -2127,9 +2127,9 @@ class PlatformSetup { for (key in defines.keys ()) { - if (key != "HXCPP_CONFIG" && (!env.exists (key) || env.get (key) != defines.get (key))) { + if (key != "LIME_CONFIG" && key != "LIME_CONFIG" && (!env.exists (key) || env.get (key) != defines.get (key))) { - definesText += " \n"; + definesText += "\t\t\n"; } @@ -2152,7 +2152,7 @@ class PlatformSetup { } catch (e:Dynamic) { } backedUpConfig = true; - + } #if (haxe_ver > 3.102) @@ -2161,19 +2161,20 @@ class PlatformSetup { var content = bytes.readString (0, bytes.length); #end - var startIndex = content.indexOf ("
"); + var startIndex = content.indexOf ("
"); var endIndex = content.indexOf ("
", startIndex); - newContent += content.substr (0, startIndex) + "
\n \n"; + newContent += content.substr (0, startIndex) + "
\n\t\t\n"; newContent += definesText; - newContent += " \n " + content.substr (endIndex); + newContent += "\t\t\n\t" + content.substr (endIndex); } else { - newContent += "\n\n"; - newContent += "
\n\n"; + newContent += "\n"; + newContent += "\n\t\n"; + newContent += "\t
\n\t\t\n"; newContent += definesText; - newContent += "
\n\n"; + newContent += "\t\t\n\t
\n\t\n"; } @@ -2181,6 +2182,16 @@ class PlatformSetup { output.writeString (newContent); output.close (); + if (backedUpConfig) { + + try { + + FileSystem.deleteFile (path + ".bak"); + + } catch (e:Dynamic) {} + + } + } diff --git a/tools/utils/publish/FirefoxMarketplace.hx b/tools/utils/publish/FirefoxMarketplace.hx index c65b5b9cc..6d42490e4 100644 --- a/tools/utils/publish/FirefoxMarketplace.hx +++ b/tools/utils/publish/FirefoxMarketplace.hx @@ -473,7 +473,7 @@ class FirefoxMarketplace { defines.set ("FIREFOX_MARKETPLACE" + (devServer ? "_DEV_" : "_") + "KEY", key); defines.set ("FIREFOX_MARKETPLACE" + (devServer ? "_DEV_" : "_") + "SECRET", secret); - PlatformSetup.writeConfig (defines.get ("HXCPP_CONFIG"), defines); + PlatformSetup.writeConfig (defines.get ("LIME_CONFIG"), defines); LogHelper.println (""); }