Add --depth and --reverse to soongdbg deps
Test: use the flags Change-Id: If7edacae672eca974978cc211d6e385d5038bcc2
This commit is contained in:
parent
04b63b1870
commit
2816c97d23
1 changed files with 9 additions and 4 deletions
13
bin/soongdbg
13
bin/soongdbg
|
@ -259,12 +259,13 @@ def print_nodes(args, nodes, module_formatter):
|
||||||
sys.stdout.write(text)
|
sys.stdout.write(text)
|
||||||
|
|
||||||
|
|
||||||
def get_deps(nodes, root):
|
def get_deps(nodes, root, maxdepth, reverse):
|
||||||
if root in nodes:
|
if root in nodes:
|
||||||
return
|
return
|
||||||
nodes.add(root)
|
nodes.add(root)
|
||||||
for dep in root.deps:
|
if maxdepth != 0:
|
||||||
get_deps(nodes, dep)
|
for dep in (root.rdeps if reverse else root.deps):
|
||||||
|
get_deps(nodes, dep, maxdepth-1, reverse)
|
||||||
|
|
||||||
|
|
||||||
def new_module_formatter(args):
|
def new_module_formatter(args):
|
||||||
|
@ -311,6 +312,10 @@ class DepsCommand:
|
||||||
def args(self, parser):
|
def args(self, parser):
|
||||||
parser.add_argument("module", nargs="+",
|
parser.add_argument("module", nargs="+",
|
||||||
help="Module to print dependencies of")
|
help="Module to print dependencies of")
|
||||||
|
parser.add_argument("--reverse", action="store_true",
|
||||||
|
help="traverse reverse dependencies")
|
||||||
|
parser.add_argument("--depth", type=int, default=-1,
|
||||||
|
help="max depth of dependencies (can keep the graph size reasonable)")
|
||||||
print_args(parser)
|
print_args(parser)
|
||||||
|
|
||||||
def run(self, args):
|
def run(self, args):
|
||||||
|
@ -323,7 +328,7 @@ class DepsCommand:
|
||||||
sys.stderr.write(f"error: Can't find root: {id}\n")
|
sys.stderr.write(f"error: Can't find root: {id}\n")
|
||||||
err = True
|
err = True
|
||||||
continue
|
continue
|
||||||
get_deps(nodes, root)
|
get_deps(nodes, root, args.depth, args.reverse)
|
||||||
if err:
|
if err:
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
print_nodes(args, nodes, new_module_formatter(args))
|
print_nodes(args, nodes, new_module_formatter(args))
|
||||||
|
|
Loading…
Reference in a new issue