summaryrefslogtreecommitdiff
path: root/xmake/rules
diff options
context:
space:
mode:
authorruki <[email protected]>2023-07-10 23:18:47 +0800
committerruki <[email protected]>2023-07-10 23:18:47 +0800
commite0cc53f53a0e40bd0cf3b4bbd0ca032627e981ae (patch)
treefe397ea4be1283b2c9f6119db06d111e468ac123 /xmake/rules
parentb3627c504fb1c65f829f92c5cd709b23a6776895 (diff)
support multiple modules
Diffstat (limited to 'xmake/rules')
-rw-r--r--xmake/rules/swift/xmake.lua13
1 files changed, 13 insertions, 0 deletions
diff --git a/xmake/rules/swift/xmake.lua b/xmake/rules/swift/xmake.lua
index 5ebd919c9..d1ea0e886 100644
--- a/xmake/rules/swift/xmake.lua
+++ b/xmake/rules/swift/xmake.lua
@@ -22,6 +22,19 @@
rule("swift.build")
set_sourcekinds("sc")
on_build_files("private.action.build.object", {batch = true})
+ on_config(function (target)
+ -- we use swift-frontend to support multiple modules
+ -- @see https://github.com/xmake-io/xmake/issues/3916
+ if target:has_tool("sc", "swift_frontend") then
+ target:add("scflags", "-module-name", target:name(), {force = true})
+ local sourcebatch = target:sourcebatches()["swift.build"]
+ if sourcebatch then
+ for _, sourcefile in ipairs(sourcebatch.sourcefiles) do
+ target:add("scflags", sourcefile, {force = true})
+ end
+ end
+ end
+ end)
-- define rule: swift
rule("swift")