aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2015-05-18 16:08:34 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-19 08:19:33 +0100
commit3bf9c8830c5d5eea5502230d5af84ebd87ad5849 (patch)
tree36a1dedb79fb7228e65e6bd64545aa09c0b64de8 /lib/bb/utils.py
parent76f095107a0eaf987a5a6a48eed7b98f87aea121 (diff)
downloadbitbake-3bf9c8830c5d5eea5502230d5af84ebd87ad5849.tar.gz
lib/bb/utils: add function to get layer containing a file
In certain contexts it can be useful to find the layer that a file (e.g. a recipe) appears in. Implements [YOCTO #7723]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index c97f3ef81..1681efd7e 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -1097,3 +1097,19 @@ def edit_bblayers_conf(bblayers_conf, add, remove):
return (notadded, notremoved)
+
+def get_file_layer(filename, d):
+ """Determine the collection (as defined by a layer's layer.conf file) containing the specified file"""
+ collections = (d.getVar('BBFILE_COLLECTIONS', True) or '').split()
+ collection_res = {}
+ for collection in collections:
+ collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection, True) or ''
+
+ # Use longest path so we handle nested layers
+ matchlen = 0
+ match = None
+ for collection, regex in collection_res.iteritems():
+ if len(regex) > matchlen and re.match(regex, filename):
+ matchlen = len(regex)
+ match = collection
+ return match