All of lore.kernel.org
 help / color / mirror / Atom feed
* Path to current bb-file or layer
@ 2017-09-21 20:00 Svein Seldal
  2017-09-21 21:29 ` Andre McCurdy
  2017-09-21 21:36 ` Richard Purdie
  0 siblings, 2 replies; 8+ messages in thread
From: Svein Seldal @ 2017-09-21 20:00 UTC (permalink / raw)
  To: yocto@yoctoproject.org


To determine a image version, I'd like to read a VERSION file which is 
located in the root of the layer. (Per our development procedure.) I'd 
like to read it from a bbclass file. However I seem to be unable to find 
any methods or variables to find a useful path to either the current 
bb-file or the root of the layer.

The only way I have found is to parse through BBLAYERS and guess at what 
my own layer is of those, and then use the found to access the file. But 
this feels very wacky.

Is there a reason why bitbake doesn't have a variable path reference to 
the current file?


Best regards,
Svein


^ permalink raw reply	[flat|nested] 8+ messages in thread
* Re: Path to current bb-file or layer
@ 2017-09-22 11:04 Svein Seldal
  2017-09-22 11:42 ` Richard Purdie
  0 siblings, 1 reply; 8+ messages in thread
From: Svein Seldal @ 2017-09-22 11:04 UTC (permalink / raw)
  To: Richard Purdie, yocto

[-- Attachment #1: Type: text/plain, Size: 1440 bytes --]



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?


Best regards,
Svein

[-- Attachment #2: Type: text/html, Size: 1905 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-09-22 13:39 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
  -- 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

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.