diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-10-17 14:40:38 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2018-10-17 23:19:47 +0100 |
commit | 796a20d24dc18479de1975a37b9e52a5ac75c73f (patch) | |
tree | aaefd0ba8843eedc771e8b7c491b74356be52933 /lib/bb/data.py | |
parent | 57d2ee17ae83a139a37081eb082e6184fa883581 (diff) | |
download | bitbake-796a20d24dc18479de1975a37b9e52a5ac75c73f.tar.gz |
data/siggen: Extract task hash generation code into a function
By creating a standalone function, we can add better functional testing
of this code.
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/data.py')
-rw-r--r-- | lib/bb/data.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/lib/bb/data.py b/lib/bb/data.py index fde4cba6b..d66d98cc8 100644 --- a/lib/bb/data.py +++ b/lib/bb/data.py @@ -38,6 +38,7 @@ the speed is more critical here. # Based on functions from the base bb module, Copyright 2003 Holger Schurig import sys, os, re +import hashlib if sys.argv[0][-5:] == "pydoc": path = os.path.dirname(os.path.dirname(sys.argv[1])) else: @@ -405,6 +406,43 @@ def generate_dependencies(d): #print "For %s: %s" % (task, str(deps[task])) return tasklist, deps, values +def generate_dependency_hash(tasklist, gendeps, lookupcache, whitelist, fn): + taskdeps = {} + basehash = {} + + for task in tasklist: + data = lookupcache[task] + + if data is None: + bb.error("Task %s from %s seems to be empty?!" % (task, fn)) + data = '' + + gendeps[task] -= whitelist + newdeps = gendeps[task] + seen = set() + while newdeps: + nextdeps = newdeps + seen |= nextdeps + newdeps = set() + for dep in nextdeps: + if dep in whitelist: + continue + gendeps[dep] -= whitelist + newdeps |= gendeps[dep] + newdeps -= seen + + alldeps = sorted(seen) + for dep in alldeps: + data = data + dep + var = lookupcache[dep] + if var is not None: + data = data + str(var) + k = fn + "." + task + basehash[k] = hashlib.md5(data.encode("utf-8")).hexdigest() + taskdeps[task] = alldeps + + return taskdeps, basehash + def inherits_class(klass, d): val = d.getVar('__inherit_cache', False) or [] needle = os.path.join('classes', '%s.bbclass' % klass) |