[yocto] Not able to preserve a variable across two python functions in bbclass

Paul Eggleton paul.eggleton at linux.intel.com
Fri Oct 16 03:01:15 PDT 2015


Hi Elena,

On Friday 16 October 2015 09:52:28 Reshetova, Elena wrote:
> I am having a very stupid issue, which I can't figure out. I am setting my
> own variable from one python function (via d.setVar) and then attempting to
> read it from another python function (via d.getVar). Both functions are in
> the same bbclass.
> 
> However, result of reading is always empty. But if I read this variable back
> in the same python function, I get a correct value.
> 
> Aren't "d" store is global and supposed to work across functions and even
> classes?
> 
> 
> 
> Here is the commit that shows that I am doing:
> https://github.com/01org/meta-security-isafw/commit/590f7158a90c98dbb1bf650e
> d081adbccb6e0006
> 
> Really plain simple, but doesn't work :(

I'm afraid not, other than dependency relationships, task functions are 
executed independently and thus have their own scope. The way to do this sort 
of thing is to set the variable in the parent scope i.e. the recipe level (or 
above that, the configuration level).  

If you absolutely must pass things between tasks you need to do so via the 
sysroot, taking care to set up the appropriate task dependency relationship to 
ensure the sysroot gets populated; I'm not sure that's the case here though.

Cheers,
Paul

-- 

Paul Eggleton
Intel Open Source Technology Centre



More information about the yocto mailing list