Patchwork [bitbake-devel] data_smart: Fix bug with overrides and weak default values

login
register
mail settings
Submitter Richard Purdie
Date June 21, 2013, noon
Message ID <1371816036.20823.301.camel@ted>
Download mbox | patch
Permalink /patch/52211/
State New
Headers show

Comments

Richard Purdie - June 21, 2013, noon
(aka pay the cookie monster for weak defaults)

If you have code like:

MYVAR = "a"
MYVAR_override ??= "b"

then MYVAR will get the value "a" even when override is in OVERRIDES. The
reason is that the value of ??= is set as a flag not a value and the cookie
monster isn't paid.

The fix is to ensure appropriate payment is made for a defaultval varflag
matching the usual setVar case.

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
---

Patch

diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index fa7811e..dfa9afe 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -485,16 +485,20 @@  class DataSmart(MutableMapping):
 
         # more cookies for the cookie monster
         if '_' in var:
-            override = var[var.rfind('_')+1:]
-            if len(override) > 0:
-                if override not in self._seen_overrides:
-                    self._seen_overrides[override] = set()
-                self._seen_overrides[override].add( var )
+            self._setvar_update_overrides(var)
 
         # setting var
         self.dict[var]["_content"] = value
         self.varhistory.record(**loginfo)
 
+    def _setvar_update_overrides(self, var):
+        # aka pay the cookie monster
+        override = var[var.rfind('_')+1:]
+        if len(override) > 0:
+            if override not in self._seen_overrides:
+                self._seen_overrides[override] = set()
+            self._seen_overrides[override].add( var )
+
     def getVar(self, var, expand=False, noweakdefault=False):
         value = self.getVarFlag(var, "_content", False, noweakdefault)
 
@@ -566,6 +570,9 @@  class DataSmart(MutableMapping):
             self._makeShadowCopy(var)
         self.dict[var][flag] = value
 
+        if flag == "defaultval" and '_' in var:
+            self._setvar_update_overrides(var)
+
     def getVarFlag(self, var, flag, expand=False, noweakdefault=False):
         local_var = self._findVar(var)
         value = None