Patchwork [bitbake-devel] data.py: Add a warning when expandKeys overwrites an existing key

login
register
mail settings
Submitter Mark Hatle
Date March 19, 2013, 8:28 p.m.
Message ID <1363724931-31720-1-git-send-email-mark.hatle@windriver.com>
Download mbox | patch
Permalink /patch/46493/
State Accepted
Commit 7c568132c54a21161de28907159f902462f1e2bb
Headers show

Comments

Mark Hatle - March 19, 2013, 7:54 p.m.
On 3/19/13 3:28 PM, Mark Hatle wrote:
> 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.

> Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
> ---
>   lib/bb/data.py | 5 +++++
>   1 file changed, 5 insertions(+)
>
> diff --git a/lib/bb/data.py b/lib/bb/data.py
> index 7047f48..110666c 100644
> --- a/lib/bb/data.py
> +++ b/lib/bb/data.py
> @@ -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):
>
Mark Hatle - March 19, 2013, 8:28 p.m.
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".

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
---
 lib/bb/data.py | 5 +++++
 1 file changed, 5 insertions(+)

Patch

diff --git a/lib/bb/data.py b/lib/bb/data.py
index 7047f48..110666c 100644
--- a/lib/bb/data.py
+++ b/lib/bb/data.py
@@ -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):