diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-11-29 08:50:19 -0700 |
---|---|---|
committer | Chris Larson <chris_larson@mentor.com> | 2010-11-29 08:50:19 -0700 |
commit | 4fe4ffbef3885887c97eebe021edc3f23feab9ea (patch) | |
tree | b1d2d89bbf322177930d6ac9bf2fa0de9d89655f /lib/bb/cache.py | |
parent | 0f68f8bcd0e0aa944f76f88a4a85c9bcc1e42bee (diff) | |
download | bitbake-4fe4ffbef3885887c97eebe021edc3f23feab9ea.tar.gz |
cache: change to more incremental format
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Diffstat (limited to 'lib/bb/cache.py')
-rw-r--r-- | lib/bb/cache.py | 55 |
1 files changed, 33 insertions, 22 deletions
diff --git a/lib/bb/cache.py b/lib/bb/cache.py index e2c030d44..981d8bd91 100644 --- a/lib/bb/cache.py +++ b/lib/bb/cache.py @@ -168,22 +168,34 @@ class Cache(object): newest_mtime = max(old_mtimes) if bb.parse.cached_mtime_noerror(self.cachefile) >= newest_mtime: + self.load_cachefile() + elif os.path.isfile(self.cachefile): + logger.info("Out of date cache found, rebuilding...") + + def load_cachefile(self): + with open(self.cachefile, "rb") as cachefile: + pickled = pickle.Unpickler(cachefile) try: - p = pickle.Unpickler(file(self.cachefile, "rb")) - self.depends_cache, version_data = p.load() - if version_data['CACHE_VER'] != __cache_version__: - raise ValueError('Cache Version Mismatch') - if version_data['BITBAKE_VER'] != bb.__version__: - raise ValueError('Bitbake Version Mismatch') - except EOFError: - logger.info("Truncated cache found, rebuilding...") - self.depends_cache = {} - except: - logger.info("Invalid cache found, rebuilding...") - self.depends_cache = {} - else: - if os.path.isfile(self.cachefile): - logger.info("Out of date cache found, rebuilding...") + cache_ver = pickled.load() + bitbake_ver = pickled.load() + except Exception: + logger.info('Invalid cache, rebuilding...') + return + + if cache_ver != __cache_version__: + logger.info('Cache version mismatch, rebuilding...') + return + elif bitbake_ver != bb.__version__: + logger.info('Bitbake version mismatch, rebuilding...') + return + + while cachefile: + try: + key = pickled.load() + value = pickled.load() + except Exception: + break + self.depends_cache[key] = value @staticmethod def virtualfn2realfn(virtualfn): @@ -391,14 +403,13 @@ class Cache(object): logger.debug(2, "Cache is clean, not saving.") return - version_data = { - 'CACHE_VER': __cache_version__, - 'BITBAKE_VER': bb.__version__, - } - with open(self.cachefile, "wb") as cachefile: - pickle.Pickler(cachefile, -1).dump([self.depends_cache, - version_data]) + pickler = pickle.Pickler(cachefile, pickle.HIGHEST_PROTOCOL) + pickler.dump(__cache_version__) + pickler.dump(bb.__version__) + for key, value in self.depends_cache.iteritems(): + pickler.dump(key) + pickler.dump(value) del self.depends_cache |