diff options
author | Dongxiao Xu <dongxiao.xu@intel.com> | 2012-02-23 21:47:13 +0800 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2012-02-23 22:40:18 +0000 |
commit | 1c1df03a6c4717bfd5faab144c4f8bbfcbae0b57 (patch) | |
tree | d0890dc01517a0318aaac8e1e1ffd90fe13e189b /lib/bb/data_smart.py | |
parent | f588ba69622a2df35417ced184e56c79ac1b40d5 (diff) | |
download | bitbake-contrib-1c1df03a6c4717bfd5faab144c4f8bbfcbae0b57.tar.gz |
cache: Use configuration's hash value to validate cache
Previously we use the file time stamp to judge if a cache is valid.
Here this commit introduce a new method, which calculates the total
hash value for a certain configuration's key/value paris, and tag
it into cache filename, for example, bb_cache.dat.xxxyyyzzz.
This mechanism also ensures the cache's correctness if user
dynamically setting variables from some frontend GUI, like HOB.
Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data_smart.py')
-rw-r--r-- | lib/bb/data_smart.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py index ea1347837..24c7a8fd6 100644 --- a/lib/bb/data_smart.py +++ b/lib/bb/data_smart.py @@ -31,6 +31,7 @@ BitBake build tools. import copy, re from collections import MutableMapping import logging +import hashlib import bb, bb.codeparser from bb import utils from bb.COW import COWDictBase @@ -459,3 +460,23 @@ class DataSmart(MutableMapping): def __delitem__(self, var): self.delVar(var) + + def get_hash(self): + data = "" + keys = iter(self) + for key in keys: + if key in ["TIME", "DATE"]: + continue + if key == "__depends": + deps = list(self.getVar(key, False)) + deps.sort() + value = [deps[i][0] for i in range(len(deps))] + elif key == "PATH": + path = list(set(self.getVar(key, False).split(':'))) + path.sort() + value = " ".join(path) + else: + value = self.getVar(key, False) or "" + data = data + key + ': ' + str(value) + '\n' + + return hashlib.md5(data).hexdigest() |