bitbake/data_smart: Fix append/prepend/override ordering issue
authorRichard Purdie <rpurdie@linux.intel.com>
Mon, 6 Dec 2010 00:39:20 +0000 (00:39 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 7 Dec 2010 12:16:16 +0000 (12:16 +0000)
Where a variable name consisted of an append/prepend combined with an override
and there was also an append/prepend to the variable, the override could be lost
if the override was not in OVERRIDES.

For example:

FOO = "A"
FOO_append = "B"
FOO_append_virtclass-native = "C"

could result in "AB" even though virtclass-native was in OVERRIDES.

With this patch applied, the result is "ABC" as would be expected.

The problem was the deletion of the _append/_prepend flag was happening
if *any* append/prepend was procesed, the result should really be that
it should contain any unprocessed append/prepend.

Kevin Tian deserves credit for looking into this and working out the
problem here.

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/data_smart.py

index b9d9476..9594fee 100644 (file)
@@ -157,32 +157,40 @@ class DataSmart:
         if "_append" in self._special_values:
             appends = self._special_values["_append"] or []
             for append in appends:
+                keep = []
                 for (a, o) in self.getVarFlag(append, "_append") or []:
-                    # maybe the OVERRIDE was not yet added so keep the append
-                    if (o and o in overrides) or not o:
-                        self.delVarFlag(append, "_append")
                     if o and not o in overrides:
+                        keep.append((a ,o))
                         continue
 
                     sval = self.getVar(append, False) or ""
                     sval += a
                     self.setVar(append, sval)
-
+                # We save overrides that may be applied at some later stage
+                if keep:
+                    self.setVarFlag(append, "_append", keep)
+                else:
+                    self.delVarFlag(append, "_append")
 
         if "_prepend" in self._special_values:
             prepends = self._special_values["_prepend"] or []
-
             for prepend in prepends:
+                keep = []
                 for (a, o) in self.getVarFlag(prepend, "_prepend") or []:
-                    # maybe the OVERRIDE was not yet added so keep the prepend
-                    if (o and o in overrides) or not o:
-                        self.delVarFlag(prepend, "_prepend")
                     if o and not o in overrides:
+                        keep.append((a ,o))
                         continue
 
                     sval = a + (self.getVar(prepend, False) or "")
                     self.setVar(prepend, sval)
 
+                # We save overrides that may be applied at some later stage
+                if keep:
+                    self.setVarFlag(prepend, "_prepend", keep)
+                else:
+                    self.delVarFlag(prepend, "_prepend")
+
+
     def initVar(self, var):
         self.expand_cache = {}
         if not var in self.dict: