[yocto] Path to current bb-file or layer

Richard Purdie richard.purdie at linuxfoundation.org
Fri Sep 22 01:30:36 PDT 2017


On Fri, 2017-09-22 at 10:17 +0200, Svein Seldal wrote:
> On 21. sep. 2017 23:36, Richard Purdie wrote:
>  > You mean like ${FILE} ?
>  >
>  > $ bitbake bash -e | grep ^FILE=
>  > FILE="/media/build1/poky/meta/recipes-extended/bash/bash_4.4.bb"
> 
> To me ${FILE} seems to be pointing towards the receipe, and not the 
> current .bbclass file as you'd expect.
> 
> If I put this in local.conf
> 
>      INHERIT += "sp-version"
>      SP_BASEVERSION = "${@read_spbaseversion(d)}"
> 
> And in sp-version.bbclass:
> 
>      def read_spbaseversion(d):
>          bb.warn("SVEIN FILE: ", d.getVar('FILE', False))
>   	return '0'
> 
> If I do bitbake -e, I get
> 
>      WARNING: SVEIN FILE: /home/s/build-sp-
> image/build/conf/bblayers.conf
> 
> Later the read_spbaseversion is used from within recipe (although
> they 
> don't need to as this variable goes into the global scope, but for
> the 
> sake of the demonstration). Then the value being prined is:
> 
> WARNING: /home/s/build-sp-image/meta-sp/sp/sp.bb: SVEIN OPEN: 
> /home/s/build-sp-image/meta-sp/sp/sp.bb
> 
> Hence, ${FILE} seems to point to the current file scope, like a
> recipe, 
> and not any class files that the recipe might take use of.

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.

Cheers,

Richard



More information about the yocto mailing list