diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-16 13:06:10 -0700 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:40 +0000 |
commit | f207bb7c9345bbf822617efe85a1be34b4e670b3 (patch) | |
tree | 68bafe8da7aeefa8a35f212a68f9a95fd847ca17 /bitbake/lib/bb/cache.py | |
parent | 9c7c18d06fcee628a847ad696be596383e168378 (diff) | |
download | poky-f207bb7c9345bbf822617efe85a1be34b4e670b3.tar.gz |
cache: make use of defaultdict
(Bitbake rev: 7171019b11ad656d0edb979564941fcf92ab0a02)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r-- | bitbake/lib/bb/cache.py | 44 |
1 files changed, 10 insertions, 34 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index 9756ada960..58ada52290 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
@@ -30,6 +30,7 @@ | |||
30 | 30 | ||
31 | import os | 31 | import os |
32 | import logging | 32 | import logging |
33 | from collections import defaultdict | ||
33 | import bb.data | 34 | import bb.data |
34 | import bb.utils | 35 | import bb.utils |
35 | 36 | ||
@@ -374,8 +375,6 @@ class Cache: | |||
374 | cacheData.task_deps[file_name] = self.getVar("_task_deps", file_name) | 375 | cacheData.task_deps[file_name] = self.getVar("_task_deps", file_name) |
375 | 376 | ||
376 | # build PackageName to FileName lookup table | 377 | # build PackageName to FileName lookup table |
377 | if pn not in cacheData.pkg_pn: | ||
378 | cacheData.pkg_pn[pn] = [] | ||
379 | cacheData.pkg_pn[pn].append(file_name) | 378 | cacheData.pkg_pn[pn].append(file_name) |
380 | 379 | ||
381 | cacheData.stamp[file_name] = self.getVar('STAMP', file_name, True) | 380 | cacheData.stamp[file_name] = self.getVar('STAMP', file_name, True) |
@@ -397,18 +396,12 @@ class Cache: | |||
397 | # Build forward and reverse provider hashes | 396 | # Build forward and reverse provider hashes |
398 | # Forward: virtual -> [filenames] | 397 | # Forward: virtual -> [filenames] |
399 | # Reverse: PN -> [virtuals] | 398 | # Reverse: PN -> [virtuals] |
400 | if pn not in cacheData.pn_provides: | ||
401 | cacheData.pn_provides[pn] = [] | ||
402 | |||
403 | cacheData.fn_provides[file_name] = provides | 399 | cacheData.fn_provides[file_name] = provides |
404 | for provide in provides: | 400 | for provide in provides: |
405 | if provide not in cacheData.providers: | ||
406 | cacheData.providers[provide] = [] | ||
407 | cacheData.providers[provide].append(file_name) | 401 | cacheData.providers[provide].append(file_name) |
408 | if not provide in cacheData.pn_provides[pn]: | 402 | if not provide in cacheData.pn_provides[pn]: |
409 | cacheData.pn_provides[pn].append(provide) | 403 | cacheData.pn_provides[pn].append(provide) |
410 | 404 | ||
411 | cacheData.deps[file_name] = [] | ||
412 | for dep in depends: | 405 | for dep in depends: |
413 | if not dep in cacheData.deps[file_name]: | 406 | if not dep in cacheData.deps[file_name]: |
414 | cacheData.deps[file_name].append(dep) | 407 | cacheData.deps[file_name].append(dep) |
@@ -418,36 +411,19 @@ class Cache: | |||
418 | # Build reverse hash for PACKAGES, so runtime dependencies | 411 | # Build reverse hash for PACKAGES, so runtime dependencies |
419 | # can be be resolved (RDEPENDS, RRECOMMENDS etc.) | 412 | # can be be resolved (RDEPENDS, RRECOMMENDS etc.) |
420 | for package in packages: | 413 | for package in packages: |
421 | if not package in cacheData.packages: | ||
422 | cacheData.packages[package] = [] | ||
423 | cacheData.packages[package].append(file_name) | 414 | cacheData.packages[package].append(file_name) |
424 | rprovides += (self.getVar("RPROVIDES_%s" % package, file_name, 1) or "").split() | 415 | rprovides += (self.getVar("RPROVIDES_%s" % package, file_name, 1) or "").split() |
425 | 416 | ||
426 | for package in packages_dynamic: | 417 | for package in packages_dynamic: |
427 | if not package in cacheData.packages_dynamic: | ||
428 | cacheData.packages_dynamic[package] = [] | ||
429 | cacheData.packages_dynamic[package].append(file_name) | 418 | cacheData.packages_dynamic[package].append(file_name) |
430 | 419 | ||
431 | for rprovide in rprovides: | 420 | for rprovide in rprovides: |
432 | if not rprovide in cacheData.rproviders: | ||
433 | cacheData.rproviders[rprovide] = [] | ||
434 | cacheData.rproviders[rprovide].append(file_name) | 421 | cacheData.rproviders[rprovide].append(file_name) |
435 | 422 | ||
436 | # Build hash of runtime depends and rececommends | 423 | # Build hash of runtime depends and rececommends |
437 | |||
438 | if not file_name in cacheData.rundeps: | ||
439 | cacheData.rundeps[file_name] = {} | ||
440 | if not file_name in cacheData.runrecs: | ||
441 | cacheData.runrecs[file_name] = {} | ||
442 | |||
443 | rdepends = bb.utils.explode_deps(self.getVar('RDEPENDS', file_name, True) or "") | 424 | rdepends = bb.utils.explode_deps(self.getVar('RDEPENDS', file_name, True) or "") |
444 | rrecommends = bb.utils.explode_deps(self.getVar('RRECOMMENDS', file_name, True) or "") | 425 | rrecommends = bb.utils.explode_deps(self.getVar('RRECOMMENDS', file_name, True) or "") |
445 | for package in packages + [pn]: | 426 | for package in packages + [pn]: |
446 | if not package in cacheData.rundeps[file_name]: | ||
447 | cacheData.rundeps[file_name][package] = [] | ||
448 | if not package in cacheData.runrecs[file_name]: | ||
449 | cacheData.runrecs[file_name][package] = [] | ||
450 | |||
451 | rdeps_pkg = bb.utils.explode_deps(self.getVar('RDEPENDS_%s' % package, file_name, True) or "") | 427 | rdeps_pkg = bb.utils.explode_deps(self.getVar('RDEPENDS_%s' % package, file_name, True) or "") |
452 | cacheData.rundeps[file_name][package] = rdepends + rdeps_pkg | 428 | cacheData.rundeps[file_name][package] = rdepends + rdeps_pkg |
453 | rrecs_pkg = bb.utils.explode_deps(self.getVar('RDEPENDS_%s' % package, file_name, True) or "") | 429 | rrecs_pkg = bb.utils.explode_deps(self.getVar('RDEPENDS_%s' % package, file_name, True) or "") |
@@ -531,21 +507,21 @@ class CacheData: | |||
531 | Direct cache variables | 507 | Direct cache variables |
532 | (from Cache.handle_data) | 508 | (from Cache.handle_data) |
533 | """ | 509 | """ |
534 | self.providers = {} | 510 | self.providers = defaultdict(list) |
535 | self.rproviders = {} | 511 | self.rproviders = defaultdict(list) |
536 | self.packages = {} | 512 | self.packages = defaultdict(list) |
537 | self.packages_dynamic = {} | 513 | self.packages_dynamic = defaultdict(list) |
538 | self.possible_world = [] | 514 | self.possible_world = [] |
539 | self.pkg_pn = {} | 515 | self.pkg_pn = defaultdict(list) |
540 | self.pkg_fn = {} | 516 | self.pkg_fn = {} |
541 | self.pkg_pepvpr = {} | 517 | self.pkg_pepvpr = {} |
542 | self.pkg_dp = {} | 518 | self.pkg_dp = {} |
543 | self.pn_provides = {} | 519 | self.pn_provides = defaultdict(list) |
544 | self.fn_provides = {} | 520 | self.fn_provides = {} |
545 | self.all_depends = [] | 521 | self.all_depends = [] |
546 | self.deps = {} | 522 | self.deps = defaultdict(list) |
547 | self.rundeps = {} | 523 | self.rundeps = defaultdict(lambda: defaultdict(list)) |
548 | self.runrecs = {} | 524 | self.runrecs = defaultdict(lambda: defaultdict(list)) |
549 | self.task_queues = {} | 525 | self.task_queues = {} |
550 | self.task_deps = {} | 526 | self.task_deps = {} |
551 | self.stamp = {} | 527 | self.stamp = {} |