summaryrefslogtreecommitdiff
path: root/xmake/modules/private/utils
diff options
context:
space:
mode:
authorruki <[email protected]>2026-02-11 09:51:35 +0800
committerGitHub <[email protected]>2026-02-11 09:51:35 +0800
commit55648bbba1a1d822cc3130d5ac638ddc276dbf71 (patch)
tree98452a2614431ffb8735819f4e4eb49fc27942d6 /xmake/modules/private/utils
parentde97caa61ab95c3a422dc9c494370f513e4ef535 (diff)
parent2e9e484793bc705d2f0c2911040ca87e753eb205 (diff)
Merge pull request #7311 from xmake-io/xcode
Improve Xcode toolchain
Diffstat (limited to 'xmake/modules/private/utils')
-rw-r--r--xmake/modules/private/utils/toolchain.lua40
1 files changed, 40 insertions, 0 deletions
diff --git a/xmake/modules/private/utils/toolchain.lua b/xmake/modules/private/utils/toolchain.lua
index bf24d3c73..d6f320a05 100644
--- a/xmake/modules/private/utils/toolchain.lua
+++ b/xmake/modules/private/utils/toolchain.lua
@@ -184,6 +184,46 @@ function get_clang_target_flags(toolchain)
end
end
+-- get xcode/apple target triple for clang -target
+--
+-- e.g.
+-- - macosx: x86_64-apple-macos14.0
+-- - macosx(catalyst): arm64-apple-macos14.0-macabi
+-- - iphoneos: arm64-apple-ios18.2
+-- - iphoneos(simulator): x86_64-apple-ios18.2-simulator
+-- - appletvos: arm64-apple-tvos17.0
+-- - watchos: armv7k-apple-watchos10.0
+-- - applexros(simulator): x86_64-apple-xros1.0-simulator
+--
+-- configs:
+-- - appledev: simulator/catalyst
+-- - target_minver: deployment target version (ios 32-bit will be capped to 10)
+function get_xcode_target_triple(toolchain)
+ local arch = toolchain:arch()
+ local plat = toolchain:plat()
+ local platmap = {macosx = "macos", iphoneos = "ios", watchos = "watchos", appletvos = "tvos", applexros = "xros"}
+ plat = platmap[plat] or plat
+ local target_minver = toolchain:config("target_minver") or config.get("target_minver")
+ local appledev = toolchain:config("appledev") or config.get("appledev")
+ local target = format("%s-apple-%s", arch, plat)
+ if target_minver then
+ if plat == "ios" and tonumber(target_minver) > 10 and (arch == "armv7" or arch == "armv7s" or arch == "i386") then
+ target_minver = "10"
+ end
+ target = target .. target_minver
+ end
+ if plat == "macos" then
+ if appledev == "catalyst" then
+ target = target .. "-macabi"
+ end
+ else
+ if appledev == "simulator" then
+ target = target .. "-simulator"
+ end
+ end
+ return target
+end
+
-- add vs environments
function add_vsenvs(toolchain, opt)
opt = opt or {}