summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-26 22:35:21 +0800
committerruki <[email protected]>2025-11-26 22:35:21 +0800
commiteba4c503ccaf873a87ec1f867ba3dffd98b45800 (patch)
tree46f2b411563c64cafb5c30e74208258f57d0f6da
parentfe96cdcbaa858ebcec0935d42b3409487e05e511 (diff)
improve app/on_installcmd
-rw-r--r--xmake/plugins/pack/batchcmds.lua22
-rw-r--r--xmake/rules/xcode/application/installcmd.lua24
-rw-r--r--xmake/rules/xcode/application/xmake.lua2
3 files changed, 46 insertions, 2 deletions
diff --git a/xmake/plugins/pack/batchcmds.lua b/xmake/plugins/pack/batchcmds.lua
index b67d66b5b..09b42d7c9 100644
--- a/xmake/plugins/pack/batchcmds.lua
+++ b/xmake/plugins/pack/batchcmds.lua
@@ -334,6 +334,17 @@ function _on_target_installcmd(target, batchcmds_, opt)
return
end
+ -- check if target rules have on_installcmd, use rule's logic first
+ local done = false
+ for _, r in ipairs(target:orderules()) do
+ local on_installcmd = r:script("installcmd")
+ if on_installcmd then
+ on_installcmd(target, batchcmds_, opt)
+ done = true
+ end
+ end
+ if done then return end
+
-- install target binaries
local scripts = {
binary = _on_target_installcmd_binary,
@@ -416,6 +427,17 @@ function _on_target_uninstallcmd(target, batchcmds_, opt)
return
end
+ -- check if target rules have on_uninstallcmd, use rule's logic first
+ local done = false
+ for _, r in ipairs(target:orderules()) do
+ local on_uninstallcmd = r:script("uninstallcmd")
+ if on_uninstallcmd then
+ on_uninstallcmd(target, batchcmds_, opt)
+ done = true
+ end
+ end
+ if done then return end
+
-- uninstall target binaries
local scripts = {
binary = _on_target_uninstallcmd_binary,
diff --git a/xmake/rules/xcode/application/installcmd.lua b/xmake/rules/xcode/application/installcmd.lua
index 39d64ab1c..c08a0fede 100644
--- a/xmake/rules/xcode/application/installcmd.lua
+++ b/xmake/rules/xcode/application/installcmd.lua
@@ -22,11 +22,16 @@
function main(target, batchcmds, opt)
local package = opt.package
- -- only for macosx when packing dmg
+ -- only for macosx when packing
if not target:is_plat("macosx") then
return
end
+ -- only for xpack (package exists)
+ if not package then
+ return
+ end
+
-- get app directory
local appdir = target:data("xcode.bundle.rootdir")
if not appdir or not os.isdir(appdir) then
@@ -44,5 +49,22 @@ function main(target, batchcmds, opt)
local appname = path.filename(appdir)
local dstappdir = path.join(installdir, appname)
batchcmds:cp(appdir, dstappdir, {symlink = true})
+
+ -- install target files (skip binary installation)
+ local srcfiles, dstfiles = target:installfiles(installdir)
+ if srcfiles and dstfiles then
+ for idx, srcfile in ipairs(srcfiles) do
+ batchcmds:cp(srcfile, dstfiles[idx], {symlink = true})
+ end
+ end
+ -- install dependent target files
+ for _, dep in ipairs(target:orderdeps()) do
+ local srcfiles, dstfiles = dep:installfiles(installdir, {interface = true})
+ if srcfiles and dstfiles then
+ for idx, srcfile in ipairs(srcfiles) do
+ batchcmds:cp(srcfile, dstfiles[idx], {symlink = true})
+ end
+ end
+ end
end
diff --git a/xmake/rules/xcode/application/xmake.lua b/xmake/rules/xcode/application/xmake.lua
index d809261c5..8af79a585 100644
--- a/xmake/rules/xcode/application/xmake.lua
+++ b/xmake/rules/xcode/application/xmake.lua
@@ -37,7 +37,7 @@ rule("xcode.application")
on_install("install")
-- install application for xpack
- after_installcmd("installcmd")
+ on_installcmd("installcmd")
-- uninstall application
on_uninstall("uninstall")