Skip to content

Commit 02a69e7

Browse files
committed
improve to clean targets
1 parent b84cea0 commit 02a69e7

2 files changed

Lines changed: 12 additions & 7 deletions

File tree

xmake/actions/clean/main.lua

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ import("core.platform.platform")
2929
import("private.action.clean.remove_files")
3030
import("target.action.clean", {alias = "_do_clean_target"})
3131
import("private.service.remote_build.action", {alias = "remote_build_action"})
32-
import("private.detect.check_targetnames")
3332
import("private.action.utils", {alias = "action_utils"})
3433

3534
-- on clean target
@@ -105,10 +104,11 @@ function _clean_targets(targets)
105104
end
106105

107106
-- clean targets
108-
function _clean(targetnames)
109-
if targetnames and #targetnames > 0 then
110-
_clean_targets(assert(check_targetnames(targetnames)))
107+
function _clean(targetnames, group_pattern)
108+
if (targetnames and #targetnames > 0) or group_pattern then
109+
_clean_targets(action_utils.get_targets(targetnames, {group_pattern = group_pattern}))
111110
else
111+
-- clean all targets by default
112112
_clean_targets(project.ordertargets())
113113
end
114114
end
@@ -163,14 +163,14 @@ function main()
163163
-- lock the whole project
164164
project.lock()
165165

166-
-- get the target names
167-
local targetnames = action_utils.get_targets_and_group()
166+
-- get the target names and group pattern
167+
local targetnames, group_pattern = action_utils.get_targets_and_group()
168168

169169
-- enter project directory
170170
local oldir = os.cd(project.directory())
171171

172172
-- clean targets
173-
_clean(targetnames)
173+
_clean(targetnames, group_pattern)
174174

175175
-- unlock the whole project
176176
project.unlock()

xmake/actions/clean/xmake.lua

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ task("clean")
3030
, options =
3131
{
3232
{'a', "all", "k", nil , "Clean all auto-generated files by xmake." }
33+
, {'g', "group", "kv", nil , "Clean all targets of the given group. It support path pattern matching.",
34+
"e.g.",
35+
" xmake clean -g test",
36+
" xmake clean -g test_*",
37+
" xmake clean --group=benchmark/*" }
3338

3439
, {}
3540
, {nil, "targets", "vs", nil , "The target names. It will clean all default targets if this parameter is not specified.",

0 commit comments

Comments
 (0)