Skip to contentSkip to conversation

data.py: Add a warning when expandKeys overwrites an existing key

PATCH In review Mark Hatle 1 participant 2 messages Mar 19, 2013

lore
Share & tools
lore

Mark Hatle

author
#0 lore raw

PATCH 1/1 data.py: Add a warning when expandKeys overwrites an existing key

When two variables are defined as:

${var} = "bar"
foo = "foobar"

The value of 'foo' when ${var} == foo becomes indeterminate. We want to warn a user when this situation has been encountered so they can take corrective actions.

In the above example usually foo == bar, unless multilibs are enabled. Then ml-foo = "ml-foobar".

---
 lib/bb/data.py | 5 +++++
 1 file changed, 5 insertions(+)
lib/bb/data.py +5 -0
index 7047f48..110666c 100644
@@ -158,6 +158,11 @@ def expandKeys(alterdata, readdata = None):
 
     for key in todolist:
         ekey = todolist[key]
+        if ekey in keys(alterdata):
+            val = alterdata.getVar(key, 0)
+            newval = alterdata.getVar(ekey, 0)
+            if val is not None and newval is not None:
+                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
         alterdata.renameVar(key, ekey)
 
 def inheritFromOS(d, savedenv, permitted):
Signature · 1 line
1.8.1.2.545.g2f19ada
author
#1 lore raw
Quoted 11 lines · Mark Hatle

When two variables are defined as:

${var} = "bar"
foo = "foobar"

The value of 'foo' when ${var} == foo becomes indeterminate. We want to warn a user when this situation has been encountered so they can take corrective actions.

In the above example usually foo == bar, unless multilibs are enabled. Then ml-foo = "ml-foobar".

This patch highlights the places where a problem may exist. When used with the current oe-core, it highlights a number of problems with the multilib configuration code. (See patch sent to oe-core.)

I'd like to see this incorporated, but at this point it's definitely an RFC.

Quoted 22 lines
---
  lib/bb/data.py | 5 +++++
  1 file changed, 5 insertions(+)
lib/bb/data.py +5 -0
index 7047f48..110666c 100644
@@ -158,6 +158,11 @@ def expandKeys(alterdata, readdata = None):
 
      for key in todolist:
          ekey = todolist[key]
+        if ekey in keys(alterdata):
+            val = alterdata.getVar(key, 0)
+            newval = alterdata.getVar(ekey, 0)
+            if val is not None and newval is not None:
+                bb.warn("Variable key %s (%s) replaces original key %s (%s)." % (key, val, ekey, newval))
          alterdata.renameVar(key, ekey)
 
  def inheritFromOS(d, savedenv, permitted):