diff options
| author | Arthur LAURENT <[email protected]> | 2025-10-23 22:08:25 +0200 |
|---|---|---|
| committer | Arthur LAURENT <[email protected]> | 2025-10-23 22:08:25 +0200 |
| commit | 16dc28b62144cdcc42cb7597e39d2d9499ac7f49 (patch) | |
| tree | ed93570c4bde41e999021f30c074e6938f2c6b3a | |
| parent | 435242713b1d1ed077c264228c0216dfa985685f (diff) | |
feat(swift) use swiftc as swift static library archiver
| -rw-r--r-- | xmake/core/tool/toolchain.lua | 1 | ||||
| -rw-r--r-- | xmake/languages/swift/xmake.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/swift/xmake.lua | 3 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_appletvos.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_applexros.lua | 8 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_iphoneos.lua | 5 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_macosx.lua | 7 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/load_watchos.lua | 4 | ||||
| -rw-r--r-- | xmake/toolchains/xcode/xmake.lua | 1 |
9 files changed, 33 insertions, 6 deletions
diff --git a/xmake/core/tool/toolchain.lua b/xmake/core/tool/toolchain.lua index 57b2f5073..2230aae9e 100644 --- a/xmake/core/tool/toolchain.lua +++ b/xmake/core/tool/toolchain.lua @@ -442,6 +442,7 @@ function _instance:_description(toolkind) sc = "the swift compiler", scld = "the swift linker", scsh = "the swift shared library linker", + scar = "the swift static library archiver", gc = "the golang compiler", gcld = "the golang linker", gcar = "the golang static library archiver", diff --git a/xmake/languages/swift/xmake.lua b/xmake/languages/swift/xmake.lua index 8048966f9..a00810111 100644 --- a/xmake/languages/swift/xmake.lua +++ b/xmake/languages/swift/xmake.lua @@ -22,8 +22,8 @@ language("swift") add_rules("swift") set_sourcekinds {sc = ".swift"} set_sourceflags {sc = "scflags"} - set_targetkinds {binary = "scld", static = "ar", shared = "scsh"} - set_targetflags {binary = "ldflags", static = "arflags", shared = "shflags"} + set_targetkinds {binary = "scld", static = "scar", shared = "scsh"} + set_targetflags {binary = "ldflags", static = "scarflags", shared = "shflags"} set_langkinds {swift = "sc"} set_mixingkinds("sc", "mm", "mxx", "cc", "cxx") @@ -105,6 +105,7 @@ language("swift") , {category = "Cross Complation Configuration/Linker Configuration" } , { nil, "scld", "kv", nil, "The Swift Linker" } , { nil, "scsh", "kv", nil, "The Swift Shared Library Linker" } + , { nil, "scar", "kv", nil, "The Swift Static Library Archiver" } , { category = "Cross Complation Configuration/Builtin Flags Configuration" } , { nil, "links", "kv", nil, "The Link Libraries" } diff --git a/xmake/toolchains/swift/xmake.lua b/xmake/toolchains/swift/xmake.lua index 2dec302bf..38c263a65 100644 --- a/xmake/toolchains/swift/xmake.lua +++ b/xmake/toolchains/swift/xmake.lua @@ -27,8 +27,9 @@ toolchain("swift") -- set toolset set_toolset("sc", "$(env SC)", "swift-frontend", "swiftc") - set_toolset("scld", "$(env SC)", "swiftc") set_toolset("scsh", "$(env SC)", "swiftc") + set_toolset("scar", "$(env SC)", "swiftc") + set_toolset("scld", "$(env SC)", "swiftc") -- on load on_load(function (toolchain) 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 |
