summaryrefslogtreecommitdiff
path: root/xmake/rules/xcode
diff options
context:
space:
mode:
authorruki <[email protected]>2022-09-17 22:17:05 +0800
committerruki <[email protected]>2022-09-17 22:17:05 +0800
commit1060233e0c71738ce6a010a395773fe68b0d057e (patch)
tree2bc41b73e4bff4443c565fa56d523e279f32f680 /xmake/rules/xcode
parentb3957eca3816e549c783e19d18101a843807b0ce (diff)
fix bundle for swift
Diffstat (limited to 'xmake/rules/xcode')
-rw-r--r--xmake/rules/xcode/bundle/xmake.lua22
1 files changed, 16 insertions, 6 deletions
diff --git a/xmake/rules/xcode/bundle/xmake.lua b/xmake/rules/xcode/bundle/xmake.lua
index 322a42418..b78e115ed 100644
--- a/xmake/rules/xcode/bundle/xmake.lua
+++ b/xmake/rules/xcode/bundle/xmake.lua
@@ -27,6 +27,15 @@ rule("xcode.bundle")
-- we must set kind before target.on_load(), may we will use target in on_load()
on_load(function (target)
+ -- generate binary as bundle, we cannot set `-shared` or `-dynamiclib`
+ target:set("kind", "binary")
+
+ -- set target info for bundle
+ target:set("filename", target:basename())
+ end)
+
+ on_config(function (target)
+
-- get bundle directory
local targetdir = target:targetdir()
local bundledir = path.join(targetdir, target:basename() .. ".bundle")
@@ -42,12 +51,13 @@ rule("xcode.bundle")
target:data_set("xcode.bundle.contentsdir", contentsdir)
target:data_set("xcode.bundle.resourcesdir", resourcesdir)
- -- set target info for bundle
- target:set("filename", target:basename())
-
- -- generate binary as bundle, we cannot set `-shared` or `-dynamiclib`
- target:set("kind", "binary")
- target:add("ldflags", "-bundle", {force = true})
+ -- add bundle flags
+ local linker = target:linker():name()
+ if linker == "swiftc" then
+ target:add("ldflags", "-Xlinker -bundle", {force = true})
+ else
+ target:add("ldflags", "-bundle", {force = true})
+ end
-- register clean files for `xmake clean`
target:add("cleanfiles", bundledir)