PlatformSetup: added optional -noalias target flag to skip creating the lime/openfl alias during setup

This commit is contained in:
Josh Tynjala
2023-12-08 09:34:18 -08:00
parent 21e8e619c3
commit aec341d481

View File

@@ -816,89 +816,92 @@ class PlatformSetup
setupHaxelib(new Haxelib("lime")); setupHaxelib(new Haxelib("lime"));
} }
var haxePath = Sys.getEnv("HAXEPATH"); if (!targetFlags.exists("noalias"))
if (System.hostPlatform == WINDOWS)
{ {
if (haxePath == null || haxePath == "") var haxePath = Sys.getEnv("HAXEPATH");
{
haxePath = "C:\\HaxeToolkit\\haxe\\";
}
try if (System.hostPlatform == WINDOWS)
{ {
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe"); if (haxePath == null || haxePath == "")
} {
catch (e:Dynamic) {} haxePath = "C:\\HaxeToolkit\\haxe\\";
try }
{
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime");
}
catch (e:Dynamic) {}
}
else
{
if (haxePath == null || haxePath == "")
{
haxePath = "/usr/lib/haxe";
}
var installedCommand = false; try
var answer = YES; {
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe");
if (targetFlags.exists("y")) }
{ catch (e:Dynamic) {}
Sys.println("Do you want to install the \"lime\" command? [y/n/a] y"); try
{
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime");
}
catch (e:Dynamic) {}
} }
else else
{ {
answer = CLIHelper.ask("Do you want to install the \"lime\" command?"); if (haxePath == null || haxePath == "")
}
if (answer == YES || answer == ALWAYS)
{
if (System.hostPlatform == MAC)
{ {
try haxePath = "/usr/lib/haxe";
{ }
System.runCommand("", "cp", [
"-f", var installedCommand = false;
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh", var answer = YES;
"/usr/local/bin/lime"
], false); if (targetFlags.exists("y"))
System.runCommand("", "chmod", ["755", "/usr/local/bin/lime"], false); {
installedCommand = true; Sys.println("Do you want to install the \"lime\" command? [y/n/a] y");
}
catch (e:Dynamic) {}
} }
else else
{ {
try answer = CLIHelper.ask("Do you want to install the \"lime\" command?");
{
System.runCommand("", "sudo", [
"cp",
"-f",
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
"/usr/local/bin/lime"
], false);
System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/lime"], false);
installedCommand = true;
}
catch (e:Dynamic) {}
} }
}
if (!installedCommand) if (answer == YES || answer == ALWAYS)
{ {
Sys.println(""); if (System.hostPlatform == MAC)
Sys.println("To finish setup, we recommend you either..."); {
Sys.println(""); try
Sys.println(" a) Manually add an alias called \"lime\" to run \"haxelib run lime\""); {
Sys.println(" b) Run the following commands:"); System.runCommand("", "cp", [
Sys.println(""); "-f",
Sys.println("sudo cp \"" + Path.combine(Haxelib.getPath(new Haxelib("lime")), "templates/bin/lime.sh") + "\" /usr/local/bin/lime"); Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
Sys.println("sudo chmod 755 /usr/local/bin/lime"); "/usr/local/bin/lime"
Sys.println(""); ], false);
System.runCommand("", "chmod", ["755", "/usr/local/bin/lime"], false);
installedCommand = true;
}
catch (e:Dynamic) {}
}
else
{
try
{
System.runCommand("", "sudo", [
"cp",
"-f",
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
"/usr/local/bin/lime"
], false);
System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/lime"], false);
installedCommand = true;
}
catch (e:Dynamic) {}
}
}
if (!installedCommand)
{
Sys.println("");
Sys.println("To finish setup, we recommend you either...");
Sys.println("");
Sys.println(" a) Manually add an alias called \"lime\" to run \"haxelib run lime\"");
Sys.println(" b) Run the following commands:");
Sys.println("");
Sys.println("sudo cp \"" + Path.combine(Haxelib.getPath(new Haxelib("lime")), "templates/bin/lime.sh") + "\" /usr/local/bin/lime");
Sys.println("sudo chmod 755 /usr/local/bin/lime");
Sys.println("");
}
} }
} }
@@ -1036,114 +1039,117 @@ class PlatformSetup
setupHaxelib(new Haxelib("openfl")); setupHaxelib(new Haxelib("openfl"));
} }
var haxePath = Sys.getEnv("HAXEPATH"); if (!targetFlags.exists("noalias"))
var project = null;
try
{ {
project = HXProject.fromHaxelib(new Haxelib("openfl")); var haxePath = Sys.getEnv("HAXEPATH");
} var project = null;
catch (e:Dynamic) {}
if (System.hostPlatform == WINDOWS)
{
if (haxePath == null || haxePath == "")
{
haxePath = "C:\\HaxeToolkit\\haxe\\";
}
try try
{ {
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe"); project = HXProject.fromHaxelib(new Haxelib("openfl"));
}
catch (e:Dynamic) {}
try
{
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime");
} }
catch (e:Dynamic) {} catch (e:Dynamic) {}
try if (System.hostPlatform == WINDOWS)
{ {
System.copyFileTemplate(project.templatePaths, "bin/openfl.exe", haxePath + "\\openfl.exe"); if (haxePath == null || haxePath == "")
System.copyFileTemplate(project.templatePaths, "bin/openfl.sh", haxePath + "\\openfl"); {
} haxePath = "C:\\HaxeToolkit\\haxe\\";
catch (e:Dynamic) {} }
}
else
{
if (haxePath == null || haxePath == "")
{
haxePath = "/usr/lib/haxe";
}
var installedCommand = false; try
var answer = YES; {
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.exe", haxePath + "\\lime.exe");
}
catch (e:Dynamic) {}
try
{
File.copy(Haxelib.getPath(new Haxelib("lime")) + "\\templates\\\\bin\\lime.sh", haxePath + "\\lime");
}
catch (e:Dynamic) {}
if (targetFlags.exists("y")) try
{ {
Sys.println("Do you want to install the \"openfl\" command? [y/n/a] y"); System.copyFileTemplate(project.templatePaths, "bin/openfl.exe", haxePath + "\\openfl.exe");
System.copyFileTemplate(project.templatePaths, "bin/openfl.sh", haxePath + "\\openfl");
}
catch (e:Dynamic) {}
} }
else else
{ {
answer = CLIHelper.ask("Do you want to install the \"openfl\" command?"); if (haxePath == null || haxePath == "")
}
if (answer == YES || answer == ALWAYS)
{
if (System.hostPlatform == MAC)
{ {
try haxePath = "/usr/lib/haxe";
}
var installedCommand = false;
var answer = YES;
if (targetFlags.exists("y"))
{
Sys.println("Do you want to install the \"openfl\" command? [y/n/a] y");
}
else
{
answer = CLIHelper.ask("Do you want to install the \"openfl\" command?");
}
if (answer == YES || answer == ALWAYS)
{
if (System.hostPlatform == MAC)
{ {
System.runCommand("", "cp", [ try
{
System.runCommand("", "cp", [
"-f",
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
"/usr/local/bin/lime"
], false);
System.runCommand("", "chmod", ["755", "/usr/local/bin/lime"], false);
System.runCommand("", "cp", [
"-f",
System.findTemplate(project.templatePaths, "bin/openfl.sh"),
"/usr/local/bin/openfl"
], false);
System.runCommand("", "chmod", ["755", "/usr/local/bin/openfl"], false);
installedCommand = true;
}
catch (e:Dynamic) {}
}
else
{
System.runCommand("", "sudo", [
"cp",
"-f", "-f",
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh", Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
"/usr/local/bin/lime" "/usr/local/bin/lime"
], false); ], false);
System.runCommand("", "chmod", ["755", "/usr/local/bin/lime"], false); System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/lime"], false);
System.runCommand("", "cp", [ System.runCommand("", "sudo", [
"cp",
"-f", "-f",
System.findTemplate(project.templatePaths, "bin/openfl.sh"), System.findTemplate(project.templatePaths, "bin/openfl.sh"),
"/usr/local/bin/openfl" "/usr/local/bin/openfl"
], false); ], false);
System.runCommand("", "chmod", ["755", "/usr/local/bin/openfl"], false); System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/openfl"], false);
installedCommand = true; installedCommand = true;
} }
catch (e:Dynamic) {}
} }
else
{
System.runCommand("", "sudo", [
"cp",
"-f",
Haxelib.getPath(new Haxelib("lime")) + "/templates/bin/lime.sh",
"/usr/local/bin/lime"
], false);
System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/lime"], false);
System.runCommand("", "sudo", [
"cp",
"-f",
System.findTemplate(project.templatePaths, "bin/openfl.sh"),
"/usr/local/bin/openfl"
], false);
System.runCommand("", "sudo", ["chmod", "755", "/usr/local/bin/openfl"], false);
installedCommand = true;
}
}
if (!installedCommand) if (!installedCommand)
{ {
Sys.println(""); Sys.println("");
Sys.println("To finish setup, we recommend you either..."); Sys.println("To finish setup, we recommend you either...");
Sys.println(""); Sys.println("");
Sys.println(" a) Manually add an alias called \"openfl\" to run \"haxelib run openfl\""); Sys.println(" a) Manually add an alias called \"openfl\" to run \"haxelib run openfl\"");
Sys.println(" b) Run the following commands:"); Sys.println(" b) Run the following commands:");
Sys.println(""); Sys.println("");
Sys.println("sudo cp \"" + Path.combine(Haxelib.getPath(new Haxelib("lime")), "templates/bin/lime.sh") + "\" /usr/local/bin/lime"); Sys.println("sudo cp \"" + Path.combine(Haxelib.getPath(new Haxelib("lime")), "templates/bin/lime.sh") + "\" /usr/local/bin/lime");
Sys.println("sudo chmod 755 /usr/local/bin/lime"); Sys.println("sudo chmod 755 /usr/local/bin/lime");
Sys.println("sudo cp \"" + System.findTemplate(project.templatePaths, "bin/openfl.sh") + "\" /usr/local/bin/openfl"); Sys.println("sudo cp \"" + System.findTemplate(project.templatePaths, "bin/openfl.sh") + "\" /usr/local/bin/openfl");
Sys.println("sudo chmod 755 /usr/local/bin/openfl"); Sys.println("sudo chmod 755 /usr/local/bin/openfl");
Sys.println(""); Sys.println("");
}
} }
} }