From 145c8946bb75cf4064f9b4ca295e4562e693ba12 Mon Sep 17 00:00:00 2001
From: A2va <49582555+A2va@users.noreply.github.com>
Date: Tue, 19 Mar 2024 22:58:43 +0100
Subject: Support others cmds
---
xmake/plugins/pack/wix/main.lua | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/xmake/plugins/pack/wix/main.lua b/xmake/plugins/pack/wix/main.lua
index 466f58405..74b1abf4d 100644
--- a/xmake/plugins/pack/wix/main.lua
+++ b/xmake/plugins/pack/wix/main.lua
@@ -94,29 +94,27 @@ end
function _get_other_commands(package, cmd, opt)
opt = table.join(cmd.opt or {}, opt)
- local result = {}
+ local result = ""
local kind = cmd.kind
if kind == "rm" then
- local filepath = _translate_filepath(package, cmd.filepath)
- local subdirectory = cmd.filepath ~= package:install_rootdir() and string.format([[Subdirectory="%s"]], filepath) or ""
+ local subdirectory = _translate_filepath(package, path.directory(cmd.filepath))
+ subdirectory = subdirectory ~= "." and string.format([[Subdirectory="%s"]], subdirectory) or ""
local on = opt.install and [[On="install"]] or [[On="uninstall"]]
+ local filename = path.filename(cmd.filepath)
- local remove_file = string.format([[]], subdirectory, on)
- table.insert(result, remove_file)
+ result = string.format([[]], filename, subdirectory, on)
elseif kind == "rmdir" then
local dir = _translate_filepath(package, cmd.dir)
- local subdirectory = cmd.dir ~= package:install_rootdir() and string.format([[Subdirectory="%s"]], dir) or ""
+ local subdirectory = dir ~= "." and string.format([[Subdirectory="%s"]], dir) or ""
local on = opt.install and [[On="install"]] or [[On="uninstall"]]
- local remove_dir = string.format([[]], subdirectory, on)
- table.insert(result, remove_dir)
+ result = string.format([[]], subdirectory, on)
elseif kind == "mkdir" then
local dir = _translate_filepath(package, cmd.dir)
- local subdirectory = cmd.dir ~= package:install_rootdir() and string.format([[Subdirectory="%s"]], dir) or ""
- local make_dir = string.format([[]], subdirectory)
- table.insert(result, make_dir)
- else
+ local subdirectory = dir ~= "." and string.format([[Subdirectory="%s"]], dir) or ""
+ result = string.format([[]], subdirectory)
+ elseif kind ~= "cp" then
wprint("kind %s is not supported with wix", kind)
end
return result
@@ -127,13 +125,13 @@ function _get_feature_string(name, opt)
local description = opt.description or ""
local allow_absent = opt.force and "false" or "true"
local allow_advertise = opt.force and "false" or "true"
- local typical_default = opt.force and [[TypicalDefault=install"]] or ""
+ local typical_default = opt.force and [[TypicalDefault="install"]] or ""
local feature = string.format([[]], name, name, description, level, allow_advertise, allow_absent, typical_default)
return feature
end
function _get_component_string(id, subdirectory)
- local subdirectory = (subdirectory ~= ".") and string.format([[Subdirectory="%s"]], subdirectory) or ""
+ local subdirectory = (subdirectory ~= "." and subdirectory ~= nil) and string.format([[Subdirectory="%s"]], subdirectory) or ""
return string.format([[]], id, hash.uuid(id), subdirectory)
end
@@ -161,11 +159,18 @@ function _build_feature(package, opt)
end
table.insert(result, _get_component_string("OtherCmds"))
+ for _, cmd in ipairs(installcmds) do
+ table.insert(result, _get_other_commands(package, cmd, {install = true}))
+ end
+ for _, cmd in ipairs(uninstallcmds) do
+ table.insert(result, _get_other_commands(package, cmd, {install = false}))
+ end
+
table.insert(result, "")
-
table.insert(result, "")
return result
end
+
-- get specvars
function _get_specvars(package)
--
cgit v1.3.1