diff options
| author | Paul Eggleton <paul.eggleton@linux.intel.com> | 2015-05-22 16:42:21 +0100 |
|---|---|---|
| committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2015-05-23 08:21:41 +0100 |
| commit | ca6ef30c7a33b3860d9b0d0da51d9b8786073170 (patch) | |
| tree | dfa54f28228e7f6dcd1f7d321fb7a426e891d03a /bitbake | |
| parent | 59e4f9fc1255b7888ffccc87ce6cc3f2b8bf98c3 (diff) | |
| download | poky-ca6ef30c7a33b3860d9b0d0da51d9b8786073170.tar.gz | |
bitbake: 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].
(Bitbake master rev: 3bf9c8830c5d5eea5502230d5af84ebd87ad5849)
(Bitbake rev: 8dcd83e5edb1cf3307b610d3bb8d54733ea7356d)
Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
| -rw-r--r-- | bitbake/lib/bb/utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index c97f3ef81f..1681efd7e5 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
| @@ -1097,3 +1097,19 @@ def edit_bblayers_conf(bblayers_conf, add, remove): | |||
| 1097 | 1097 | ||
| 1098 | return (notadded, notremoved) | 1098 | return (notadded, notremoved) |
| 1099 | 1099 | ||
| 1100 | |||
| 1101 | def get_file_layer(filename, d): | ||
| 1102 | """Determine the collection (as defined by a layer's layer.conf file) containing the specified file""" | ||
| 1103 | collections = (d.getVar('BBFILE_COLLECTIONS', True) or '').split() | ||
| 1104 | collection_res = {} | ||
| 1105 | for collection in collections: | ||
| 1106 | collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection, True) or '' | ||
| 1107 | |||
| 1108 | # Use longest path so we handle nested layers | ||
| 1109 | matchlen = 0 | ||
| 1110 | match = None | ||
| 1111 | for collection, regex in collection_res.iteritems(): | ||
| 1112 | if len(regex) > matchlen and re.match(regex, filename): | ||
| 1113 | matchlen = len(regex) | ||
| 1114 | match = collection | ||
| 1115 | return match | ||
