summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data_smart.py
diff options
context:
space:
mode:
authorDongxiao Xu <dongxiao.xu@intel.com>2012-02-23 21:47:13 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-23 22:52:15 +0000
commit8e737db4fc2ab90850c2fe91733011dc4e0a24df (patch)
tree5e4c649a13f7a3fcfab6373b7305407b71d56881 /bitbake/lib/bb/data_smart.py
parent99d326a818a49faf457c707ceeec6163bf8c8e16 (diff)
downloadpoky-8e737db4fc2ab90850c2fe91733011dc4e0a24df.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. (Bitbake rev: 1c1df03a6c4717bfd5faab144c4f8bbfcbae0b57) Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data_smart.py')
-rw-r--r--bitbake/lib/bb/data_smart.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py
index ea1347837c..24c7a8fd64 100644
--- a/bitbake/lib/bb/data_smart.py
+++ b/bitbake/lib/bb/data_smart.py
@@ -31,6 +31,7 @@ BitBake build tools.
31import copy, re 31import copy, re
32from collections import MutableMapping 32from collections import MutableMapping
33import logging 33import logging
34import hashlib
34import bb, bb.codeparser 35import bb, bb.codeparser
35from bb import utils 36from bb import utils
36from bb.COW import COWDictBase 37from bb.COW import COWDictBase
@@ -459,3 +460,23 @@ class DataSmart(MutableMapping):
459 460
460 def __delitem__(self, var): 461 def __delitem__(self, var):
461 self.delVar(var) 462 self.delVar(var)
463
464 def get_hash(self):
465 data = ""
466 keys = iter(self)
467 for key in keys:
468 if key in ["TIME", "DATE"]:
469 continue
470 if key == "__depends":
471 deps = list(self.getVar(key, False))
472 deps.sort()
473 value = [deps[i][0] for i in range(len(deps))]
474 elif key == "PATH":
475 path = list(set(self.getVar(key, False).split(':')))
476 path.sort()
477 value = " ".join(path)
478 else:
479 value = self.getVar(key, False) or ""
480 data = data + key + ': ' + str(value) + '\n'
481
482 return hashlib.md5(data).hexdigest()