From 7eada8439652626e484c0011a4ae536b916cc7fe Mon Sep 17 00:00:00 2001 From: Akaps316 <48785708+Akaps316@users.noreply.github.com> Date: Sun, 12 Apr 2026 19:40:20 +0530 Subject: fix(depgraph): use direct deps and align print output with JSON MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 --- tests/projects/plugins/show/depgraph/test.lua | 1 + xmake/plugins/show/info/depgraph.lua | 18 +++++++++++++++--- 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 -- cgit v1.3.1