summaryrefslogtreecommitdiffstats
path: root/scripts/contrib
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.microsoft.com>2020-06-14 21:48:43 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2020-06-16 23:39:28 +0100
commitb87f0746b01c079eab5fba81e2f9580dba75835e (patch)
treeda9e66d25fd44855a7d329bf89ba198bc7933513 /scripts/contrib
parent8f7c45c183e3d9ec15feb507cd923dea85b34f47 (diff)
downloadpoky-b87f0746b01c079eab5fba81e2f9580dba75835e.tar.gz
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>
Diffstat (limited to 'scripts/contrib')
-rwxr-xr-xscripts/contrib/graph-tool43
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/contrib/graph-tool b/scripts/contrib/graph-tool
index 9402e617e9..26488930e0 100755
--- a/scripts/contrib/graph-tool
+++ b/scripts/contrib/graph-tool
@@ -50,6 +50,40 @@ def find_paths(args):
50 return 1 50 return 1
51 51
52 52
53def filter_graph(args):
54 import fnmatch
55
56 exclude_tasks = []
57 if args.exclude_tasks:
58 for task in args.exclude_tasks.split(','):
59 if not task.startswith('do_'):
60 task = 'do_%s' % task
61 exclude_tasks.append(task)
62
63 def checkref(strval):
64 strval = strval.strip().strip('"')
65 target, taskname = strval.rsplit('.', 1)
66 if exclude_tasks:
67 for extask in exclude_tasks:
68 if fnmatch.fnmatch(taskname, extask):
69 return False
70 if strval in args.ref or target in args.ref:
71 return True
72 return False
73
74 with open(args.infile, 'r') as f:
75 for line in f:
76 line = line.rstrip()
77 if line.startswith(('digraph', '}')):
78 print(line)
79 elif '->' in line:
80 linesplit = line.split('->')
81 if checkref(linesplit[0]) and checkref(linesplit[1]):
82 print(line)
83 elif (not args.no_nodes) and checkref(line.split()[0]):
84 print(line)
85
86
53def main(): 87def main():
54 parser = argparse_oe.ArgumentParser(description='Small utility for working with .dot graph files') 88 parser = argparse_oe.ArgumentParser(description='Small utility for working with .dot graph files')
55 89
@@ -64,6 +98,15 @@ def main():
64 parser_find_paths.add_argument('tonode', help='ending node name') 98 parser_find_paths.add_argument('tonode', help='ending node name')
65 parser_find_paths.set_defaults(func=find_paths) 99 parser_find_paths.set_defaults(func=find_paths)
66 100
101 parser_filter = subparsers.add_parser('filter',
102 help='Pare down a task graph to contain only the specified references',
103 description='Pares down a task-depends.dot graph produced by bitbake -g to contain only the specified references')
104 parser_filter.add_argument('infile', help='Input file')
105 parser_filter.add_argument('ref', nargs='+', help='Reference to include (either recipe/target name or full target.taskname specification)')
106 parser_filter.add_argument('-n', '--no-nodes', action='store_true', help='Skip node formatting lines')
107 parser_filter.add_argument('-x', '--exclude-tasks', help='Comma-separated list of tasks to exclude (do_ prefix optional, wildcards allowed)')
108 parser_filter.set_defaults(func=filter_graph)
109
67 args = parser.parse_args() 110 args = parser.parse_args()
68 111
69 ret = args.func(args) 112 ret = args.func(args)