bitbake-devel.lists.openembedded.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] bb/utils: add layer_path() function
@ 2021-07-07 12:20 Ross Burton
  2021-07-07 15:44 ` [bitbake-devel] " Mark Hatle
  0 siblings, 1 reply; 2+ messages in thread
From: Ross Burton @ 2021-07-07 12:20 UTC (permalink / raw)
  To: bitbake-devel

Add layer_path() which will return the path to a layer. Useful to
programatically find other layers at build time, or from tinfoil.

Signed-off-by: Ross Burton <ross.burton@arm.com>
---
 bitbake/lib/bb/utils.py | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 6ba1d2a3766..951fa3cb0e4 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -1537,6 +1537,16 @@ def get_file_layer(filename, d, collection_res={}):
 
     return result
 
+def layer_path(layername, d):
+    """
+    Return the path to the specified layer, or None if the layer isn't present.
+    """
+    bbpath = d.getVar("BBPATH").split(":")
+    pattern = d.getVar('BBFILE_PATTERN_' + layername)
+    for path in reversed(sorted(bbpath)):
+        if re.match(pattern, path + "/"):
+            return path
+    return None
 
 # Constant taken from http://linux.die.net/include/linux/prctl.h
 PR_SET_PDEATHSIG = 1
-- 
2.25.1


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

* Re: [bitbake-devel] [PATCH] bb/utils: add layer_path() function
  2021-07-07 12:20 [PATCH] bb/utils: add layer_path() function Ross Burton
@ 2021-07-07 15:44 ` Mark Hatle
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Hatle @ 2021-07-07 15:44 UTC (permalink / raw)
  To: Ross Burton, bitbake-devel



On 7/7/21 7:20 AM, Ross Burton wrote:
> Add layer_path() which will return the path to a layer. Useful to
> programatically find other layers at build time, or from tinfoil.
> 
> Signed-off-by: Ross Burton <ross.burton@arm.com>
> ---
>  bitbake/lib/bb/utils.py | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
> index 6ba1d2a3766..951fa3cb0e4 100644
> --- a/bitbake/lib/bb/utils.py
> +++ b/bitbake/lib/bb/utils.py
> @@ -1537,6 +1537,16 @@ def get_file_layer(filename, d, collection_res={}):
>  
>      return result
>  
> +def layer_path(layername, d):
> +    """
> +    Return the path to the specified layer, or None if the layer isn't present.
> +    """
> +    bbpath = d.getVar("BBPATH").split(":")
> +    pattern = d.getVar('BBFILE_PATTERN_' + layername)
> +    for path in reversed(sorted(bbpath)):
> +        if re.match(pattern, path + "/"):
> +            return path
> +    return None
>  
>  # Constant taken from http://linux.die.net/include/linux/prctl.h
>  PR_SET_PDEATHSIG = 1
> 

Would it be easier to capture the layer path while processing the layers, since
at that point there is a LAYERDIR available?

Something like BB_LAYERDIR_<collection>, then we can use that directly in any
users.  This could replace the few layers people have that manually set their
own layer paths?

I'm not sure where the processing for the layer.conf happens, but that would
seem like the place to put it and that would also avoid having to guess based on
the BBFILE_PATTERN and BBPATH.

I've definitely seen layers where BBPATH does NOT include a specific layer's
path.  They are extremely rare, but I've seen it before.

--Mark

> 
> 
> 

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

end of thread, other threads:[~2021-07-07 15:44 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-07 12:20 [PATCH] bb/utils: add layer_path() function Ross Burton
2021-07-07 15:44 ` [bitbake-devel] " Mark Hatle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).