Skip to contentSkip to conversation

cookerdata: Be consistent with what type bb_data represents

PATCH New Peter Kjellerstedt 1 participant 2 messages Nov 21, 2023

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 cookerdata: Be consistent with what type bb_data represents

In _parse_recipe(), bb_data was initially a datastore object, but then after the call to bb.parse.handle() it was all of a sudden turned into a dict of variant:datastore pairs. At the same time, parseRecipeVariants() used bb_data for datastore objects, while parseRecipe() used it for the dicts of variant:datastore pairs.

Change these functions to consistently use "bb_data" for datastore objects and use "datastores" for the dicts of variant:datastore pairs.

---
 bitbake/lib/bb/cookerdata.py | 11 +++++------
 1 file changed, 5 insertions(+), 6 deletions(-)
bitbake/lib/bb/cookerdata.py +5 -6
index 42b8d64685..0649e40995 100644
@@ -503,8 +503,8 @@ class CookerDataBuilder(object):
 
         if appends:
             bb_data.setVar('__BBAPPEND', " ".join(appends))
-        bb_data = bb.parse.handle(bbfile, bb_data)
-        return bb_data
+
+        return bb.parse.handle(bbfile, bb_data)
 
     def parseRecipeVariants(self, bbfile, appends, virtonly=False, mc=None, layername=None):
         """
@@ -516,8 +516,7 @@ class CookerDataBuilder(object):
             (bbfile, virtual, mc) = bb.cache.virtualfn2realfn(bbfile)
             bb_data = self.mcdata[mc].createCopy()
             bb_data.setVar("__ONLYFINALISE", virtual or "default")
-            datastores = self._parse_recipe(bb_data, bbfile, appends, mc, layername)
-            return datastores
+            return self._parse_recipe(bb_data, bbfile, appends, mc, layername)
 
         if mc is not None:
             bb_data = self.mcdata[mc].createCopy()
@@ -543,5 +542,5 @@ class CookerDataBuilder(object):
         """
         logger.debug("Parsing %s (full)" % virtualfn)
         (fn, virtual, mc) = bb.cache.virtualfn2realfn(virtualfn)
-        bb_data = self.parseRecipeVariants(virtualfn, appends, virtonly=True, layername=layername)
-        return bb_data[virtual]
+        datastores = self.parseRecipeVariants(virtualfn, appends, virtonly=True, layername=layername)
+        return datastores[virtual]
#1 lore raw

PATCH 2/2 cache: Simplify virtualfn2realfn()

Also correct the description of variant2virtual().

---
 bitbake/lib/bb/cache.py | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
bitbake/lib/bb/cache.py +2 -4
index 5ea41c5de0..18d5574a31 100644
@@ -344,9 +344,7 @@ def virtualfn2realfn(virtualfn):
     """
     mc = ""
     if virtualfn.startswith('mc:') and virtualfn.count(':') >= 2:
-        elems = virtualfn.split(':')
-        mc = elems[1]
-        virtualfn = ":".join(elems[2:])
+        (_, mc, virtualfn) = virtualfn.split(':', 2)
 
     fn = virtualfn
     cls = ""
@@ -369,7 +367,7 @@ def realfn2virtual(realfn, cls, mc):
 
 def variant2virtual(realfn, variant):
     """
-    Convert a real filename + the associated subclass keyword to a virtual filename
+    Convert a real filename + a variant to a virtual filename
     """
     if variant == "":
         return realfn