diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua index 4b100a8e2f1..ae9857ed39d 100644 --- a/xmake/actions/install/install.lua +++ b/xmake/actions/install/install.lua @@ -107,19 +107,21 @@ end -- install targets function main(targetname, group_pattern) - - -- install the given target? + local targets = {} if targetname and not targetname:startswith("__") then local target = project.target(targetname) - _install_targets(target:orderdeps()) - _install_target(target) + table.join2(targets, target:orderdeps()) + table.insert(targets, target) else - -- install default or all targets for _, target in ipairs(project.ordertargets()) do local group = target:get("group") if (target:is_default() and not group_pattern) or targetname == "__all" or (group_pattern and group and group:match(group_pattern)) then - _install_target(target) + table.join2(targets, target:orderdeps()) + table.insert(targets, target) end end end + if #targets > 0 then + _install_targets(table.unique(targets)) + end end diff --git a/xmake/actions/uninstall/uninstall.lua b/xmake/actions/uninstall/uninstall.lua index 8ce5346a65d..5aade031372 100644 --- a/xmake/actions/uninstall/uninstall.lua +++ b/xmake/actions/uninstall/uninstall.lua @@ -107,14 +107,21 @@ end -- uninstall function main(targetname) - - -- uninstall the given target? + local targets = {} if targetname and not targetname:startswith("__") then local target = project.target(targetname) - _uninstall_targets(target:orderdeps()) - _uninstall_target(target) + table.join2(targets, target:orderdeps()) + table.insert(targets, target) else - -- uninstall all targets - _uninstall_targets(project.ordertargets()) + for _, target in ipairs(project.ordertargets()) do + local group = target:get("group") + if (target:is_default() and not group_pattern) or targetname == "__all" or (group_pattern and group and group:match(group_pattern)) then + table.join2(targets, target:orderdeps()) + table.insert(targets, target) + end + end + end + if #targets > 0 then + _uninstall_targets(table.unique(targets)) end end diff --git a/xmake/actions/uninstall/xmake.lua b/xmake/actions/uninstall/xmake.lua index 36814bcd7ce..30d87f49885 100644 --- a/xmake/actions/uninstall/xmake.lua +++ b/xmake/actions/uninstall/xmake.lua @@ -46,6 +46,11 @@ task("uninstall") " $ xmake uninstall -o /usr/local", "or $ DESTDIR=/usr/local xmake uninstall", "or $ INSTALLDIR=/usr/local xmake uninstall" } + , {'g', "group", "kv", nil , "Uninstall all targets of the given group. It support path pattern matching.", + "e.g.", + " xmake uninstall -g test", + " xmake uninstall -g test_*", + " xmake uninstall --group=benchmark/*" } , {'p', "prefix", "kv", nil , "Set the prefix directory.", "e.g.", " $ xmake uninstall --prefix=local",