diff options
Diffstat (limited to 'bitbake/lib/bb/cache.py')
| -rw-r--r-- | bitbake/lib/bb/cache.py | 53 |
1 files changed, 26 insertions, 27 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py index c6f3794d5e..255c6168dd 100644 --- a/bitbake/lib/bb/cache.py +++ b/bitbake/lib/bb/cache.py | |||
| @@ -29,14 +29,17 @@ | |||
| 29 | 29 | ||
| 30 | 30 | ||
| 31 | import os | 31 | import os |
| 32 | import logging | ||
| 32 | import bb.data | 33 | import bb.data |
| 33 | import bb.utils | 34 | import bb.utils |
| 34 | 35 | ||
| 36 | logger = logging.getLogger("BitBake.Cache") | ||
| 37 | |||
| 35 | try: | 38 | try: |
| 36 | import cPickle as pickle | 39 | import cPickle as pickle |
| 37 | except ImportError: | 40 | except ImportError: |
| 38 | import pickle | 41 | import pickle |
| 39 | bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.") | 42 | logger.info("Importing cPickle failed. Falling back to a very slow implementation.") |
| 40 | 43 | ||
| 41 | __cache_version__ = "132" | 44 | __cache_version__ = "132" |
| 42 | 45 | ||
| @@ -57,13 +60,13 @@ class Cache: | |||
| 57 | 60 | ||
| 58 | if self.cachedir in [None, '']: | 61 | if self.cachedir in [None, '']: |
| 59 | self.has_cache = False | 62 | self.has_cache = False |
| 60 | bb.msg.note(1, bb.msg.domain.Cache, "Not using a cache. Set CACHE = <directory> to enable.") | 63 | logger.info("Not using a cache. Set CACHE = <directory> to enable.") |
| 61 | return | 64 | return |
| 62 | 65 | ||
| 63 | self.has_cache = True | 66 | self.has_cache = True |
| 64 | self.cachefile = os.path.join(self.cachedir, "bb_cache.dat") | 67 | self.cachefile = os.path.join(self.cachedir, "bb_cache.dat") |
| 65 | 68 | ||
| 66 | bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir) | 69 | logger.debug(1, "Using cache in '%s'", self.cachedir) |
| 67 | bb.utils.mkdirhier(self.cachedir) | 70 | bb.utils.mkdirhier(self.cachedir) |
| 68 | 71 | ||
| 69 | # If any of configuration.data's dependencies are newer than the | 72 | # If any of configuration.data's dependencies are newer than the |
| @@ -84,14 +87,14 @@ class Cache: | |||
| 84 | if version_data['BITBAKE_VER'] != bb.__version__: | 87 | if version_data['BITBAKE_VER'] != bb.__version__: |
| 85 | raise ValueError('Bitbake Version Mismatch') | 88 | raise ValueError('Bitbake Version Mismatch') |
| 86 | except EOFError: | 89 | except EOFError: |
| 87 | bb.msg.note(1, bb.msg.domain.Cache, "Truncated cache found, rebuilding...") | 90 | logger.info("Truncated cache found, rebuilding...") |
| 88 | self.depends_cache = {} | 91 | self.depends_cache = {} |
| 89 | except: | 92 | except: |
| 90 | bb.msg.note(1, bb.msg.domain.Cache, "Invalid cache found, rebuilding...") | 93 | logger.info("Invalid cache found, rebuilding...") |
| 91 | self.depends_cache = {} | 94 | self.depends_cache = {} |
| 92 | else: | 95 | else: |
| 93 | if os.path.isfile(self.cachefile): | 96 | if os.path.isfile(self.cachefile): |
| 94 | bb.msg.note(1, bb.msg.domain.Cache, "Out of date cache found, rebuilding...") | 97 | logger.info("Out of date cache found, rebuilding...") |
| 95 | 98 | ||
| 96 | def getVar(self, var, fn, exp = 0): | 99 | def getVar(self, var, fn, exp = 0): |
| 97 | """ | 100 | """ |
| @@ -111,7 +114,7 @@ class Cache: | |||
| 111 | if fn != self.data_fn: | 114 | if fn != self.data_fn: |
| 112 | # We're trying to access data in the cache which doesn't exist | 115 | # We're trying to access data in the cache which doesn't exist |
| 113 | # yet setData hasn't been called to setup the right access. Very bad. | 116 | # yet setData hasn't been called to setup the right access. Very bad. |
| 114 | bb.msg.error(bb.msg.domain.Cache, "Parsing error data_fn %s and fn %s don't match" % (self.data_fn, fn)) | 117 | logger.error("data_fn %s and fn %s don't match", self.data_fn, fn) |
| 115 | 118 | ||
| 116 | self.cacheclean = False | 119 | self.cacheclean = False |
| 117 | result = bb.data.getVar(var, self.data, exp) | 120 | result = bb.data.getVar(var, self.data, exp) |
| @@ -152,7 +155,6 @@ class Cache: | |||
| 152 | if virtualfn.startswith('virtual:'): | 155 | if virtualfn.startswith('virtual:'): |
| 153 | cls = virtualfn.split(':', 2)[1] | 156 | cls = virtualfn.split(':', 2)[1] |
| 154 | fn = virtualfn.replace('virtual:' + cls + ':', '') | 157 | fn = virtualfn.replace('virtual:' + cls + ':', '') |
| 155 | #bb.msg.debug(2, bb.msg.domain.Cache, "virtualfn2realfn %s to %s %s" % (virtualfn, fn, cls)) | ||
| 156 | return (fn, cls) | 158 | return (fn, cls) |
| 157 | 159 | ||
| 158 | def realfn2virtual(self, realfn, cls): | 160 | def realfn2virtual(self, realfn, cls): |
| @@ -160,9 +162,7 @@ class Cache: | |||
| 160 | Convert a real filename + the associated subclass keyword to a virtual filename | 162 | Convert a real filename + the associated subclass keyword to a virtual filename |
| 161 | """ | 163 | """ |
| 162 | if cls == "": | 164 | if cls == "": |
| 163 | #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and '%s' to %s" % (realfn, cls, realfn)) | ||
| 164 | return realfn | 165 | return realfn |
| 165 | #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn)) | ||
| 166 | return "virtual:" + cls + ":" + realfn | 166 | return "virtual:" + cls + ":" + realfn |
| 167 | 167 | ||
| 168 | def loadDataFull(self, virtualfn, appends, cfgData): | 168 | def loadDataFull(self, virtualfn, appends, cfgData): |
| @@ -173,7 +173,7 @@ class Cache: | |||
| 173 | 173 | ||
| 174 | (fn, cls) = self.virtualfn2realfn(virtualfn) | 174 | (fn, cls) = self.virtualfn2realfn(virtualfn) |
| 175 | 175 | ||
| 176 | bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn) | 176 | logger.debug(1, "Parsing %s (full)", fn) |
| 177 | 177 | ||
| 178 | bb_data = self.load_bbfile(fn, appends, cfgData) | 178 | bb_data = self.load_bbfile(fn, appends, cfgData) |
| 179 | return bb_data[cls] | 179 | return bb_data[cls] |
| @@ -198,13 +198,13 @@ class Cache: | |||
| 198 | virtualfn = self.realfn2virtual(fn, cls) | 198 | virtualfn = self.realfn2virtual(fn, cls) |
| 199 | if self.depends_cache[virtualfn]["__SKIPPED"]: | 199 | if self.depends_cache[virtualfn]["__SKIPPED"]: |
| 200 | skipped += 1 | 200 | skipped += 1 |
| 201 | bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn) | 201 | logger.debug(1, "Skipping %s", virtualfn) |
| 202 | continue | 202 | continue |
| 203 | self.handle_data(virtualfn, cacheData) | 203 | self.handle_data(virtualfn, cacheData) |
| 204 | virtuals += 1 | 204 | virtuals += 1 |
| 205 | return True, skipped, virtuals | 205 | return True, skipped, virtuals |
| 206 | 206 | ||
| 207 | bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn) | 207 | logger.debug(1, "Parsing %s", fn) |
| 208 | 208 | ||
| 209 | bb_data = self.load_bbfile(fn, appends, cfgData) | 209 | bb_data = self.load_bbfile(fn, appends, cfgData) |
| 210 | 210 | ||
| @@ -213,7 +213,7 @@ class Cache: | |||
| 213 | self.setData(virtualfn, fn, bb_data[data]) | 213 | self.setData(virtualfn, fn, bb_data[data]) |
| 214 | if self.getVar("__SKIPPED", virtualfn): | 214 | if self.getVar("__SKIPPED", virtualfn): |
| 215 | skipped += 1 | 215 | skipped += 1 |
| 216 | bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn) | 216 | logger.debug(1, "Skipping %s", virtualfn) |
| 217 | else: | 217 | else: |
| 218 | self.handle_data(virtualfn, cacheData) | 218 | self.handle_data(virtualfn, cacheData) |
| 219 | virtuals += 1 | 219 | virtuals += 1 |
| @@ -248,7 +248,7 @@ class Cache: | |||
| 248 | 248 | ||
| 249 | # File isn't in depends_cache | 249 | # File isn't in depends_cache |
| 250 | if not fn in self.depends_cache: | 250 | if not fn in self.depends_cache: |
| 251 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % fn) | 251 | logger.debug(2, "Cache: %s is not cached", fn) |
| 252 | self.remove(fn) | 252 | self.remove(fn) |
| 253 | return False | 253 | return False |
| 254 | 254 | ||
| @@ -256,13 +256,13 @@ class Cache: | |||
| 256 | 256 | ||
| 257 | # Check file still exists | 257 | # Check file still exists |
| 258 | if mtime == 0: | 258 | if mtime == 0: |
| 259 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s no longer exists" % fn) | 259 | logger.debug(2, "Cache: %s no longer exists", fn) |
| 260 | self.remove(fn) | 260 | self.remove(fn) |
| 261 | return False | 261 | return False |
| 262 | 262 | ||
| 263 | # Check the file's timestamp | 263 | # Check the file's timestamp |
| 264 | if mtime != self.getVar("CACHETIMESTAMP", fn, True): | 264 | if mtime != self.getVar("CACHETIMESTAMP", fn, True): |
| 265 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s changed" % fn) | 265 | logger.debug(2, "Cache: %s changed", fn) |
| 266 | self.remove(fn) | 266 | self.remove(fn) |
| 267 | return False | 267 | return False |
| 268 | 268 | ||
| @@ -277,11 +277,10 @@ class Cache: | |||
| 277 | return False | 277 | return False |
| 278 | 278 | ||
| 279 | if (fmtime != old_mtime): | 279 | if (fmtime != old_mtime): |
| 280 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s's dependency %s changed" % (fn, f)) | 280 | logger.debug(2, "Cache: %s's dependency %s changed", fn, f) |
| 281 | self.remove(fn) | 281 | self.remove(fn) |
| 282 | return False | 282 | return False |
| 283 | 283 | ||
| 284 | #bb.msg.debug(2, bb.msg.domain.Cache, "Depends Cache: %s is clean" % fn) | ||
| 285 | if not fn in self.clean: | 284 | if not fn in self.clean: |
| 286 | self.clean[fn] = "" | 285 | self.clean[fn] = "" |
| 287 | 286 | ||
| @@ -292,16 +291,16 @@ class Cache: | |||
| 292 | virtualfn = self.realfn2virtual(fn, cls) | 291 | virtualfn = self.realfn2virtual(fn, cls) |
| 293 | self.clean[virtualfn] = "" | 292 | self.clean[virtualfn] = "" |
| 294 | if not virtualfn in self.depends_cache: | 293 | if not virtualfn in self.depends_cache: |
| 295 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: %s is not cached" % virtualfn) | 294 | logger.debug(2, "Cache: %s is not cached", virtualfn) |
| 296 | invalid = True | 295 | invalid = True |
| 297 | 296 | ||
| 298 | # If any one of the varients is not present, mark cache as invalid for all | 297 | # If any one of the varients is not present, mark cache as invalid for all |
| 299 | if invalid: | 298 | if invalid: |
| 300 | for cls in (multi or "").split(): | 299 | for cls in (multi or "").split(): |
| 301 | virtualfn = self.realfn2virtual(fn, cls) | 300 | virtualfn = self.realfn2virtual(fn, cls) |
| 302 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: Removing %s from cache" % virtualfn) | 301 | logger.debug(2, "Cache: Removing %s from cache", virtualfn) |
| 303 | del self.clean[virtualfn] | 302 | del self.clean[virtualfn] |
| 304 | bb.msg.debug(2, bb.msg.domain.Cache, "Cache: Removing %s from cache" % fn) | 303 | logger.debug(2, "Cache: removing %s from cache", fn) |
| 305 | del self.clean[fn] | 304 | del self.clean[fn] |
| 306 | return False | 305 | return False |
| 307 | 306 | ||
| @@ -312,7 +311,7 @@ class Cache: | |||
| 312 | Remove a fn from the cache | 311 | Remove a fn from the cache |
| 313 | Called from the parser in error cases | 312 | Called from the parser in error cases |
| 314 | """ | 313 | """ |
| 315 | bb.msg.debug(1, bb.msg.domain.Cache, "Removing %s from cache" % fn) | 314 | logger.debug(1, "Removing %s from cache", fn) |
| 316 | if fn in self.depends_cache: | 315 | if fn in self.depends_cache: |
| 317 | del self.depends_cache[fn] | 316 | del self.depends_cache[fn] |
| 318 | if fn in self.clean: | 317 | if fn in self.clean: |
| @@ -329,7 +328,7 @@ class Cache: | |||
| 329 | return | 328 | return |
| 330 | 329 | ||
| 331 | if self.cacheclean: | 330 | if self.cacheclean: |
| 332 | bb.msg.note(1, bb.msg.domain.Cache, "Cache is clean, not saving.") | 331 | logger.info("Cache is clean, not saving.") |
| 333 | return | 332 | return |
| 334 | 333 | ||
| 335 | version_data = {} | 334 | version_data = {} |
| @@ -339,10 +338,10 @@ class Cache: | |||
| 339 | cache_data = copy.copy(self.depends_cache) | 338 | cache_data = copy.copy(self.depends_cache) |
| 340 | for fn in self.depends_cache: | 339 | for fn in self.depends_cache: |
| 341 | if '__BB_DONT_CACHE' in self.depends_cache[fn] and self.depends_cache[fn]['__BB_DONT_CACHE']: | 340 | if '__BB_DONT_CACHE' in self.depends_cache[fn] and self.depends_cache[fn]['__BB_DONT_CACHE']: |
| 342 | bb.msg.debug(2, bb.msg.domain.Cache, "Not caching %s, marked as not cacheable" % fn) | 341 | logger.debug(2, "Not caching %s, marked as not cacheable", fn) |
| 343 | del cache_data[fn] | 342 | del cache_data[fn] |
| 344 | elif 'PV' in self.depends_cache[fn] and 'SRCREVINACTION' in self.depends_cache[fn]['PV']: | 343 | elif 'PV' in self.depends_cache[fn] and 'SRCREVINACTION' in self.depends_cache[fn]['PV']: |
| 345 | bb.msg.error(bb.msg.domain.Cache, "Not caching %s as it had SRCREVINACTION in PV. Please report this bug" % fn) | 344 | logger.error("Not caching %s as it had SRCREVINACTION in PV. Please report this bug", fn) |
| 346 | del cache_data[fn] | 345 | del cache_data[fn] |
| 347 | 346 | ||
| 348 | p = pickle.Pickler(file(self.cachefile, "wb" ), -1 ) | 347 | p = pickle.Pickler(file(self.cachefile, "wb" ), -1 ) |
| @@ -360,7 +359,7 @@ class Cache: | |||
| 360 | pe = self.getVar('PE', file_name, True) or "0" | 359 | pe = self.getVar('PE', file_name, True) or "0" |
| 361 | pv = self.getVar('PV', file_name, True) | 360 | pv = self.getVar('PV', file_name, True) |
| 362 | if 'SRCREVINACTION' in pv: | 361 | if 'SRCREVINACTION' in pv: |
| 363 | bb.msg.note(1, bb.msg.domain.Cache, "Found SRCREVINACTION in PV (%s) or %s. Please report this bug." % (pv, file_name)) | 362 | logger.info("Found SRCREVINACTION in PV (%s) or %s. Please report this bug.", pv, file_name) |
| 364 | pr = self.getVar('PR', file_name, True) | 363 | pr = self.getVar('PR', file_name, True) |
| 365 | dp = int(self.getVar('DEFAULT_PREFERENCE', file_name, True) or "0") | 364 | dp = int(self.getVar('DEFAULT_PREFERENCE', file_name, True) or "0") |
| 366 | depends = bb.utils.explode_deps(self.getVar("DEPENDS", file_name, True) or "") | 365 | depends = bb.utils.explode_deps(self.getVar("DEPENDS", file_name, True) or "") |
