summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-18 10:44:30 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-12-18 17:08:07 +0000
commit8a82a3835cb5b38812da720914d5f47a7cd443e8 (patch)
tree4f3a44bba1744d5f2a1bc33d4955f6e8e77c6fb6
parent0f2041142e2513ee284e29f1b88e3767c2522f90 (diff)
downloadpoky-8a82a3835cb5b38812da720914d5f47a7cd443e8.tar.gz
bitbake: ast/BBHandler/build: Add support for removing tasks (deltask)
Back in the depths of time we did support task removal. In the pre AST days it was nearly impossible to continue supporting it, it wasn't used so it was dropped. With the modern codebase we can easily now support deltask and it would be very useful within the metadata since it can massively simplify dependency trees. As an example, a core-image-sato had 47703 inter task dependencies before this patch and a patch to native.bbclass, afterwards with the noexec tasks deleted, we had 29883. Such a significant simplification is worthwhile and justifies adding a deltask operation to the system. (Bitbake rev: acecbde6fb70ff3c96deab3cdf819d8442e87ed4) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/build.py6
-rw-r--r--bitbake/lib/bb/parse/ast.py25
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py6
3 files changed, 35 insertions, 2 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 92c45a38c9..6b395264b6 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -622,7 +622,7 @@ def stampfile(taskname, d, file_name = None):
622 """ 622 """
623 return stamp_internal(taskname, d, file_name) 623 return stamp_internal(taskname, d, file_name)
624 624
625def add_tasks(tasklist, d): 625def add_tasks(tasklist, deltasklist, d):
626 task_deps = d.getVar('_task_deps') 626 task_deps = d.getVar('_task_deps')
627 if not task_deps: 627 if not task_deps:
628 task_deps = {} 628 task_deps = {}
@@ -633,6 +633,10 @@ def add_tasks(tasklist, d):
633 633
634 for task in tasklist: 634 for task in tasklist:
635 task = d.expand(task) 635 task = d.expand(task)
636
637 if task in deltasklist:
638 continue
639
636 d.setVarFlag(task, 'task', 1) 640 d.setVarFlag(task, 'task', 1)
637 641
638 if not task in task_deps['tasks']: 642 if not task in task_deps['tasks']:
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index d4b8b09543..2036cd43fe 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -259,6 +259,21 @@ class AddTaskNode(AstNode):
259 if var not in existing: 259 if var not in existing:
260 data.setVarFlag(entry, "deps", [var] + existing) 260 data.setVarFlag(entry, "deps", [var] + existing)
261 261
262class DelTaskNode(AstNode):
263 def __init__(self, filename, lineno, func):
264 AstNode.__init__(self, filename, lineno)
265 self.func = func
266
267 def eval(self, data):
268 var = self.func
269 if self.func[:3] != "do_":
270 var = "do_" + self.func
271
272 bbtasks = data.getVar('__BBDELTASKS') or []
273 if not var in bbtasks:
274 bbtasks.append(var)
275 data.setVar('__BBDELTASKS', bbtasks)
276
262class BBHandlerNode(AstNode): 277class BBHandlerNode(AstNode):
263 def __init__(self, filename, lineno, fns): 278 def __init__(self, filename, lineno, fns):
264 AstNode.__init__(self, filename, lineno) 279 AstNode.__init__(self, filename, lineno)
@@ -309,6 +324,13 @@ def handleAddTask(statements, filename, lineno, m):
309 324
310 statements.append(AddTaskNode(filename, lineno, func, before, after)) 325 statements.append(AddTaskNode(filename, lineno, func, before, after))
311 326
327def handleDelTask(statements, filename, lineno, m):
328 func = m.group("func")
329 if func is None:
330 return
331
332 statements.append(DelTaskNode(filename, lineno, func))
333
312def handleBBHandlers(statements, filename, lineno, m): 334def handleBBHandlers(statements, filename, lineno, m):
313 statements.append(BBHandlerNode(filename, lineno, m.group(1))) 335 statements.append(BBHandlerNode(filename, lineno, m.group(1)))
314 336
@@ -333,7 +355,8 @@ def finalize(fn, d, variant = None):
333 bb.data.update_data(d) 355 bb.data.update_data(d)
334 356
335 tasklist = d.getVar('__BBTASKS') or [] 357 tasklist = d.getVar('__BBTASKS') or []
336 bb.build.add_tasks(tasklist, d) 358 deltasklist = d.getVar('__BBDELTASKS') or []
359 bb.build.add_tasks(tasklist, deltasklist, d)
337 360
338 bb.parse.siggen.finalise(fn, d, variant) 361 bb.parse.siggen.finalise(fn, d, variant)
339 362
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 7cba649595..408890e48a 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -42,6 +42,7 @@ __func_start_regexp__ = re.compile( r"(((?P<py>python)|(?P<fr>fakeroot))\s*)*
42__inherit_regexp__ = re.compile( r"inherit\s+(.+)" ) 42__inherit_regexp__ = re.compile( r"inherit\s+(.+)" )
43__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" ) 43__export_func_regexp__ = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" )
44__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") 44__addtask_regexp__ = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
45__deltask_regexp__ = re.compile("deltask\s+(?P<func>\w+)")
45__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" ) 46__addhandler_regexp__ = re.compile( r"addhandler\s+(.+)" )
46__def_regexp__ = re.compile( r"def\s+(\w+).*:" ) 47__def_regexp__ = re.compile( r"def\s+(\w+).*:" )
47__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" ) 48__python_func_regexp__ = re.compile( r"(\s+.*)|(^$)" )
@@ -243,6 +244,11 @@ def feeder(lineno, s, fn, root, statements):
243 ast.handleAddTask(statements, fn, lineno, m) 244 ast.handleAddTask(statements, fn, lineno, m)
244 return 245 return
245 246
247 m = __deltask_regexp__.match(s)
248 if m:
249 ast.handleDelTask(statements, fn, lineno, m)
250 return
251
246 m = __addhandler_regexp__.match(s) 252 m = __addhandler_regexp__.match(s)
247 if m: 253 if m:
248 ast.handleBBHandlers(statements, fn, lineno, m) 254 ast.handleBBHandlers(statements, fn, lineno, m)