Skip to contentSkip to conversation

lib/bb: fix exit when found renamed variables

PATCH New Marta Rybczynska 1 participant 1 message Feb 21, 2022

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 lib/bb: fix exit when found renamed variables

Until now, if a renamed variable was found, bitbake exited immediately if it was in a class, but continued after an error message if the variable was in a recipe. This was caused by cookerdata.py CookerDataBuilder::parseBaseConfiguration checking a different DataSmart instance than the variable was set in. To solve the issue, add a special variable and set it when we find a renamed variable. Check for it in ast.py and bail out if needed.

---
 lib/bb/data_smart.py | 4 ++++
 lib/bb/parse/ast.py  | 4 ++++
 2 files changed, 8 insertions(+)
lib/bb/data_smart.py +4 -0
index 7b06d3a1..e7047d79 100644
@@ -546,6 +546,8 @@ class DataSmart(MutableMapping):
         shortvar = var.split(":", 1)[0]
         if shortvar in self._var_renames:
             _print_rename_error(shortvar, loginfo, self._var_renames, fullvar=var)
+            # Mark that we have seen a renamed variable
+            self.setVar("_FAILPARSINGERRORHANDLED", True)
 
         self.expand_cache = {}
         parsing=False
@@ -737,6 +739,8 @@ class DataSmart(MutableMapping):
 
         if var in self._var_renames:
             _print_rename_error(var, loginfo, self._var_renames)
+            # Mark that we have seen a renamed variable
+            self.setVar("_FAILPARSINGERRORHANDLED", True)
 
         if 'op' not in loginfo:
             loginfo['op'] = "set"
lib/bb/parse/ast.py +4 -0
index 31bcc8e7..4b1b44ce 100644
@@ -333,6 +333,10 @@ def runAnonFuncs(d):
 def finalize(fn, d, variant = None):
     saved_handlers = bb.event.get_handlers().copy()
     try:
+        # Found renamed variables. Exit immediately
+        if d.getVar("_FAILPARSINGERRORHANDLED", False) == True:
+            raise bb.BBHandledException()
+
         for var in d.getVar('__BBHANDLERS', False) or []:
             # try to add the handler
             handlerfn = d.getVarFlag(var, "filename", False)
Signature · 1 line
2.33.0