summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAkaps316 <[email protected]>2026-04-12 19:40:20 +0530
committerruki <[email protected]>2026-04-20 09:35:36 +0800
commit7eada8439652626e484c0011a4ae536b916cc7fe (patch)
treeff7141a877441ceda06d55c2b30e72f5d9435803
parent0c36a9b4acb9150c607b3d70291ad50148785038 (diff)
fix(depgraph): use direct deps and align print output with JSON
- Switch from target:orderdeps() to target:get('deps') to show only direct dependencies declared via add_deps(), not transitive ones - Print output now shows all fields: root targets, name, kind, group, default, and deps — matching the JSON structure - Add kind assertion to test
-rw-r--r--tests/projects/plugins/show/depgraph/test.lua1
-rw-r--r--xmake/plugins/show/info/depgraph.lua18
2 files changed, 16 insertions, 3 deletions
diff --git a/tests/projects/plugins/show/depgraph/test.lua b/tests/projects/plugins/show/depgraph/test.lua
index 28ae7c188..229e715de 100644
--- a/tests/projects/plugins/show/depgraph/test.lua
+++ b/tests/projects/plugins/show/depgraph/test.lua
@@ -12,6 +12,7 @@ function test_depgraph_json(t)
entries[target.name] = target
end
t:are_equal(entries.core.deps, {})
+ t:are_equal(entries.core.kind, "static")
t:are_equal(entries.ui.deps, {"core"})
t:are_equal(entries.app.deps, {"core", "ui"})
t:are_equal(entries.app.kind, "binary")
diff --git a/xmake/plugins/show/info/depgraph.lua b/xmake/plugins/show/info/depgraph.lua
index 1f3142309..0807d865a 100644
--- a/xmake/plugins/show/info/depgraph.lua
+++ b/xmake/plugins/show/info/depgraph.lua
@@ -27,8 +27,11 @@ import("private.detect.check_targetname")
function _collect_target_entry(target)
local deps = {}
- for _, dep in ipairs(target:orderdeps() or {}) do
- table.insert(deps, dep:name())
+ local plain_deps = target:get("deps")
+ if plain_deps then
+ for _, dep in ipairs(plain_deps) do
+ table.insert(deps, dep)
+ end
end
return {
@@ -86,9 +89,18 @@ end
function _print_target_graph(graph)
print("The dependency graph of targets:")
+ cprint("")
+ cprint(" ${color.dump.string}root targets${clear}: %s", table.concat(graph.root_targets, ", "))
+ cprint("")
for _, target in ipairs(graph.targets) do
local deps = #target.deps > 0 and table.concat(target.deps, ", ") or "(none)"
- cprint(" ${color.dump.string}%s${clear}: %s", target.name, deps)
+ cprint(" ${color.dump.string}%s${clear}:", target.name)
+ cprint(" ${dim}kind${clear}: %s", target.kind)
+ if target.group then
+ cprint(" ${dim}group${clear}: %s", target.group)
+ end
+ cprint(" ${dim}default${clear}: %s", tostring(target.default))
+ cprint(" ${dim}deps${clear}: %s", deps)
end
end