Implement lime setup hl in a hopefully better way.

This commit is contained in:
Apprentice-Alchemist
2022-03-12 21:37:23 +01:00
parent 18f680e247
commit cb3b0240de
5 changed files with 126 additions and 66 deletions

View File

@@ -0,0 +1,57 @@
package lime.tools;
import lime.tools.ConfigHelper;
import lime.tools.HXProject;
import lime.tools.Platform;
import hxp.Path;
import hxp.System;
class HashlinkHelper
{
public static function copyHashlink(project:HXProject, targetDirectory:String, applicationDirectory:String, executablePath:String)
{
final platform = project.target;
final hlPath = ConfigHelper.getConfigValue("HL_PATH");
if (hlPath == null)
{
System.recursiveCopyTemplate(project.templatePaths, 'bin/hl/$platform', applicationDirectory);
}
else
{
System.copyFile(Path.combine(hlPath, "hl" + (platform == WINDOWS ? ".exe" : "")), executablePath);
if (platform == WINDOWS)
{
System.copyFile(Path.combine(hlPath, "libhl.dll"), Path.combine(applicationDirectory, "libhl.dll"));
System.copyFile(Path.combine(hlPath, "msvcr120.dll"), Path.combine(applicationDirectory, "msvcr120.dll"));
}
else if (platform == MAC || platform == IOS)
{
System.copyFile(Path.combine(hlPath, "libhl.dylib"), Path.combine(applicationDirectory, "libhl.dylib"));
}
else
{
System.copyFile(Path.combine(hlPath, "libhl.so"), Path.combine(applicationDirectory, "libhl.so"));
}
for (file in System.readDirectory(hlPath)
.filter(f -> Path.extension(f) == "hdll"
&& Path.withoutDirectory(f) != "sdl.hdll"
&& Path.withoutDirectory(f) != "openal.hdll"))
{
System.copyFile(file, Path.combine(applicationDirectory, Path.withoutDirectory(file)));
}
}
// make sure no hxcpp hash files remain
for (file in System.readDirectory(applicationDirectory))
{
if (Path.extension(file) == "hash")
{
System.deleteFile(file);
}
}
System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat"));
}
}

View File

@@ -1,5 +1,6 @@
package;
import lime.tools.HashlinkHelper;
import hxp.Haxelib;
import hxp.HXML;
import hxp.Path;
@@ -220,19 +221,7 @@ class LinuxPlatform extends PlatformTarget
if (noOutput) return;
// System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl",
// Path.combine(applicationDirectory, project.app.file + ".hl"));
System.recursiveCopyTemplate(project.templatePaths, "bin/hl/linux", applicationDirectory);
System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat"));
System.renameFile(Path.combine(applicationDirectory, "hl"), executablePath);
// let's not keep around hxcpp's hash files
for (file in System.readDirectory(applicationDirectory))
{
if (Path.extension(file) == "hash")
{
System.deleteFile(file);
}
}
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
}
else if (targetType == "nodejs")
{

View File

@@ -1,5 +1,6 @@
package;
import lime.tools.HashlinkHelper;
import hxp.Haxelib;
import hxp.HXML;
import hxp.Log;
@@ -205,19 +206,21 @@ class MacPlatform extends PlatformTarget
if (noOutput) return;
// System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl",
// Path.combine(executableDirectory, project.app.file + ".hl"));
System.recursiveCopyTemplate(project.templatePaths, "bin/hl/mac", executableDirectory);
// let's not keep around hxcpp's hash files
for (file in System.readDirectory(applicationDirectory))
{
if (Path.extension(file) == "hash")
{
System.deleteFile(file);
}
}
System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(executableDirectory, "hlboot.dat"));
System.renameFile(Path.combine(executableDirectory, "hl"), executablePath);
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
// // System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".hl",
// // Path.combine(executableDirectory, project.app.file + ".hl"));
// System.recursiveCopyTemplate(project.templatePaths, "bin/hl/mac", executableDirectory);
// // let's not keep around hxcpp's hash files
// for (file in System.readDirectory(applicationDirectory))
// {
// if (Path.extension(file) == "hash")
// {
// System.deleteFile(file);
// }
// }
// System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(executableDirectory, "hlboot.dat"));
// System.renameFile(Path.combine(executableDirectory, "hl"), executablePath);
}
else if (targetType == "java")
{

View File

@@ -1,5 +1,6 @@
package;
import lime.tools.HashlinkHelper;
import hxp.Haxelib;
import hxp.HXML;
import hxp.Log;
@@ -341,10 +342,12 @@ class WindowsPlatform extends PlatformTarget
if (noOutput) return;
HashlinkHelper.copyHashlink(project, targetDirectory, applicationDirectory, executablePath);
// System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, project.app.file + ".hl"));
System.recursiveCopyTemplate(project.templatePaths, "bin/hl/windows", applicationDirectory);
System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat"));
System.renameFile(Path.combine(applicationDirectory, "hl.exe"), executablePath);
// System.recursiveCopyTemplate(project.templatePaths, "bin/hl/windows", applicationDirectory);
// System.copyFile(targetDirectory + "/obj/ApplicationMain.hl", Path.combine(applicationDirectory, "hlboot.dat"));
// System.renameFile(Path.combine(applicationDirectory, "hl.exe"), executablePath);
// let's not keep around hxcpp's hash files
for (file in System.readDirectory(applicationDirectory))
{

View File

@@ -1185,9 +1185,16 @@ class PlatformSetup
public static function setupHL():Void
{
getDefineValue("HL_PATH", "Path to a custom version of Hashlink. Leave empty to use lime's default version.");
if (System.hostPlatform == MAC)
{
Log.println("To use the hashlink debugger on macOS, the hl executable needs to be signed.");
if (ConfigHelper.getConfigValue("HL_PATH") != null)
{
Log.println("When building HL from source, make sure to have run `make codesign_osx` before installing.");
}
else
{
var answer = CLIHelper.ask("Would you like to do this now? (Requires sudo.)");
if (answer == YES || answer == ALWAYS)
@@ -1211,8 +1218,8 @@ class PlatformSetup
"extendedKeyUsage=critical,codeSigning",
].join("\n"));
System.runCommand("", "openssl", [
"req", "-x509", "-newkey", "rsa:4096", "-keyout", key, "-nodes", "-days", "365", "-subj", "/CN=hl-cert", "-outform", "der", "-out", cert,
"-extensions", "v3_req", "-config", openSSLConf
"req", "-x509", "-newkey", "rsa:4096", "-keyout", key, "-nodes", "-days", "365", "-subj", "/CN=hl-cert", "-outform", "der", "-out",
cert, "-extensions", "v3_req", "-config", openSSLConf
], true, false, true);
System.runCommand("", "sudo", [
"security",
@@ -1229,6 +1236,7 @@ class PlatformSetup
}
}
}
}
private static function throwPermissionsError()
{