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] build/ast: Create strong task add/del API in bb.build
Date: Wed, 18 Dec 2013 10:45:02 +0000	[thread overview]
Message-ID: <1387363502.6402.23.camel@ted> (raw)

Currently its near impossible to control task addition/deletion from
metadata context. This adds stong add/deltask API to bb.build
which is traditionally where it resided. The rather broken
remove_tasks function was removed, it didn't appear to do anything
useful or have any users.

This allows us to clean up hacks currently in use in metadata and use
standard API for it instead.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 6b39526..1524da0 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -668,9 +668,36 @@ def add_tasks(tasklist, deltasklist, d):
     # don't assume holding a reference
     d.setVar('_task_deps', task_deps)
 
-def remove_task(task, kill, d):
-    """Remove an BB 'task'.
+def addtask(task, before, after, d):
+    if task[:3] != "do_":
+        task = "do_" + task
+
+    d.setVarFlag(task, "task", 1)
+    bbtasks = d.getVar('__BBTASKS') or []
+    if not task in bbtasks:
+        bbtasks.append(task)
+    d.setVar('__BBTASKS', bbtasks)
+
+    existing = d.getVarFlag(task, "deps") or []
+    if after is not None:
+        # set up deps for function
+        for entry in after.split():
+            if entry not in existing:
+                existing.append(entry)
+    d.setVarFlag(task, "deps", existing)
+    if before is not None:
+        # set up things that depend on this func
+        for entry in before.split():
+            existing = d.getVarFlag(entry, "deps") or []
+            if task not in existing:
+                d.setVarFlag(entry, "deps", [task] + existing)
+
+def deltask(task, d):
+    if task[:3] != "do_":
+        task = "do_" + task
+
+    bbtasks = d.getVar('__BBDELTASKS') or []
+    if not task in bbtasks:
+        bbtasks.append(task)
+    d.setVar('__BBDELTASKS', bbtasks)
 
-       If kill is 1, also remove tasks that depend on this task."""
-
-    d.delVarFlag(task, 'task')
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py
index 2036cd4..a202053 100644
--- a/bitbake/lib/bb/parse/ast.py
+++ b/bitbake/lib/bb/parse/ast.py
@@ -235,29 +235,7 @@ class AddTaskNode(AstNode):
         self.after = after
 
     def eval(self, data):
-        var = self.func
-        if self.func[:3] != "do_":
-            var = "do_" + self.func
-
-        data.setVarFlag(var, "task", 1)
-        bbtasks = data.getVar('__BBTASKS') or []
-        if not var in bbtasks:
-            bbtasks.append(var)
-        data.setVar('__BBTASKS', bbtasks)
-
-        existing = data.getVarFlag(var, "deps") or []
-        if self.after is not None:
-            # set up deps for function
-            for entry in self.after.split():
-                if entry not in existing:
-                    existing.append(entry)
-        data.setVarFlag(var, "deps", existing)
-        if self.before is not None:
-            # set up things that depend on this func
-            for entry in self.before.split():
-                existing = data.getVarFlag(entry, "deps") or []
-                if var not in existing:
-                    data.setVarFlag(entry, "deps", [var] + existing)
+        bb.build.addtask(self.func, self.before, self.after, data)
 
 class DelTaskNode(AstNode):
     def __init__(self, filename, lineno, func):
@@ -265,14 +243,7 @@ class DelTaskNode(AstNode):
         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)
+        bb.build.deltask(self.func, data)
 
 class BBHandlerNode(AstNode):
     def __init__(self, filename, lineno, fns):
--
cgit v0.9.1




                 reply	other threads:[~2013-12-18 10:45 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=1387363502.6402.23.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.