Implement lime setup hl in a hopefully better way.
This commit is contained in:
57
src/lime/tools/HashlinkHelper.hx
Normal file
57
src/lime/tools/HashlinkHelper.hx
Normal 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"));
|
||||
}
|
||||
}
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -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")
|
||||
{
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -1185,47 +1185,55 @@ 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.");
|
||||
var answer = CLIHelper.ask("Would you like to do this now? (Requires sudo.)");
|
||||
|
||||
if (answer == YES || answer == ALWAYS)
|
||||
if (ConfigHelper.getConfigValue("HL_PATH") != null)
|
||||
{
|
||||
final openSSLConf = System.getTemporaryFile("cnf");
|
||||
final key = System.getTemporaryFile("pem");
|
||||
final cert = System.getTemporaryFile("cer");
|
||||
final limePath = Haxelib.getPath(new Haxelib("lime"));
|
||||
final hlPath = limePath + "/templates/bin/hl/mac/hl";
|
||||
final entitlementsPath = sys.FileSystem.exists(limePath + "/project") ? (limePath +
|
||||
"/project/lib/hashlink/other/osx/entitlements.xml") : (limePath
|
||||
+ "/templates/bin/hl/entitlements.xml");
|
||||
System.runCommand("", "sudo", ["security", "delete-identity", "-c", "hl-cert"], true, false, true);
|
||||
sys.io.File.saveContent(openSSLConf, [
|
||||
"[req]",
|
||||
"distinguished_name=codesign_dn",
|
||||
"[codesign_dn]",
|
||||
"commonName=hl-cert",
|
||||
"[v3_req]",
|
||||
"keyUsage=critical,digitalSignature",
|
||||
"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
|
||||
], true, false, true);
|
||||
System.runCommand("", "sudo", [
|
||||
"security",
|
||||
"add-trusted-cert",
|
||||
"-d",
|
||||
"-k /Library/Keychains/System.keychain",
|
||||
cert
|
||||
], true, false, true);
|
||||
System.runCommand("", "sudo", ["security", "import", key, "-k", "/Library/Keychains/System.keychain", "-A"], true, false, true);
|
||||
System.runCommand("", "codesign", ["--entitlements", entitlementsPath, "-fs", "hl-cert", hlPath], true, false, true);
|
||||
for (f in [key, cert, openSSLConf])
|
||||
sys.FileSystem.deleteFile(f);
|
||||
Log.println("\nIf you update lime, yo will have to run this again to sign the new hl executable");
|
||||
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)
|
||||
{
|
||||
final openSSLConf = System.getTemporaryFile("cnf");
|
||||
final key = System.getTemporaryFile("pem");
|
||||
final cert = System.getTemporaryFile("cer");
|
||||
final limePath = Haxelib.getPath(new Haxelib("lime"));
|
||||
final hlPath = limePath + "/templates/bin/hl/mac/hl";
|
||||
final entitlementsPath = sys.FileSystem.exists(limePath + "/project") ? (limePath +
|
||||
"/project/lib/hashlink/other/osx/entitlements.xml") : (limePath
|
||||
+ "/templates/bin/hl/entitlements.xml");
|
||||
System.runCommand("", "sudo", ["security", "delete-identity", "-c", "hl-cert"], true, false, true);
|
||||
sys.io.File.saveContent(openSSLConf, [
|
||||
"[req]",
|
||||
"distinguished_name=codesign_dn",
|
||||
"[codesign_dn]",
|
||||
"commonName=hl-cert",
|
||||
"[v3_req]",
|
||||
"keyUsage=critical,digitalSignature",
|
||||
"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
|
||||
], true, false, true);
|
||||
System.runCommand("", "sudo", [
|
||||
"security",
|
||||
"add-trusted-cert",
|
||||
"-d",
|
||||
"-k /Library/Keychains/System.keychain",
|
||||
cert
|
||||
], true, false, true);
|
||||
System.runCommand("", "sudo", ["security", "import", key, "-k", "/Library/Keychains/System.keychain", "-A"], true, false, true);
|
||||
System.runCommand("", "codesign", ["--entitlements", entitlementsPath, "-fs", "hl-cert", hlPath], true, false, true);
|
||||
for (f in [key, cert, openSSLConf])
|
||||
sys.FileSystem.deleteFile(f);
|
||||
Log.println("\nIf you update lime, yo will have to run this again to sign the new hl executable");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user