[yocto] Path to current bb-file or layer

Richard Purdie richard.purdie at linuxfoundation.org
Fri Sep 22 04:42:30 PDT 2017


On Fri, 2017-09-22 at 13:04 +0200, Svein Seldal wrote:
> On 22. sep. 2017 10:30, Richard Purdie wrote:
> > Its all about when your code is executed. Try putting:
>> > SP_BASEVERSION := "${@read_spbaseversion(d)}"
>> > in the bbclass file. I suspect that will give you the bbclass file
> > name.
>> > By default everything is deferred expansion so your code would give
> you
> > the final .bb as that is the context the code is run in.
> 
> In local.conf I put:
> 
>      INHERIT += "sp-version"
> 
> In classes/sp-version.bbclass
> 
>      def read_spbaseversion(d):
> # The goal of this function is to read and
> # parse a file from the layer
>          bb.warn("MYSELF: ", d.getVar('FILE', False))
>          return '0'
> 
>      SP_BASEVERSION := "${@read_spbaseversion(d)}"
> 
> Then both on Krogoth and Pyro, the following command returns:
> 
>      $ bitbake -e |tee var.txt |grep MYSELF
> 
> WARNING: MYSELF: /home/s/bughunt-pyro/build/conf/bblayers.conf
> WARNING: MYSELF: /home/s/bughunt-pyro/build/conf/bblayers.conf
>      bb.warn("MYSELF: ", d.getVar('FILE', False))
> 
> Likewise:
> 
>      $ bitbake -e sp-image |tee sp-image.txt |grep MYSELF
> 
> WARNING: MYSELF: /home/s/bughunt-pyro/build/conf/bblayers.conf
> WARNING: MYSELF: /home/s/bughunt-pyro/build/conf/bblayers.conf
> WARNING: MYSELF: /home/s/bughunt-pyro/build/conf/bblayers.conf
>      bb.warn("MYSELF: ", d.getVar('FILE', False))
> 
> 
> Is there an alternative to d.getVar() to access the "other" versions
> of the variable?

I suspect I'm misremembering the places that FILE gets reset in the
bitbake parser. It probably changes for conf and bb files and maybe inc
files but not bbclass files.

Why it does that is before my time with the codebase and I've never
really dared change it.

A better way to get what you're after may be to look at the contents
of BBINCLUDED.

Cheers,

Richard





More information about the yocto mailing list