summaryrefslogtreecommitdiff
path: root/xmake/rules/xcode/bundle/xmake.lua
diff options
context:
space:
mode:
authorruki <[email protected]>2020-04-04 21:27:21 +0800
committerruki <[email protected]>2020-04-04 21:27:21 +0800
commitdb450e5497761c5def6cab798d7fabfc4316214a (patch)
treec1cd45f6a8ab9988854168c63040c3f6011cb1dd /xmake/rules/xcode/bundle/xmake.lua
parentd656204be63f729a9e7b60f509af1fc3450726cc (diff)
add xcode.bundle rule
Diffstat (limited to 'xmake/rules/xcode/bundle/xmake.lua')
-rw-r--r--xmake/rules/xcode/bundle/xmake.lua55
1 files changed, 55 insertions, 0 deletions
diff --git a/xmake/rules/xcode/bundle/xmake.lua b/xmake/rules/xcode/bundle/xmake.lua
index e3b146c69..2e486cffd 100644
--- a/xmake/rules/xcode/bundle/xmake.lua
+++ b/xmake/rules/xcode/bundle/xmake.lua
@@ -23,6 +23,61 @@ rule("xcode.bundle")
-- we must set kind before target.on_load(), may we will use target in on_load()
before_load(function (target)
+
+ -- get bundle directory
+ local targetdir = target:targetdir()
+ local bundledir = path.join(targetdir, target:basename() .. ".bundle")
+ target:data_set("xcode.bundledir", bundledir)
+
+ -- set target info for bundle
target:set("kind", "shared")
+ target:set("filename", target:basename())
+ target:set("targetdir", path.join(bundledir, "Contents", "MacOS"))
+
+ -- register clean files for `xmake clean`
+ target:add("cleanfiles", bundledir)
end)
+ after_build(function (target)
+
+ -- imports
+ import("private.tools.codesign")
+
+ -- get bundle directory
+ local bundledir = path.absolute(target:data("xcode.bundledir"))
+
+ -- copy resource files to the content directory
+ local srcfiles, dstfiles = target:installfiles(path.join(bundledir, "Contents"))
+ if srcfiles and dstfiles then
+ local i = 1
+ for _, srcfile in ipairs(srcfiles) do
+ local dstfile = dstfiles[i]
+ if dstfile then
+ os.vcp(srcfile, dstfile)
+ end
+ i = i + 1
+ end
+ end
+
+ -- do codesign
+ codesign(bundledir)
+ end)
+
+ on_install(function (target)
+ local bundledir = path.absolute(target:data("xcode.bundledir"))
+ local installdir = target:installdir()
+ if not os.isdir(installdir) then
+ os.mkdir(installdir)
+ end
+ os.vcp(bundledir, installdir)
+ end)
+
+ on_uninstall(function (target)
+ local bundledir = path.absolute(target:data("xcode.bundledir"))
+ local installdir = target:installdir()
+ os.tryrm(path.join(installdir, path.filename(bundledir)))
+ end)
+
+ -- disable package
+ on_package(function (target) end)
+