From f0bae5692e85639d7199a906279231e4d054abc1 Mon Sep 17 00:00:00 2001 From: player-03 Date: Sat, 27 Jan 2024 22:29:04 -0500 Subject: [PATCH] Improve target selection logic in `MacPlatform.rebuild()`. 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. --- tools/platforms/MacPlatform.hx | 38 +++++++++++++++++----------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/tools/platforms/MacPlatform.hx b/tools/platforms/MacPlatform.hx index dbe8bf522..65c4e7b03 100644 --- a/tools/platforms/MacPlatform.hx +++ b/tools/platforms/MacPlatform.hx @@ -385,27 +385,27 @@ class MacPlatform extends PlatformTarget { var commands = []; - if (targetFlags.exists("hl") && System.hostArchitecture == X64) + switch (System.hostArchitecture) { - // TODO: Support single binary - commands.push(["-Dmac", "-DHXCPP_CLANG", "-DHXCPP_M64", "-Dhashlink"]); - } - else - { - 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"))