diff options
Diffstat (limited to 'xmake/rules/xcode/application/xmake.lua')
| -rw-r--r-- | xmake/rules/xcode/application/xmake.lua | 68 |
1 files changed, 68 insertions, 0 deletions
diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua index 91ec7dbda..756d94d6c 100644 --- a/xmake/rules/xcode/application/xmake.lua +++ b/xmake/rules/xcode/application/xmake.lua @@ -23,6 +23,74 @@ rule("xcode.application") -- we must set kind before target.on_load(), may we will use target in on_load() before_load(function (target) + + -- get app directory + local targetdir = target:targetdir() + local appdir = path.join(targetdir, target:basename() .. ".app") + target:data_set("xcode.appdir", appdir) + + -- set target info for app target:set("kind", "binary") + target:set("filename", target:basename()) + if is_plat("macosx") then + target:set("targetdir", path.join(appdir, "Contents", "MacOS")) + else + target:set("targetdir", appdir) + end + + -- register clean files for `xmake clean` + target:add("cleanfiles", appdir) end) + after_build(function (target) + + -- imports + import("private.tools.codesign") + + -- get app directory + local appdir = path.absolute(target:data("xcode.appdir")) + + -- get contents directory + local contentsdir = appdir + if is_plat("macosx") then + contentsdir = path.join(appdir, "Contents") + end + + -- copy PkgInfo to the contents directory + os.cp(path.join(os.programdir(), "scripts", "PkgInfo"), contentsdir) + + -- copy resource files to the contents directory + local srcfiles, dstfiles = target:installfiles(contentsdir) + 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(appdir) + end) + + on_install(function (target) + local appdir = path.absolute(target:data("xcode.appdir")) + local installdir = target:installdir() + if not os.isdir(installdir) then + os.mkdir(installdir) + end + os.vcp(appdir, installdir) + end) + + on_uninstall(function (target) + local appdir = path.absolute(target:data("xcode.appdir")) + local installdir = target:installdir() + os.tryrm(path.join(installdir, path.filename(appdir))) + end) + + -- disable package + on_package(function (target) end) + |
