diff options
Diffstat (limited to 'bitbake/lib/bb')
| -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): | |||
| 312 | lines.append(line) | 312 | lines.append(line) |
| 313 | return lines | 313 | return lines |
| 314 | 314 | ||
| 315 | def get_variable_items_files(self, var, d): | ||
| 316 | """ | ||
| 317 | Use variable history to map items added to a list variable and | ||
| 318 | the files in which they were added. | ||
| 319 | """ | ||
| 320 | history = self.variable(var) | ||
| 321 | finalitems = (d.getVar(var, True) or '').split() | ||
| 322 | filemap = {} | ||
| 323 | isset = False | ||
| 324 | for event in history: | ||
| 325 | if 'flag' in event: | ||
| 326 | continue | ||
| 327 | if event['op'] == '_remove': | ||
| 328 | continue | ||
| 329 | if isset and event['op'] == 'set?': | ||
| 330 | continue | ||
| 331 | isset = True | ||
| 332 | items = d.expand(event['detail']).split() | ||
| 333 | for item in items: | ||
| 334 | # This is a little crude but is belt-and-braces to avoid us | ||
| 335 | # having to handle every possible operation type specifically | ||
| 336 | if item in finalitems and not item in filemap: | ||
| 337 | filemap[item] = event['file'] | ||
| 338 | return filemap | ||
| 339 | |||
| 315 | def del_var_history(self, var, f=None, line=None): | 340 | def del_var_history(self, var, f=None, line=None): |
| 316 | """If file f and line are not given, the entire history of var is deleted""" | 341 | """If file f and line are not given, the entire history of var is deleted""" |
| 317 | if var in self.variables: | 342 | 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 | |||
| 29 | import fcntl | 29 | import fcntl |
| 30 | import subprocess | 30 | import subprocess |
| 31 | import glob | 31 | import glob |
| 32 | import fnmatch | ||
| 32 | import traceback | 33 | import traceback |
| 33 | import errno | 34 | import errno |
| 34 | import signal | 35 | import signal |
| @@ -1262,11 +1263,26 @@ def get_file_layer(filename, d): | |||
| 1262 | for collection in collections: | 1263 | for collection in collections: |
| 1263 | collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection, True) or '' | 1264 | collection_res[collection] = d.getVar('BBFILE_PATTERN_%s' % collection, True) or '' |
| 1264 | 1265 | ||
| 1265 | # Use longest path so we handle nested layers | 1266 | def path_to_layer(path): |
| 1266 | matchlen = 0 | 1267 | # Use longest path so we handle nested layers |
| 1267 | match = None | 1268 | matchlen = 0 |
| 1268 | for collection, regex in collection_res.iteritems(): | 1269 | match = None |
| 1269 | if len(regex) > matchlen and re.match(regex, filename): | 1270 | for collection, regex in collection_res.iteritems(): |
| 1270 | matchlen = len(regex) | 1271 | if len(regex) > matchlen and re.match(regex, path): |
| 1271 | match = collection | 1272 | matchlen = len(regex) |
| 1272 | return match | 1273 | match = collection |
| 1274 | return match | ||
| 1275 | |||
| 1276 | result = None | ||
| 1277 | bbfiles = (d.getVar('BBFILES', True) or '').split() | ||
| 1278 | bbfilesmatch = False | ||
| 1279 | for bbfilesentry in bbfiles: | ||
| 1280 | if fnmatch.fnmatch(filename, bbfilesentry): | ||
| 1281 | bbfilesmatch = True | ||
| 1282 | result = path_to_layer(bbfilesentry) | ||
| 1283 | |||
| 1284 | if not bbfilesmatch: | ||
| 1285 | # Probably a bbclass | ||
| 1286 | result = path_to_layer(filename) | ||
| 1287 | |||
| 1288 | return result | ||
