Hi,

On Thu, 2020-01-30 at 13:32 +0200, Alexandru N. Onea wrote:
> Let's consider the following example in a bb file:
> 
> X = "1"
> A := "X is '${X}' and Y is '${Y}'"
> B = "X is '${X}' and Y is '${Y}'"
> X = "2"
> Y = "3"
> 
> According to the bitbake user manual, section 3.1.7 [1], the expected
> values for A and B after parsing is done, are 
> 
> A="X is '1' and Y is ''"
> B="X is '2' and Y is '3'"
> 
> meaning that, since Y is not defined at the time of parsing the
> assignment to A, it is replaced with blank, while X is substituted
> with the value that it had at that time. On the other hand, B will
> substitute the last defined values for both X and Y.
> 
> However, if I run the following example through bitbake, I get the
> following result:
> 
> A="X is '1' and Y is '3'"
> B="X is '2' and Y is '3'"
> 
> Although unexpected and a bit counter-intuitive at first, the result
> is easily explained by the fact that, according to section 3.1.4 [2],
> an undefined variable expansion results in keeping the actual literal
> string in place, in our case "${Y}", which probably leads, at the end
> of the parsing, to a re-evaluation of A and, since now Y is defined,
> the substitution of that literal with the last value that has been
> assigned to Y (i.e. 3).
> 
> Question: is this behavior intentional? Or is it a bug? The
> documentation for the immediate assignment states that we should
> expect undefined variables to be substituted with blank while in
> practice they obey the rules of the simple assignments.

I'd say bitbake is behaving as it was written to behave. I'm not sure
its ideal but we probably do rely on it in places.

> Should at least the documentation be updated?

Yes, and we should add some tests for it to better "document" it.

There is a patch on the bitbake list which tweaks the docs already but
I'd like to fix the example too.

Cheers,

Richard

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.

View/Reply Online (#48212): https://lists.yoctoproject.org/g/yocto/message/48212
Mute This Topic: https://lists.yoctoproject.org/mt/70268333/21656
Group Owner: yocto+ow...@lists.yoctoproject.org
Unsubscribe: https://lists.yoctoproject.org/g/yocto/unsub  
[arch...@mail-archive.com]
-=-=-=-=-=-=-=-=-=-=-=-

Reply via email to