summaryrefslogtreecommitdiff
path: root/xmake/toolchains/xcode
diff options
context:
space:
mode:
authorArthur LAURENT <[email protected]>2025-10-23 22:08:25 +0200
committerArthur LAURENT <[email protected]>2025-10-23 22:08:25 +0200
commit16dc28b62144cdcc42cb7597e39d2d9499ac7f49 (patch)
treeed93570c4bde41e999021f30c074e6938f2c6b3a /xmake/toolchains/xcode
parent435242713b1d1ed077c264228c0216dfa985685f (diff)
feat(swift) use swiftc as swift static library archiver
Diffstat (limited to 'xmake/toolchains/xcode')
-rw-r--r--xmake/toolchains/xcode/load_appletvos.lua5
-rw-r--r--xmake/toolchains/xcode/load_applexros.lua8
-rw-r--r--xmake/toolchains/xcode/load_iphoneos.lua5
-rw-r--r--xmake/toolchains/xcode/load_macosx.lua7
-rw-r--r--xmake/toolchains/xcode/load_watchos.lua4
-rw-r--r--xmake/toolchains/xcode/xmake.lua1
6 files changed, 27 insertions, 3 deletions
diff --git a/xmake/toolchains/xcode/load_appletvos.lua b/xmake/toolchains/xcode/load_appletvos.lua
index c4aea5953..446177cab 100644
--- a/xmake/toolchains/xcode/load_appletvos.lua
+++ b/xmake/toolchains/xcode/load_appletvos.lua
@@ -48,6 +48,11 @@ function main(toolchain)
-- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags)
toolchain:add("scflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scshflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
+ toolchain:add("scarflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scldflags", format("-target %s-apple-tvos%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
+
+ toolchain:add("scshflags", "-sdk " .. xcode_sysroot, "-emit-library")
+ toolchain:add("scarflags", "-sdk " .. xcode_sysroot, "-emit-library", "-static")
+ toolchain:add("scldflags", "-sdk " .. xcode_sysroot, "-emit-executable")
end
diff --git a/xmake/toolchains/xcode/load_applexros.lua b/xmake/toolchains/xcode/load_applexros.lua
index 9f1702ba5..6a74abaf7 100644
--- a/xmake/toolchains/xcode/load_applexros.lua
+++ b/xmake/toolchains/xcode/load_applexros.lua
@@ -37,6 +37,7 @@ function main(toolchain)
toolchain:add("scflags", "-target", target)
toolchain:add("scldflags", "-target", target)
toolchain:add("scshflags", "-target", target)
+ toolchain:add("scarflags", "-target", target)
end
-- init flags for c/c++
@@ -52,9 +53,10 @@ function main(toolchain)
-- init flags for asm
toolchain:add("asflags", "-isysroot", xcode_sysroot)
- -- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags)
+ -- init flags for swift (with toolchain:add("ldflags") and toolchain:add("shflags") and toolchain:add("arflags"))
toolchain:add("scflags", "-sdk " .. xcode_sysroot)
- toolchain:add("scshflags", "-sdk " .. xcode_sysroot)
- toolchain:add("scldflags", "-sdk " .. xcode_sysroot)
+ toolchain:add("scshflags", "-sdk " .. xcode_sysroot, "-emit-library")
+ toolchain:add("scarflags", "-sdk " .. xcode_sysroot, "-emit-library", "-static")
+ toolchain:add("scldflags", "-sdk " .. xcode_sysroot, "-emit-executable")
end
diff --git a/xmake/toolchains/xcode/load_iphoneos.lua b/xmake/toolchains/xcode/load_iphoneos.lua
index fd4cd4548..4f3fb1293 100644
--- a/xmake/toolchains/xcode/load_iphoneos.lua
+++ b/xmake/toolchains/xcode/load_iphoneos.lua
@@ -51,6 +51,11 @@ function main(toolchain)
-- init flags for swift (with toolchain:add("ldflags and toolchain:add("shflags)
toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
+ toolchain:add("scarflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
+
+ toolchain:add("scshflags", "-emit-library")
+ toolchain:add("scarflags", "-emit-library", "-static")
+ toolchain:add("scldflags", "-emit-executable")
end
diff --git a/xmake/toolchains/xcode/load_macosx.lua b/xmake/toolchains/xcode/load_macosx.lua
index 702d721f4..c88680644 100644
--- a/xmake/toolchains/xcode/load_macosx.lua
+++ b/xmake/toolchains/xcode/load_macosx.lua
@@ -39,6 +39,7 @@ function main(toolchain)
toolchain:add("scflags", "-target", target)
toolchain:add("scldflags", "-target", target)
toolchain:add("scshflags", "-target", target)
+ toolchain:add("scarflags", "-target", target)
end
-- add sysroot flags
@@ -50,6 +51,7 @@ function main(toolchain)
toolchain:add("mxflags", "-isysroot", xcode_sysroot)
toolchain:add("scflags", "-sdk " .. xcode_sysroot)
toolchain:add("scshflags", "-sdk " .. xcode_sysroot)
+ toolchain:add("scarflags", "-sdk " .. xcode_sysroot)
toolchain:add("scldflags", "-sdk " .. xcode_sysroot)
if appledev == "catalyst" then
toolchain:add("cxflags", {"-I", path.join(xcode_sysroot, "System/iOSSupport/usr/include")})
@@ -66,6 +68,7 @@ function main(toolchain)
toolchain:add("mxflags", {"-iframework", path.join(xcode_sysroot, "System/iOSSupport/System/Library/Frameworks")})
toolchain:add("scflags", {"-iframework", path.join(xcode_sysroot, "System/iOSSupport/System/Library/Frameworks")})
toolchain:add("scshflags", {"-iframework", path.join(xcode_sysroot, "System/iOSSupport/System/Library/Frameworks")})
+ toolchain:add("scarflags", {"-iframework", path.join(xcode_sysroot, "System/iOSSupport/System/Library/Frameworks")})
toolchain:add("scldflags", {"-iframework", path.join(xcode_sysroot, "System/iOSSupport/System/Library/Frameworks")})
end
end
@@ -77,4 +80,8 @@ function main(toolchain)
-- init flags for objc/c++ (with ldflags and shflags)
-- we can use `add_mxflags("-fno-objc-arc")` to override it in xmake.lua
toolchain:add("mxflags", "-fobjc-arc")
+
+ toolchain:add("scshflags", "-emit-library")
+ toolchain:add("scarflags", "-emit-library", "-static")
+ toolchain:add("scldflags", "-emit-executable")
end
diff --git a/xmake/toolchains/xcode/load_watchos.lua b/xmake/toolchains/xcode/load_watchos.lua
index 91503ff80..e3deebb8a 100644
--- a/xmake/toolchains/xcode/load_watchos.lua
+++ b/xmake/toolchains/xcode/load_watchos.lua
@@ -49,5 +49,9 @@ function main(toolchain)
toolchain:add("scflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scshflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
toolchain:add("scldflags", format("-target %s-apple-ios%s", arch, target_minver) , "-sdk " .. xcode_sysroot)
+
+ toolchain:add("scshflags", "-emit-library")
+ toolchain:add("scarflags", "-emit-library", "-static")
+ toolchain:add("scldflags", "-emit-executable")
end
diff --git a/xmake/toolchains/xcode/xmake.lua b/xmake/toolchains/xcode/xmake.lua
index dfe224d29..482fbaf7e 100644
--- a/xmake/toolchains/xcode/xmake.lua
+++ b/xmake/toolchains/xcode/xmake.lua
@@ -51,6 +51,7 @@ toolchain("xcode")
toolchain:set("toolset", "sc", xc_swift_frontend, "swift_frontend", xc_swiftc, "swiftc")
toolchain:set("toolset", "scld", xc_swiftc, "swiftc")
toolchain:set("toolset", "scsh", xc_swiftc, "swiftc")
+ toolchain:set("toolset", "scar", xc_swiftc, "swiftc")
if arch then
toolchain:set("toolset", "cpp", xc_clang .. " -arch " .. arch .. " -E")
end