diff options
| author | ruki <[email protected]> | 2024-03-27 16:10:49 +0800 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-03-27 16:10:49 +0800 |
| commit | 63915e436cd859c0ef6fe9b281b441d6129b2fbb (patch) | |
| tree | 6ef608387d365f56097358885b999d93a3e73144 | |
| parent | 85d1f75b4bb592aef26c7bd6ec3205d077628f7f (diff) | |
| parent | 62510bda9ec1d1177edbdd7d42920d17947e29b5 (diff) | |
Merge pull request #4885 from xmake-io/install
Improve to install with group #4882
| -rw-r--r-- | xmake/actions/install/install.lua | 14 | ||||
| -rw-r--r-- | xmake/actions/uninstall/uninstall.lua | 19 | ||||
| -rw-r--r-- | xmake/actions/uninstall/xmake.lua | 5 |
3 files changed, 26 insertions, 12 deletions
diff --git a/xmake/actions/install/install.lua b/xmake/actions/install/install.lua index 4b100a8e2..ae9857ed3 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 8ce5346a6..5aade0313 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 36814bcd7..30d87f498 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", |
