diff options
| author | ruki <[email protected]> | 2023-11-15 00:43:52 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2023-11-15 00:43:52 +0800 |
| commit | 232d49f245224019a5c69a17702a3c3ad15d467e (patch) | |
| tree | 4bcf5c02f3108c98b85b2253bb2008e4652fafc4 /xmake/plugins/pack/nsis/main.lua | |
| parent | 6e6b5bb6959d2e0f6b393d881170b3a0eb81fe9d (diff) | |
add tryrm for nsis
Diffstat (limited to 'xmake/plugins/pack/nsis/main.lua')
| -rw-r--r-- | xmake/plugins/pack/nsis/main.lua | 28 |
1 files changed, 21 insertions, 7 deletions
diff --git a/xmake/plugins/pack/nsis/main.lua b/xmake/plugins/pack/nsis/main.lua index 5acb3c055..e0df55ccf 100644 --- a/xmake/plugins/pack/nsis/main.lua +++ b/xmake/plugins/pack/nsis/main.lua @@ -83,6 +83,21 @@ function _get_command_strings(package, cmd) elseif kind == "rm" then local filepath = path.normalize(path.join("$INSTDIR", cmd.filepath)) table.insert(result, string.format("Delete \"%s\"", filepath)) + elseif kind == "tryrm" then + --[[ + IfFileExists "$InstDir\file" file_found file_not_found_or_end + file_found: + Delete "$InstDir\file" + goto file_not_found_or_end + file_not_found_or_end: + --]] + local filepath = path.normalize(path.join("$INSTDIR", cmd.filepath)) + local tag = hash.uuid(filepath):split("-", {plain = true})[1]:lower() + table.insert(result, string.format("IfFileExists \"%s\" file_found_%s file_not_found_or_end_%s", filepath, tag, tag)) + table.insert(result, string.format("file_found_%s:", tag)) + table.insert(result, string.format(" Delete \"%s\"", filepath)) + table.insert(result, string.format(" goto file_not_found_or_end_%s", tag)) + table.insert(result, string.format("file_not_found_or_end_%s:", tag)) elseif kind == "rmdir" then local dir = path.normalize(path.join("$INSTDIR", cmd.dir)) table.insert(result, string.format("RMDir /r \"%s\"", dir)) @@ -180,8 +195,7 @@ function _on_target_uninstallcmd_binary(target, batchcmds_, opt) -- uninstall target file batchcmds_:rm(path.join(bindir, target:filename())) - - -- TODO: tryrm symbolfile + batchcmds_:tryrm(path.join(bindir, path.filename(target:symbolfile()))) end -- on uninstall shared target command @@ -191,24 +205,24 @@ function _on_target_uninstallcmd_shared(target, batchcmds_, opt) -- uninstall target file batchcmds_:rm(path.join(bindir, target:filename())) + batchcmds_:tryrm(path.join(bindir, path.filename(target:symbolfile()))) end -- on uninstall static target command function _on_target_uninstallcmd_static(target, batchcmds_, opt) local package = opt.package - local bindir = package:bindir() + local libdir = package:libdir() -- uninstall target file - batchcmds_:rm(path.join(bindir, target:filename())) + batchcmds_:rm(path.join(libdir, target:filename())) + batchcmds_:tryrm(path.join(libdir, path.filename(target:symbolfile()))) end -- on uninstall headeronly target command function _on_target_uninstallcmd_headeronly(target, batchcmds_, opt) local package = opt.package - local bindir = package:bindir() + local includedir = package:includedir() - -- uninstall target file - batchcmds_:rm(path.join(bindir, target:filename())) end -- on uninstall target command |
