summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2025-11-28 22:38:15 +0800
committerruki <[email protected]>2025-11-28 22:38:15 +0800
commit574ee096281c94938eb396045f7e96a25df5387b (patch)
tree7ec3b6607d02a26fc5c3f148aa814d06b6a8b542
parent241d9b9ed100c437f5e659dfb626f4c037b92057 (diff)
fix uninstall files
-rw-r--r--xmake/rules/qt/uninstallcmd.lua34
1 files changed, 26 insertions, 8 deletions
diff --git a/xmake/rules/qt/uninstallcmd.lua b/xmake/rules/qt/uninstallcmd.lua
index 12ef3a345..cc989ce12 100644
--- a/xmake/rules/qt/uninstallcmd.lua
+++ b/xmake/rules/qt/uninstallcmd.lua
@@ -46,15 +46,33 @@ function main(target, batchcmds, opt)
-- Windows/Mingw: remove all deployed files and directories from install directory
local installdir = package:installdir()
- -- remove all files and directories deployed by windeployqt
- -- since we copied everything from deploydir to installdir, we need to remove them
- -- use os.filedirs to match all files and directories, then remove them
- for _, item in ipairs(os.filedirs(path.join(installdir, "*"))) do
- if os.isfile(item) then
- batchcmds:rm(item, {emptydirs = true})
- elseif os.isdir(item) then
- batchcmds:rmdir(item, {emptydirs = true})
+ -- use the same deploydir as installcmd to determine what files were installed
+ -- deploydir exists at build/pack time when uninstallcmd is called
+ local deploydir = path.join(target:autogendir(), "qt", "deploy", target:name())
+
+ -- if deploydir exists, use it to get the list of files/dirs to remove
+ if os.isdir(deploydir) then
+ -- match all files and directories in deploydir (same as installcmd)
+ for _, item in ipairs(os.filedirs(path.join(deploydir, "*"))) do
+ local relpath = path.relative(item, deploydir)
+ local dstpath = path.join(installdir, relpath)
+ if os.isfile(item) then
+ batchcmds:rm(dstpath, {emptydirs = true})
+ elseif os.isdir(item) then
+ batchcmds:rmdir(dstpath, {emptydirs = true})
+ end
+ end
+ else
+ -- fallback: if deploydir doesn't exist, remove common Qt deployment items
+ -- this should rarely happen, but provides a safety net
+ batchcmds:rm(path.join(installdir, target:filename()), {emptydirs = true})
+ for _, dep in ipairs(target:orderdeps()) do
+ if dep:rule("qt.shared") then
+ batchcmds:rm(path.join(installdir, path.filename(dep:targetfile())), {emptydirs = true})
+ end
end
+ -- note: we can't easily remove all deployed files without deploydir,
+ -- but at least we remove the main binaries
end
else
-- Linux: remove all files from bin directory