bb/utils: add layer_path() function
PATCH 1/1 bb/utils: add layer_path() function
Add layer_path() which will return the path to a layer. Useful to programatically find other layers at build time, or from tinfoil.
--- bitbake/lib/bb/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+)
bitbake/lib/bb/utils.py +10 -0
@@ -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
Signature · 1 line
2.25.1
Quoted 20 lines · Ross Burton
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 <[email protected]>--- bitbake/lib/bb/utils.py | 10 ++++++++++ 1 file changed, 10 insertions(+)bitbake/lib/bb/utils.py +3
-0@@ -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.
bitbake/lib/bb/utils.py def get_file_layer(filename, d, collection_res={}): · line 1552
Quoted 10 lines
bitbake/lib/bb/utils.py +7
-0+ """ + 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