summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonless9 <[email protected]>2025-06-05 14:43:34 +0800
committerlonless9 <[email protected]>2025-06-05 14:43:34 +0800
commit5c39da6e7dce986e0e2c2d09d2f1ef2fd23ce435 (patch)
treec52904bc36292f53be737ddfecc22653ec5145af
parent95e86b5524b4752d9d29e39ff4c17e8f5a3ba844 (diff)
fix pattern
-rw-r--r--xmake/plugins/show/lists/targets.lua29
1 files changed, 11 insertions, 18 deletions
diff --git a/xmake/plugins/show/lists/targets.lua b/xmake/plugins/show/lists/targets.lua
index a5244e9c7..ce398fc77 100644
--- a/xmake/plugins/show/lists/targets.lua
+++ b/xmake/plugins/show/lists/targets.lua
@@ -29,28 +29,21 @@ import(".showlist")
function main()
config.load()
- local group_filter = option.get("group")
+ local group_pattern = option.get("group")
+ if group_pattern then
+ group_pattern = "^" .. path.pattern(group_pattern) .. "$"
+ end
local targets = {}
- if not group_filter then
- for name, _ in pairs(project.targets()) do
+ for name, target in pairs(project.targets()) do
+ local group = target:get("group")
+ if (target:is_default() and not group_pattern) or
+ (group_pattern and group and (group:match(group_pattern) or
+ table.find_first_if(group:split("[/\\]"), function(i, component)
+ return component:match(group_pattern)
+ end))) then
table.insert(targets, name)
end
- else
-
- local normalized_filter = path.normalize(group_filter)
- local filter_prefix = normalized_filter .. "/"
-
- for name, target in pairs(project.targets()) do
- local target_group = target:get("group")
- if target_group then
- local normalized_target_group = path.normalize(target_group)
- if normalized_target_group == normalized_filter or
- normalized_target_group:startswith(filter_prefix) then
- table.insert(targets, name)
- end
- end
- end
end
showlist(targets)