summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorlonless9 <[email protected]>2025-06-04 15:54:13 +0800
committerlonless9 <[email protected]>2025-06-04 16:01:40 +0800
commit95e86b5524b4752d9d29e39ff4c17e8f5a3ba844 (patch)
tree51765ab8bbc7eecfc66c567456a3692fb5d8b337
parent6989184ed0b7e61614d3f41bdbcdac4c6075ac77 (diff)
adds target group filtering to `show targets`
-rw-r--r--xmake/plugins/show/lists/targets.lua28
-rw-r--r--xmake/plugins/show/xmake.lua1
2 files changed, 26 insertions, 3 deletions
diff --git a/xmake/plugins/show/lists/targets.lua b/xmake/plugins/show/lists/targets.lua
index 50507aa1b..a5244e9c7 100644
--- a/xmake/plugins/show/lists/targets.lua
+++ b/xmake/plugins/show/lists/targets.lua
@@ -19,17 +19,39 @@
--
-- imports
+import("core.base.option")
import("core.project.config")
import("core.project.project")
import("core.platform.platform")
import(".showlist")
--- show all platforms
+-- show all targets (optionally filtered by group)
function main()
config.load()
+
+ local group_filter = option.get("group")
local targets = {}
- for name, _ in pairs(project.targets()) do
- table.insert(targets, name)
+
+ if not group_filter then
+ for name, _ in pairs(project.targets()) do
+ 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)
end
diff --git a/xmake/plugins/show/xmake.lua b/xmake/plugins/show/xmake.lua
index bae15471c..33fb51635 100644
--- a/xmake/plugins/show/xmake.lua
+++ b/xmake/plugins/show/xmake.lua
@@ -29,6 +29,7 @@ task("show")
values = function (complete, opt)
return import("list").lists()
end},
+ {'g', "group", "kv", nil, "Filter targets by the given group name."},
{nil, "json", "k", false, "Show information with json format."},
{'t', "target", "kv", nil, "Show the information of the given target.",
values = function (complete, opt)