From 8e737db4fc2ab90850c2fe91733011dc4e0a24df Mon Sep 17 00:00:00 2001 From: Dongxiao Xu Date: Thu, 23 Feb 2012 21:47:13 +0800 Subject: 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 Signed-off-by: Richard Purdie --- bitbake/lib/bb/data_smart.py | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'bitbake/lib/bb/data_smart.py') 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. 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() -- cgit v1.2.3-54-g00ecf