From eba4c503ccaf873a87ec1f867ba3dffd98b45800 Mon Sep 17 00:00:00 2001 From: ruki Date: Wed, 26 Nov 2025 22:35:21 +0800 Subject: improve app/on_installcmd --- xmake/plugins/pack/batchcmds.lua | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'xmake/plugins/pack/batchcmds.lua') 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, -- cgit v1.3.1