Skip to content

Commit

Permalink
Improve target selection logic in MacPlatform.rebuild().
Browse files Browse the repository at this point in the history
The old logic could produce inappropriate results, such as attempting to compile an x86 binary on ARM64, or compiling no binary when "64" is specified on a 32-bit machine. I'd argue that it makes sense to only check the flags when they're supported, and not to bother otherwise.
  • Loading branch information
player-03 authored Jan 28, 2024
1 parent f06c78e commit f0bae56
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions tools/platforms/MacPlatform.hx
Original file line number Diff line number Diff line change
Expand Up @@ -385,27 +385,27 @@ class MacPlatform extends PlatformTarget
{
var commands = [];

if (targetFlags.exists("hl") && System.hostArchitecture == X64)
{
// TODO: Support single binary
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]);
}
else
switch (System.hostArchitecture)
{
if (!targetFlags.exists("32") && System.hostArchitecture == X64)
{
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]);
}

if (!targetFlags.exists("32") && System.hostArchitecture == ARM64)
{
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_ARM64"]);
}

if (!targetFlags.exists("64") && (targetFlags.exists("32") || System.hostArchitecture == X86))
{
case X64:
if (targetFlags.exists("hl"))
{
// TODO: Support single binary
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]);
}
else if (!targetFlags.exists("32"))
{
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64"]);
}
else
{
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]);
}
case X86:
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M32"]);
}
case ARM64:
commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_ARM64"]);
default:
}

if (targetFlags.exists("hl"))
Expand Down

0 comments on commit f0bae56

Please sign in to comment.