summaryrefslogtreecommitdiff
path: root/bitbake
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-11-29 08:50:19 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:45 +0000
commitb890c19a3308ff88d8450a2811afd2b084f3aafe (patch)
treed061bd7dce7a5bc245bb43bb854d26ecf72932c5 /bitbake
parent5bff22988c9b5cf8ada82f4488c6a74dc8e77e17 (diff)
downloadopenembedded-core-b890c19a3308ff88d8450a2811afd2b084f3aafe.tar.gz
openembedded-core-b890c19a3308ff88d8450a2811afd2b084f3aafe.tar.bz2
openembedded-core-b890c19a3308ff88d8450a2811afd2b084f3aafe.zip
cache: change to more incremental format
(Bitbake rev: 4fe4ffbef3885887c97eebe021edc3f23feab9ea) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cache.py55
1 files changed, 33 insertions, 22 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index b5be37ea8c..b3c632b81c 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -183,22 +183,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):
@@ -406,14 +418,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