mirror of
git://git.yoctoproject.org/poky.git
synced 2025-07-19 03:49:07 +02:00
graph-tool: add filter subcommand
Add a filter subcommand to filter a task-depends.dot graph produced by bitbake -g down to just a subset of targets/tasks. (From OE-Core rev: a14b274b56676ff0ba55a4048169ad60c9514994) Signed-off-by: Paul Eggleton <paul.eggleton@linux.microsoft.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
parent
8f7c45c183
commit
b87f0746b0
|
@ -50,6 +50,40 @@ def find_paths(args):
|
||||||
return 1
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def filter_graph(args):
|
||||||
|
import fnmatch
|
||||||
|
|
||||||
|
exclude_tasks = []
|
||||||
|
if args.exclude_tasks:
|
||||||
|
for task in args.exclude_tasks.split(','):
|
||||||
|
if not task.startswith('do_'):
|
||||||
|
task = 'do_%s' % task
|
||||||
|
exclude_tasks.append(task)
|
||||||
|
|
||||||
|
def checkref(strval):
|
||||||
|
strval = strval.strip().strip('"')
|
||||||
|
target, taskname = strval.rsplit('.', 1)
|
||||||
|
if exclude_tasks:
|
||||||
|
for extask in exclude_tasks:
|
||||||
|
if fnmatch.fnmatch(taskname, extask):
|
||||||
|
return False
|
||||||
|
if strval in args.ref or target in args.ref:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
with open(args.infile, 'r') as f:
|
||||||
|
for line in f:
|
||||||
|
line = line.rstrip()
|
||||||
|
if line.startswith(('digraph', '}')):
|
||||||
|
print(line)
|
||||||
|
elif '->' in line:
|
||||||
|
linesplit = line.split('->')
|
||||||
|
if checkref(linesplit[0]) and checkref(linesplit[1]):
|
||||||
|
print(line)
|
||||||
|
elif (not args.no_nodes) and checkref(line.split()[0]):
|
||||||
|
print(line)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse_oe.ArgumentParser(description='Small utility for working with .dot graph files')
|
parser = argparse_oe.ArgumentParser(description='Small utility for working with .dot graph files')
|
||||||
|
|
||||||
|
@ -64,6 +98,15 @@ def main():
|
||||||
parser_find_paths.add_argument('tonode', help='ending node name')
|
parser_find_paths.add_argument('tonode', help='ending node name')
|
||||||
parser_find_paths.set_defaults(func=find_paths)
|
parser_find_paths.set_defaults(func=find_paths)
|
||||||
|
|
||||||
|
parser_filter = subparsers.add_parser('filter',
|
||||||
|
help='Pare down a task graph to contain only the specified references',
|
||||||
|
description='Pares down a task-depends.dot graph produced by bitbake -g to contain only the specified references')
|
||||||
|
parser_filter.add_argument('infile', help='Input file')
|
||||||
|
parser_filter.add_argument('ref', nargs='+', help='Reference to include (either recipe/target name or full target.taskname specification)')
|
||||||
|
parser_filter.add_argument('-n', '--no-nodes', action='store_true', help='Skip node formatting lines')
|
||||||
|
parser_filter.add_argument('-x', '--exclude-tasks', help='Comma-separated list of tasks to exclude (do_ prefix optional, wildcards allowed)')
|
||||||
|
parser_filter.set_defaults(func=filter_graph)
|
||||||
|
|
||||||
args = parser.parse_args()
|
args = parser.parse_args()
|
||||||
|
|
||||||
ret = args.func(args)
|
ret = args.func(args)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user