All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: bitbake-devel <bitbake-devel@lists.openembedded.org>
Subject: [PATCH] ast/BBHandler/build: Add support for removing tasks (deltask)
Date: Wed, 18 Dec 2013 10:44:30 +0000	[thread overview]
Message-ID: <1387363470.6402.22.camel@ted> (raw)

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.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 92c45a3..6b39526 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -622,7 +622,7 @@ def stampfile(taskname, d, file_name = None):
     """
     return stamp_internal(taskname, d, file_name)
 
-def add_tasks(tasklist, d):
+def add_tasks(tasklist, deltasklist, d):
     task_deps = d.getVar('_task_deps')
     if not task_deps:
         task_deps = {}
@@ -633,6 +633,10 @@ def add_tasks(tasklist, d):
 
     for task in tasklist:
         task = d.expand(task)
+
+        if task in deltasklist:
+            continue
+
         d.setVarFlag(task, 'task', 1)
 
         if not task in task_deps['tasks']:
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index d4b8b09..2036cd4 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -259,6 +259,21 @@ class AddTaskNode(AstNode):
                 if var not in existing:
                     data.setVarFlag(entry, "deps", [var] + existing)
 
+class DelTaskNode(AstNode):
+    def __init__(self, filename, lineno, func):
+        AstNode.__init__(self, filename, lineno)
+        self.func = func
+
+    def eval(self, data):
+        var = self.func
+        if self.func[:3] != "do_":
+            var = "do_" + self.func
+
+        bbtasks = data.getVar('__BBDELTASKS') or []
+        if not var in bbtasks:
+            bbtasks.append(var)
+        data.setVar('__BBDELTASKS', bbtasks)
+
 class BBHandlerNode(AstNode):
     def __init__(self, filename, lineno, fns):
         AstNode.__init__(self, filename, lineno)
@@ -309,6 +324,13 @@ def handleAddTask(statements, filename, lineno, m):
 
     statements.append(AddTaskNode(filename, lineno, func, before, after))
 
+def handleDelTask(statements, filename, lineno, m):
+    func = m.group("func")
+    if func is None:
+        return
+
+    statements.append(DelTaskNode(filename, lineno, func))
+
 def handleBBHandlers(statements, filename, lineno, m):
     statements.append(BBHandlerNode(filename, lineno, m.group(1)))
 
@@ -333,7 +355,8 @@ def finalize(fn, d, variant = None):
     bb.data.update_data(d)
 
     tasklist = d.getVar('__BBTASKS') or []
-    bb.build.add_tasks(tasklist, d)
+    deltasklist = d.getVar('__BBDELTASKS') or []
+    bb.build.add_tasks(tasklist, deltasklist, d)
 
     bb.parse.siggen.finalise(fn, d, variant)
 
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 7cba649..408890e 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*)*
 __inherit_regexp__       = re.compile( r"inherit\s+(.+)" )
 __export_func_regexp__   = re.compile( r"EXPORT_FUNCTIONS\s+(.+)" )
 __addtask_regexp__       = re.compile("addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*")
+__deltask_regexp__       = re.compile("deltask\s+(?P<func>\w+)")
 __addhandler_regexp__    = re.compile( r"addhandler\s+(.+)" )
 __def_regexp__           = re.compile( r"def\s+(\w+).*:" )
 __python_func_regexp__   = re.compile( r"(\s+.*)|(^$)" )
@@ -243,6 +244,11 @@ def feeder(lineno, s, fn, root, statements):
         ast.handleAddTask(statements, fn, lineno, m)
         return
 
+    m = __deltask_regexp__.match(s)
+    if m:
+        ast.handleDelTask(statements, fn, lineno, m)
+        return
+
     m = __addhandler_regexp__.match(s)
     if m:
         ast.handleBBHandlers(statements, fn, lineno, m)




                 reply	other threads:[~2013-12-18 10:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1387363470.6402.22.camel@ted \
    --to=richard.purdie@linuxfoundation.org \
    --cc=bitbake-devel@lists.openembedded.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.