summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-06-18 22:07:05 +0800
committerruki <[email protected]>2026-06-18 22:07:05 +0800
commitb84cea0adc1541444643d65d95061485763b208a (patch)
tree87db85af5976b14e3b84a75e65d23a2e8a064c49
parent43a4e2c277d003251f476e8aa5b2f0efbe2f3ae7 (diff)
remove deduplicated targets
-rw-r--r--xmake/actions/install/install.lua2
-rw-r--r--xmake/actions/uninstall/main.lua7
-rw-r--r--xmake/actions/uninstall/uninstall.lua2
-rw-r--r--xmake/actions/uninstall/uninstall_admin.lua7
-rw-r--r--xmake/modules/private/action/utils.lua27
5 files changed, 26 insertions, 19 deletions
diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua
index 95b774d58..97db58f09 100644
--- a/xmake/actions/install/install.lua
+++ b/xmake/actions/install/install.lua
@@ -118,6 +118,6 @@ end
function main(targetnames, group_pattern)
local targets = action_utils.get_targets(targetnames, {group_pattern = group_pattern})
if #targets > 0 then
- _install_targets(table.unique(targets))
+ _install_targets(targets)
end
end
diff --git a/xmake/actions/uninstall/main.lua b/xmake/actions/uninstall/main.lua
index 840f12450..e8ef87035 100644
--- a/xmake/actions/uninstall/main.lua
+++ b/xmake/actions/uninstall/main.lua
@@ -32,12 +32,12 @@ function main()
-- load config first
task.run("config", {require = false}, {disable_dump = true})
- -- attempt to uninstall directly, TODO group_pattern
+ -- attempt to uninstall directly
local targetnames, group_pattern = action_utils.get_targets_and_group()
try
{
function ()
- uninstall(targetnames)
+ uninstall(targetnames, group_pattern)
cprint("${color.success}uninstall ok!")
end,
@@ -51,7 +51,7 @@ function main()
local ok = try
{
function ()
- uninstall(targetnames)
+ uninstall(targetnames, group_pattern)
cprint("${color.success}uninstall ok!")
return true
end
@@ -71,6 +71,7 @@ function main()
-- uninstall target with administrator permission
sudo.execl(path.join(os.scriptdir(), "uninstall_admin.lua"), {
targetnames and table.concat(targetnames, path.envsep()) or "__all",
+ group_pattern or "",
option.get("installdir") or "",
option.get("bindir"),
option.get("libdir"),
diff --git a/xmake/actions/uninstall/uninstall.lua b/xmake/actions/uninstall/uninstall.lua
index e5ccc6cbd..a5ac53cb9 100644
--- a/xmake/actions/uninstall/uninstall.lua
+++ b/xmake/actions/uninstall/uninstall.lua
@@ -113,6 +113,6 @@ end
function main(targetnames, group_pattern)
local targets = action_utils.get_targets(targetnames, {group_pattern = group_pattern})
if #targets > 0 then
- _uninstall_targets(table.unique(targets))
+ _uninstall_targets(targets)
end
end
diff --git a/xmake/actions/uninstall/uninstall_admin.lua b/xmake/actions/uninstall/uninstall_admin.lua
index 9c6bd4a53..ce036ec19 100644
--- a/xmake/actions/uninstall/uninstall_admin.lua
+++ b/xmake/actions/uninstall/uninstall_admin.lua
@@ -25,13 +25,16 @@ import("core.project.project")
import("core.platform.platform")
import("uninstall")
-function main(targetname, installdir, bindir, libdir, includedir)
+function main(targetname, group_pattern, installdir, bindir, libdir, includedir)
local verbose = option.get("verbose")
-- the targetname may be a list of target names joined with the path separator
if targetname and targetname:find(path.envsep(), 1, true) then
targetname = path.splitenv(targetname)
end
+ if group_pattern and #group_pattern == 0 then
+ group_pattern = nil
+ end
if installdir and #installdir == 0 then
installdir = nil
end
@@ -65,6 +68,6 @@ function main(targetname, installdir, bindir, libdir, includedir)
option.set("includedir", includedir)
end
-- uninstall target
- uninstall(targetname ~= "__all" and targetname or nil)
+ uninstall(targetname ~= "__all" and targetname or nil, group_pattern)
option.restore()
end
diff --git a/xmake/modules/private/action/utils.lua b/xmake/modules/private/action/utils.lua
index 39045d204..5b83a522b 100644
--- a/xmake/modules/private/action/utils.lua
+++ b/xmake/modules/private/action/utils.lua
@@ -75,19 +75,22 @@ function get_targets(targetnames, opt)
opt = opt or {}
-- select the explicitly given targets (table.wrap to always get a list back)
+ local targets
if type(targetnames) == "table" or (type(targetnames) == "string" and not targetnames:startswith("__")) then
- return assert(check_targetnames(table.wrap(targetnames)))
- end
-
- -- otherwise select the default/all/group targets
- local targets = {}
- local all = opt.all or targetnames == "__all" or option.get("all")
- local group_pattern = opt.group_pattern
- for _, target in ipairs(project.ordertargets()) do
- local group = target:get("group")
- if (target:is_default() and not group_pattern) or all or (group_pattern and group and group:match(group_pattern)) then
- table.insert(targets, target)
+ targets = assert(check_targetnames(table.wrap(targetnames)))
+ else
+ -- otherwise select the default/all/group targets
+ targets = {}
+ local all = opt.all or targetnames == "__all" or option.get("all")
+ local group_pattern = opt.group_pattern
+ for _, target in ipairs(project.ordertargets()) do
+ local group = target:get("group")
+ if (target:is_default() and not group_pattern) or all or (group_pattern and group and group:match(group_pattern)) then
+ table.insert(targets, target)
+ end
end
end
- return targets
+
+ -- remove duplicates, e.g. the same target name may be given more than once
+ return table.unique(targets)
end