[oe] getVar. setVar, "d", etc.

Richard Purdie rpurdie at rpsys.net
Wed Feb 6 12:18:10 UTC 2008


On Tue, 2008-02-05 at 18:29 -0800, Rich Pixley wrote:
> When does d change?
> 
> I've got the following bb file which produces results which puzzle me.  
> What I'm seeing is that the two values for d are different instances and 
> that the second function doesn't see the variable which was set in the 
> first because they're using different dictionaries.
> 
> --rich
> 
> def setting(d):
> 
>     import bb
> 
>     print "setting sets in ", d, "\n"
> 
>     bb.data.setVar('FOO', 'bar', d)
> 
>     return "setting"
> 
> X := ${@setting(d)}
> 
> def getting(d):
> 
>     import bb
> 
>     got = bb.data.getVar('FOO', d)
> 
>     print "getting gets %s from " % (got), d, "\n"
> 
>     return "getting"
> 
> Y := ${@getting(d)}

The problem is that you're doing this in ":=" context. The immediate
expansion operator means we have to expand the data overrides before
parsing the variables so overrides work as expected. This makes a copy
of the data object so the result of the setVar is lost inside the
setting function.

Using "X = ${@setting(d)}" instead should make the above example work if
I remember how this works correctly.

Once again I should remind people that := is usually a bad idea (see
recent discussions).

Regards,

Richard





More information about the Openembedded-devel mailing list