Skip to contentSkip to conversation

cooker: Only add universe targets where the task exists

PATCH New Richard Purdie 1 participant 5 messages Jan 19, 2017

lore
Share & tools
lore
#0 lore raw

PATCH 1/5 cooker: Only add universe targets where the task exists

Currently "bitbake universe -c fetch" will error if every task in the system doesn't have a fetch task. This seems unreasonable so filter the list based upon whether the task exists. This implementation does assume if a task exits for a given provider name, it can run, even if the preferred provider that ends up getting built might be the namespace without the task. This is unlikely to be a real world issue at this point.

---
 lib/bb/cooker.py | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/bb/cooker.py +9 -0
index 5608845..a7b9745 100644
@@ -1704,6 +1704,15 @@ class BBCooker:
             pkgs_to_build.remove('universe')
             for mc in self.multiconfigs:
                 for t in self.recipecaches[mc].universe_target:
+                    if task:
+                        foundtask = False
+                        for provider_fn in self.recipecaches[mc].providers[t]:
+                            if task in self.recipecaches[mc].task_deps[provider_fn]['tasks']:
+                                foundtask = True
+                                break
+                        if not foundtask:
+                            bb.debug(1, "Skipping %s for universe tasks as task %s doesn't exist" % (t, task))
+                            continue
                     if mc:
                         t = "multiconfig:" + mc + ":" + t
                     pkgs_to_build.append(t)
Signature · 1 line
2.7.4
#1 lore raw

PATCH 2/5 runqueue: Fix traceback when using -b

Without this, bitbake -b of image recipes cause tracebacks since the list of providers is empty.

---
 lib/bb/runqueue.py | 2 ++
 1 file changed, 2 insertions(+)
lib/bb/runqueue.py +2 -0
index d42eb81..7e651a4 100644
@@ -567,6 +567,8 @@ class RunQueueData:
                 for (depname, idependtask) in irdepends:
                     if depname in taskData[mc].run_targets:
                         # Won't be in run_targets if ASSUME_PROVIDED
+                        if not taskData[mc].run_targets[depname]:
+                            continue
                         depdata = taskData[mc].run_targets[depname][0]
                         if depdata is not None:
                             t = depdata + ":" + idependtask
Signature · 1 line
2.7.4
#2 lore raw

PATCH 3/5 event/ast: Add RecipeTaskPreProcess event before task finalisation

In reply to Richard Purdie

There are various pieces of code which need to run after the tasks are finalised but before bitbake locks in on the task dependencies. This adds such an event so dependency changes in anonymous python can be accounted for and acted upon by these specific event handlers.

---
 lib/bb/event.py     | 11 +++++++++++
 lib/bb/parse/ast.py |  1 +
 2 files changed, 12 insertions(+)
lib/bb/event.py +11 -0
index e2ca33e..6d8493b 100644
@@ -361,6 +361,17 @@ class RecipeEvent(Event):
 class RecipePreFinalise(RecipeEvent):
     """ Recipe Parsing Complete but not yet finialised"""
 
+class RecipeTaskPreProcess(RecipeEvent):
+    """
+    Recipe Tasks about to be finalised
+    The list of tasks should be final at this point and handlers
+    are only able to change interdependencies
+    """
+    def __init__(self, fn, tasklist):
+        self.fn = fn
+        self.tasklist = tasklist
+        Event.__init__(self)
+
 class RecipeParsed(RecipeEvent):
     """ Recipe Parsing Complete """
 
lib/bb/parse/ast.py +1 -0
index 853dda8..8b5b366 100644
@@ -358,6 +358,7 @@ def finalize(fn, d, variant = None):
     bb.data.update_data(d)
 
     tasklist = d.getVar('__BBTASKS', False) or []
+    bb.event.fire(bb.event.RecipeTaskPreProcess(fn, list(tasklist)), d)
     bb.build.add_tasks(tasklist, d)
 
     bb.parse.siggen.finalise(fn, d, variant)
Signature · 1 line
2.7.4
#3 lore raw

PATCH 4/5 cooker: Add BB_LIMITEDDEPS support

In reply to Richard Purdie

When we're running with bitbake -b, BB_TASKDEPDATA is incorrect and limited. We really need a way to know this from the metadata and this new variable provides this in worker context. This means existing code can stop having to guess.

---
 bin/bitbake-worker   | 2 ++
 lib/bb/cooker.py     | 1 +
 lib/bb/cookerdata.py | 1 +
 3 files changed, 4 insertions(+)
bin/bitbake-worker +2 -0
index 5010bad..ee2d622 100755
@@ -222,6 +222,8 @@ def fork_off_task(cfg, data, databuilder, workerdata, fn, task, taskname, append
                 the_data = databuilder.mcdata[mc]
                 the_data.setVar("BB_WORKERCONTEXT", "1")
                 the_data.setVar("BB_TASKDEPDATA", taskdepdata)
+                if cfg.limited_deps:
+                    the_data.setVar("BB_LIMITEDDEPS", "1")
                 the_data.setVar("BUILDNAME", workerdata["buildname"])
                 the_data.setVar("DATE", workerdata["date"])
                 the_data.setVar("TIME", workerdata["time"])
lib/bb/cooker.py +1 -0
index a7b9745..80007c5 100644
@@ -1409,6 +1409,7 @@ class BBCooker:
         item = info_array[0].pn
         self.recipecaches[mc].ignored_dependencies = set()
         self.recipecaches[mc].bbfile_priority[fn] = 1
+        self.configuration.limited_deps = True
 
         # Remove external dependencies
         self.recipecaches[mc].task_deps[fn]['depends'] = {}
lib/bb/cookerdata.py +1 -0
index d9eab56..53f4587 100644
@@ -147,6 +147,7 @@ class CookerConfiguration(object):
         self.interface = []
         self.writeeventlog = False
         self.server_only = False
+        self.limited_deps = False
 
         self.env = {}
 
Signature · 1 line
2.7.4
#4 lore raw

PATCH 5/5 fetch2: Avoid recursive errors

In reply to Richard Purdie

If PATH contains WORKDIR which contains PV which contains SRCPV we can end up in circular recursion within the fetcher. This code change allows for the recursion to be broken by giving PV a temporary dummy value in a data store copy.

---
 lib/bb/fetch2/__init__.py | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/bb/fetch2/__init__.py +9 -0
index d6d7850..525f47e 100644
@@ -819,6 +819,15 @@ def runfetchcmd(cmd, d, quiet=False, cleanup=None, log=None, workdir=None):
     if not cleanup:
         cleanup = []
 
+    # If PATH contains WORKDIR which contains PV which contains SRCPV we
+    # can end up in circular recursion here so give the option of breaking it
+    # in a data store copy.
+    try:
+        d.getVar("PV")
+    except bb.data_smart.ExpansionError:
+        d = bb.data.createCopy(d)
+        d.setVar("PV", "fetcheravoidrecurse")
+
     origenv = d.getVar("BB_ORIGENV", False)
     for var in exportvars:
         val = d.getVar(var) or (origenv and origenv.getVar(var))
Signature · 1 line
2.7.4