Skip to content

Commit

Permalink
Merge is64 and isArm64.
Browse files Browse the repository at this point in the history
  • Loading branch information
player-03 authored Jan 28, 2024
1 parent 3d87dfe commit 17ad057
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions tools/platforms/MacPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,11 @@ class MacPlatform extends PlatformTarget
private var contentDirectory:String;
private var executableDirectory:String;
private var executablePath:String;
private var is64:Bool;
private var isArm64:Bool;
private var targetArchitecture:Architecture;
private var targetType:String;

private var dirSuffix(get, never):String;

public function new(command:String, _project:HXProject, targetFlags:Map<String, String>)
{
super(command, _project, targetFlags);
Expand Down Expand Up @@ -127,11 +128,15 @@ class MacPlatform extends PlatformTarget

if (project.architectures.indexOf(X64) != -1)
{
is64 = true;
targetArchitecture = X64;
}
else if (project.architectures.indexOf(ARM64) != -1)
{
isArm64 = true;
targetArchitecture = ARM64;
}
else
{
targetArchitecture = X86;
}

if (project.targetFlags.exists("neko") || project.target != cast System.hostPlatform)
Expand All @@ -141,7 +146,7 @@ class MacPlatform extends PlatformTarget
else if (project.targetFlags.exists("hl"))
{
targetType = "hl";
is64 = true;
targetArchitecture = X64;
}
else if (project.targetFlags.exists("java"))
{
Expand All @@ -161,7 +166,7 @@ class MacPlatform extends PlatformTarget
}

targetDirectory = Path.combine(project.app.path, project.config.getString("mac.output-directory", targetType == "cpp" ? "macos" : targetType));
targetDirectory = StringTools.replace(targetDirectory, "arch64", is64 ? "64" : "");
targetDirectory = StringTools.replace(targetDirectory, "arch64", dirSuffix);
applicationDirectory = targetDirectory + "/bin/" + project.app.file + ".app";
contentDirectory = applicationDirectory + "/Contents/Resources";
executableDirectory = applicationDirectory + "/Contents/MacOS";
Expand All @@ -183,11 +188,11 @@ class MacPlatform extends PlatformTarget
// TODO: Support single binary for HashLink
if (targetType == "hl")
{
ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "", ".hdll", executableDirectory, project.debug, targetSuffix);
ProjectHelper.copyLibrary(project, ndll, "Mac" + dirSuffix, "", ".hdll", executableDirectory, project.debug, targetSuffix);
}
else
{
ProjectHelper.copyLibrary(project, ndll, "Mac" + (is64 ? "64" : ""), "",
ProjectHelper.copyLibrary(project, ndll, "Mac" + dirSuffix, "",
(ndll.haxelib != null
&& (ndll.haxelib.name == "hxcpp" || ndll.haxelib.name == "hxlibc")) ? ".dll" : ".ndll", executableDirectory,
project.debug, targetSuffix);
Expand All @@ -201,16 +206,16 @@ class MacPlatform extends PlatformTarget

if (noOutput) return;

NekoHelper.createExecutable(project.templatePaths, "mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries(project.templatePaths, "mac" + (is64 ? "64" : ""), executableDirectory);
NekoHelper.createExecutable(project.templatePaths, "mac" + dirSuffix, targetDirectory + "/obj/ApplicationMain.n", executablePath);
NekoHelper.copyLibraries(project.templatePaths, "mac" + dirSuffix, executableDirectory);
}
else if (targetType == "hl")
{
System.runCommand("", "haxe", [hxml]);

if (noOutput) return;

HashlinkHelper.copyHashlink(project, targetDirectory, executableDirectory, executablePath, is64);
HashlinkHelper.copyHashlink(project, targetDirectory, executableDirectory, executablePath, true);

This comment has been minimized.

Copy link
@tobil4sk

tobil4sk Feb 4, 2024

Member

@player-03 Looks like we overlooked this, this is another artefact of is64 being forced on hashlink.


// HashLink looks for hlboot.dat and libraries in the current
// working directory, so the .app file won't work properly if it
Expand Down Expand Up @@ -238,16 +243,16 @@ class MacPlatform extends PlatformTarget
System.recursiveCopy(targetDirectory + "/obj/lib", Path.combine(executableDirectory, "lib"));
System.copyFile(targetDirectory + "/obj/ApplicationMain" + (project.debug ? "-Debug" : "") + ".jar",
Path.combine(executableDirectory, project.app.file + ".jar"));
JavaHelper.copyLibraries(project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory);
JavaHelper.copyLibraries(project.templatePaths, "Mac" + dirSuffix, executableDirectory);
}
else if (targetType == "nodejs")
{
System.runCommand("", "haxe", [hxml]);

if (noOutput) return;

// NekoHelper.createExecutable (project.templatePaths, "Mac" + (is64 ? "64" : ""), targetDirectory + "/obj/ApplicationMain.n", executablePath);
// NekoHelper.copyLibraries (project.templatePaths, "Mac" + (is64 ? "64" : ""), executableDirectory);
// NekoHelper.createExecutable (project.templatePaths, "Mac" + dirSuffix, targetDirectory + "/obj/ApplicationMain.n", executablePath);
// NekoHelper.copyLibraries (project.templatePaths, "Mac" + dirSuffix, executableDirectory);
}
else if (targetType == "cs")
{
Expand All @@ -268,13 +273,13 @@ class MacPlatform extends PlatformTarget
var haxeArgs = [hxml, "-D", "HXCPP_CLANG"];
var flags = ["-DHXCPP_CLANG"];

if (is64)
if (targetArchitecture == X64)
{
haxeArgs.push("-D");
haxeArgs.push("HXCPP_M64");
flags.push("-DHXCPP_M64");
}
else if (isArm64)
else if (targetArchitecture == ARM64)
{
haxeArgs.push("-D");
haxeArgs.push("HXCPP_ARM64");
Expand Down Expand Up @@ -342,7 +347,7 @@ class MacPlatform extends PlatformTarget
context.NODE_FILE = executableDirectory + "/ApplicationMain.js";
context.HL_FILE = targetDirectory + "/obj/ApplicationMain.hl";
context.CPP_DIR = targetDirectory + "/obj/";
context.BUILD_DIR = project.app.path + "/mac" + (is64 ? "64" : "");
context.BUILD_DIR = project.app.path + "/mac" + dirSuffix;

return context;
}
Expand Down Expand Up @@ -470,7 +475,7 @@ class MacPlatform extends PlatformTarget

if (ndll.path == null || ndll.path == "")
{
context.ndlls[i].path = NDLL.getLibraryPath(ndll, "Mac" + (is64 ? "64" : ""), "lib", ".a", project.debug);
context.ndlls[i].path = NDLL.getLibraryPath(ndll, "Mac" + dirSuffix, "lib", ".a", project.debug);
}
}
}
Expand Down Expand Up @@ -545,4 +550,11 @@ class MacPlatform extends PlatformTarget
@ignore public override function trace():Void {}

@ignore public override function uninstall():Void {}

// Getters & Setters

private inline function get_dirSuffix():String
{
return targetArchitecture == X64 ? "64" : "";
}
}

0 comments on commit 17ad057

Please sign in to comment.