All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Svein Seldal <sveinse@seldal.com>,
	"yocto@yoctoproject.org" <yocto@yoctoproject.org>
Subject: Re: Path to current bb-file or layer
Date: Fri, 22 Sep 2017 09:30:36 +0100	[thread overview]
Message-ID: <1506069036.18640.187.camel@linuxfoundation.org> (raw)
In-Reply-To: <29436fab-d836-536b-d5d9-3cc1fe5a5e85@seldal.com>

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


  reply	other threads:[~2017-09-22  8:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-21 20:00 Path to current bb-file or layer Svein Seldal
2017-09-21 21:29 ` Andre McCurdy
2017-09-21 21:36 ` Richard Purdie
2017-09-22  8:17   ` Svein Seldal
2017-09-22  8:30     ` Richard Purdie [this message]
  -- strict thread matches above, loose matches on Subject: below --
2017-09-22 11:04 Svein Seldal
2017-09-22 11:42 ` Richard Purdie
2017-09-22 13:39   ` Svein Seldal

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1506069036.18640.187.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=sveinse@seldal.com \
    --cc=yocto@yoctoproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.