diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 25 | ||||
-rw-r--r-- | bitbake/lib/bb/utils.py | 32 |
2 files changed, 49 insertions, 8 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 26f69d105a..75e22f9c45 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py @@ -312,6 +312,31 @@ class VariableHistory(object): lines.append(line) return lines + def get_variable_items_files(self, var, d): + """ + Use variable history to map items added to a list variable and + the files in which they were added. + """ + history = self.variable(var) + finalitems = (d.getVar(var, True) or '').split() + filemap = {} + isset = False + for event in history: + if 'flag' in event: + continue + if event['op'] == '_remove': + continue + if isset and event['op'] == 'set?': + continue + isset = True + items = d.expand(event['detail']).split() + for item in items: + # This is a little crude but is belt-and-braces to avoid us + # having to handle every possible operation type specifically + if item in finalitems and not item in filemap: + filemap[item] = event['file'] + return filemap + def del_var_history(self, var, f=None, line=None): """If file f and line are not given, the entire history of var is deleted""" if var in self.variables: diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 607ffc5065..5b94432b37 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -29,6 +29,7 @@ import multiprocessing import fcntl import subprocess import glob +import fnmatch import traceback import errno import signal @@ -1262,11 +1263,26 @@ def get_file_layer(filename, d): 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 + def path_to_layer(path): + # 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, path): + matchlen = len(regex) + match = collection + return match + + result = None + bbfiles = (d.getVar('BBFILES', True) or '').split() + bbfilesmatch = False + for bbfilesentry in bbfiles: + if fnmatch.fnmatch(filename, bbfilesentry): + bbfilesmatch = True + result = path_to_layer(bbfilesentry) + + if not bbfilesmatch: + # Probably a bbclass + result = path_to_layer(filename) + + return result |