<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugzilla.yoctoproject.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.6"
          urlbase="https://bugzilla.yoctoproject.org/"
          
          maintainer="it-coreprojects-helpdesk@linuxfoundation.org"
>

    <bug>
          <bug_id>11905</bug_id>
          
          <creation_ts>2017-08-07 22:14:20 +0000</creation_ts>
          <short_desc>expandKeys() doesn&apos;t expand in definition order</short_desc>
          <delta_ts>2017-08-16 14:55:08 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>7</classification_id>
          <classification>Build System, Metadata &amp; Runtime</classification>
          <product>BitBake</product>
          <component>bitbake</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Multiple</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>NOTABUG</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>Undecided</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Haris Okanovic">haris.okanovic</reporter>
          <assigned_to name="Richard Purdie">richard.purdie</assigned_to>
          <cc>poky.bs.watcher</cc>
    
    <cc>poky.watcher</cc>
          
          
          <cf_os>---</cf_os>
          <cf_regression_type>---</cf_regression_type>
          
          <cf_docchange>No (bug/feature does not impact docs)</cf_docchange>

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>75703</commentid>
    <comment_count>0</comment_count>
    <who name="Haris Okanovic">haris.okanovic</who>
    <bug_when>2017-08-07 22:14:20 +0000</bug_when>
    <thetext>Consider the following bb snippet:

VAR_foo = &quot;base&quot;
AAA = &quot;foo&quot;
BBB = &quot;${AAA}&quot;
VAR_${BBB} = &quot;wrong&quot;
VAR_${AAA} = &quot;right&quot;

VAR_foo expands to &quot;wrong&quot;, which is very unintuitive.

The problem happens in lib.bb.data.expandKeys() which expands variables alphabetically instead of definition order. It first renames VAR_${AAA} --&gt; VAR_foo == &quot;right&quot; then renames VAR_${BBB} --&gt; VAR_foo --&gt; &quot;wrong&quot;, instead of the other way around.

You can reproduce this in OpenEmbedded by simply copying the 5-line bb snippet above into any recipe X, and run `bitbake -e X | grep &apos;^VAR_foo=&apos;` .</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>75897</commentid>
    <comment_count>1</comment_count>
    <who name="Richard Purdie">richard.purdie</who>
    <bug_when>2017-08-16 14:55:08 +0000</bug_when>
    <thetext>Key expansion happens at a very specific time in the metadata when expandKeys is called. We don&apos;t dynamically expand keys. We also don&apos;t store the order of variable declaration as it makes very little sense to given the complexities of the overrides that are possible.

I&apos;d therefore argue that the current behaviour is correct and the only way bitbake can reasonably behave. Its clear and deterministic.

I appreciate its not always 100% intuitive but I really can&apos;t see any other way the code can work, sorry.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>