summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2026-06-18 22:09:00 +0800
committerruki <[email protected]>2026-06-18 22:09:00 +0800
commit02a69e7a3e0442a750c33eae77dc5feb2e5ff655 (patch)
tree337586fdbc65cf15d539be45899fb8c61020ef62
parentb84cea0adc1541444643d65d95061485763b208a (diff)
improve to clean targets
-rw-r--r--xmake/actions/clean/main.lua14
-rw-r--r--xmake/actions/clean/xmake.lua5
2 files changed, 12 insertions, 7 deletions
diff --git a/xmake/actions/clean/main.lua b/xmake/actions/clean/main.lua
index ba30ccb77..6606ddc2f 100644
--- a/xmake/actions/clean/main.lua
+++ b/xmake/actions/clean/main.lua
@@ -29,7 +29,6 @@ import("core.platform.platform")
import("private.action.clean.remove_files")
import("target.action.clean", {alias = "_do_clean_target"})
import("private.service.remote_build.action", {alias = "remote_build_action"})
-import("private.detect.check_targetnames")
import("private.action.utils", {alias = "action_utils"})
-- on clean target
@@ -105,10 +104,11 @@ function _clean_targets(targets)
end
-- clean targets
-function _clean(targetnames)
- if targetnames and #targetnames > 0 then
- _clean_targets(assert(check_targetnames(targetnames)))
+function _clean(targetnames, group_pattern)
+ if (targetnames and #targetnames > 0) or group_pattern then
+ _clean_targets(action_utils.get_targets(targetnames, {group_pattern = group_pattern}))
else
+ -- clean all targets by default
_clean_targets(project.ordertargets())
end
end
@@ -163,14 +163,14 @@ function main()
-- lock the whole project
project.lock()
- -- get the target names
- local targetnames = action_utils.get_targets_and_group()
+ -- get the target names and group pattern
+ local targetnames, group_pattern = action_utils.get_targets_and_group()
-- enter project directory
local oldir = os.cd(project.directory())
-- clean targets
- _clean(targetnames)
+ _clean(targetnames, group_pattern)
-- unlock the whole project
project.unlock()
diff --git a/xmake/actions/clean/xmake.lua b/xmake/actions/clean/xmake.lua
index b2968e118..980ee2b28 100644
--- a/xmake/actions/clean/xmake.lua
+++ b/xmake/actions/clean/xmake.lua
@@ -30,6 +30,11 @@ task("clean")
, options =
{
{'a', "all", "k", nil , "Clean all auto-generated files by xmake." }
+ , {'g', "group", "kv", nil , "Clean all targets of the given group. It support path pattern matching.",
+ "e.g.",
+ " xmake clean -g test",
+ " xmake clean -g test_*",
+ " xmake clean --group=benchmark/*" }
, {}
, {nil, "targets", "vs", nil , "The target names. It will clean all default targets if this parameter is not specified.",