From c9605ee784f26d0f5df050dc9d557a5972cf223f Mon Sep 17 00:00:00 2001 From: Josh Tynjala Date: Thu, 8 Feb 2024 14:29:04 -0800 Subject: [PATCH] PlatformSetup: in verbose mode, failure to install lime alias logs a warning On Windows, if HAXEPATH is not set, but it probably should be, and installing the alias fails, logs a warning suggesting to set HAXEPATH --- tools/utils/PlatformSetup.hx | 60 +++++++++++++++++++++++++++++------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/tools/utils/PlatformSetup.hx b/tools/utils/PlatformSetup.hx index 071e7ae22..ae684e357 100644 --- a/tools/utils/PlatformSetup.hx +++ b/tools/utils/PlatformSetup.hx @@ -816,25 +816,49 @@ class PlatformSetup setupHaxelib(new Haxelib("lime")); } - var haxePath = Sys.getEnv("HAXEPATH"); + var haxePathEnv = Sys.getEnv("HAXEPATH"); + var haxePath = haxePathEnv; if (System.hostPlatform == WINDOWS) { + var usingDefaultHaxePath = false; if (haxePath == null || haxePath == "") { + usingDefaultHaxePath = true; haxePath = "C:\\HaxeToolkit\\haxe\\"; } + var copyFailure = false; + var exeDestPath = haxePath + "\\lime.exe"; try { - File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe"); + File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", exeDestPath); } - catch (e:Dynamic) {} + catch (e:Dynamic) + { + copyFailure = true; + if (Log.verbose) + { + Log.warn("Failed to copy lime.exe alias to destination: " + exeDestPath); + } + } + var shDestPath = haxePath + "\\lime"; try { - File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime"); + File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", shDestPath); + } + catch (e:Dynamic) + { + copyFailure = true; + if (Log.verbose) + { + Log.warn("Failed to copy lime.sh alias to destination: " + shDestPath); + } + } + if (Log.verbose && copyFailure && usingDefaultHaxePath && !FileSystem.exists(haxePath)) + { + Log.warn("Did you install Haxe to a custom location? Set the HAXEPATH environment variable, and run Lime setup again."); } - catch (e:Dynamic) {} } else { @@ -859,32 +883,46 @@ class PlatformSetup { if (System.hostPlatform == MAC) { + var aliasDestPath = "/usr/local/bin/lime"; try { System.runCommand("", "cp", [ "-f", Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh", - "/usr/local/bin/lime" + aliasDestPath ], false); - System.runCommand("", "chmod", ["755", "/usr/local/bin/lime"], false); + System.runCommand("", "chmod", ["755", aliasDestPath], false); installedCommand = true; } - catch (e:Dynamic) {} + catch (e:Dynamic) + { + if (Log.verbose) + { + Log.warn("Failed to copy Lime alias to destination: " + aliasDestPath); + } + } } else { + var aliasDestPath = "/usr/local/bin/lime"; try { System.runCommand("", "sudo", [ "cp", "-f", Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh", - "/usr/local/bin/lime" + aliasDestPath ], false); - System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/lime"], false); + System.runCommand("", "sudo", ["chmod", "755", aliasDestPath], false); installedCommand = true; } - catch (e:Dynamic) {} + catch (e:Dynamic) + { + if (Log.verbose) + { + Log.warn("Failed to copy Lime alias to destination: " + aliasDestPath); + } + } } }