Bug 9033 - Data.getVar doesn't support the expansion of nested variables
Summary: Data.getVar doesn't support the expansion of nested variables
Status: RESOLVED WORKSFORME
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 Multiple
: Undecided normal
Target Milestone: ---
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2016-02-02 10:04 UTC by Igor Stoppa
Modified: 2016-02-02 14:18 UTC (History)
2 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Yes (doc changes required)


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Igor Stoppa 2016-02-02 10:04:01 UTC
In a recipe, it is common to have a variable defined in terms of another, with various levels of nesting.

Simple Ex:


Precondition:
-------------

VAR1 ?= "a"

VAR2 ?= "${VAR1}b"


Triggering Action:
------------------
running Data.getVar over VAR2 in a python script, within a recipe
ex: print d.getVar("VAR2")

Expected Outcome:
-----------------
one would expect that it will yield "ab", just like it would happen if the expansion was performed within a shell script


Actual Outcome:
---------------
It will instead yield "${VAR1}b", which is somewhat less intuitive and definitely less usable, in typical scenario where one wants to have the final evaluation of the expression.


Additional remarks:
-------------------
One might argue that this is a feature request, rather than a bug, but I see the current implementation as a deviation from the behaviour of the existing variable expansion performed in shell context. I think it's fair to expect getVar to be the python counterpart of variable retrieval that in a shell is done with "{VAR2}" and therefore I think it should be expected that it behaves in a compatible way.
Comment 1 Igor Stoppa 2016-02-02 10:05:44 UTC
In the remarks, s/{VAR2}/${VAR2}/
Comment 2 Richard Purdie 2016-02-02 11:57:33 UTC
Try d.getVar("VAR2", True)

There is an open bug about changing to expand by default but that is a long process. In the current cycle we will make the expand parameter mandatory (we've already done a few rounds of cleanup adding the missing parameters).
Comment 3 Igor Stoppa 2016-02-02 12:10:45 UTC
Yes, thanks, it worked.

I was looking at the wrong code, where the value was already set to True, so I couldn't figure out what else I could do.

But this issue can be closed.
Comment 4 Richard Purdie 2016-02-02 14:18:05 UTC
Resolved as variable expansion does work.