summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/siggen.py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-09-28 22:24:13 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-09-29 10:47:17 +0100
commit9747616600b424e8c0d7075a9b516a12d65a17c3 (patch)
tree5a59f32ae06bb18565bdffe12414902337b8fa93 /bitbake/lib/bb/siggen.py
parent8976fa69d0ddfdad24fe041f4b88c853dc7a33a2 (diff)
downloadpoky-9747616600b424e8c0d7075a9b516a12d65a17c3.tar.gz
bitbake/siggen: Ensure full signature data is not held unless needed, reducing memory consumption
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/siggen.py')
-rw-r--r--bitbake/lib/bb/siggen.py29
1 files changed, 18 insertions, 11 deletions
diff --git a/bitbake/lib/bb/siggen.py b/bitbake/lib/bb/siggen.py
index eb624311a0..2948372c6a 100644
--- a/bitbake/lib/bb/siggen.py
+++ b/bitbake/lib/bb/siggen.py
@@ -7,26 +7,26 @@ except ImportError:
7 import pickle 7 import pickle
8 bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.") 8 bb.msg.note(1, bb.msg.domain.Cache, "Importing cPickle failed. Falling back to a very slow implementation.")
9 9
10def init(d): 10def init(d, dumpsigs):
11 siggens = [obj for obj in globals().itervalues() 11 siggens = [obj for obj in globals().itervalues()
12 if type(obj) is type and issubclass(obj, SignatureGenerator)] 12 if type(obj) is type and issubclass(obj, SignatureGenerator)]
13 13
14 desired = bb.data.getVar("BB_SIGNATURE_HANDLER", d, True) or "noop" 14 desired = bb.data.getVar("BB_SIGNATURE_HANDLER", d, True) or "noop"
15 for sg in siggens: 15 for sg in siggens:
16 if desired == sg.name: 16 if desired == sg.name:
17 return sg(d) 17 return sg(d, dumpsigs)
18 break 18 break
19 else: 19 else:
20 bb.error("Invalid signature generator '%s', using default 'noop' generator" % desired) 20 bb.error("Invalid signature generator '%s', using default 'noop' generator" % desired)
21 bb.error("Available generators: %s" % ", ".join(obj.name for obj in siggens)) 21 bb.error("Available generators: %s" % ", ".join(obj.name for obj in siggens))
22 return SignatureGenerator(d) 22 return SignatureGenerator(d, dumpsigs)
23 23
24class SignatureGenerator(object): 24class SignatureGenerator(object):
25 """ 25 """
26 """ 26 """
27 name = "noop" 27 name = "noop"
28 28
29 def __init__(self, data): 29 def __init__(self, data, dumpsigs):
30 return 30 return
31 31
32 def finalise(self, fn, d): 32 def finalise(self, fn, d):
@@ -37,7 +37,7 @@ class SignatureGeneratorBasic(SignatureGenerator):
37 """ 37 """
38 name = "basic" 38 name = "basic"
39 39
40 def __init__(self, data): 40 def __init__(self, data, dumpsigs):
41 self.basehash = {} 41 self.basehash = {}
42 self.taskhash = {} 42 self.taskhash = {}
43 self.taskdeps = {} 43 self.taskdeps = {}
@@ -52,17 +52,19 @@ class SignatureGeneratorBasic(SignatureGenerator):
52 else: 52 else:
53 self.twl = None 53 self.twl = None
54 54
55 self.dumpsigs = dumpsigs
56
55 def _build_data(self, fn, d): 57 def _build_data(self, fn, d):
56 58
57 self.taskdeps[fn], self.gendeps[fn] = bb.data.generate_dependencies(d) 59 taskdeps, gendeps = bb.data.generate_dependencies(d)
58 60
59 basehash = {} 61 basehash = {}
60 lookupcache = {} 62 lookupcache = {}
61 63
62 for task in self.taskdeps[fn]: 64 for task in taskdeps:
63 data = d.getVar(task, False) 65 data = d.getVar(task, False)
64 lookupcache[task] = data 66 lookupcache[task] = data
65 for dep in sorted(self.taskdeps[fn][task]): 67 for dep in sorted(taskdeps[task]):
66 if dep in self.basewhitelist: 68 if dep in self.basewhitelist:
67 continue 69 continue
68 if dep in lookupcache: 70 if dep in lookupcache:
@@ -75,20 +77,25 @@ class SignatureGeneratorBasic(SignatureGenerator):
75 self.basehash[fn + "." + task] = hashlib.md5(data).hexdigest() 77 self.basehash[fn + "." + task] = hashlib.md5(data).hexdigest()
76 #bb.note("Hash for %s is %s" % (task, tashhash[task])) 78 #bb.note("Hash for %s is %s" % (task, tashhash[task]))
77 79
78 self.lookupcache[fn] = lookupcache 80 if self.dumpsigs:
81 self.taskdeps[fn] = taskdeps
82 self.gendeps[fn] = gendeps
83 self.lookupcache[fn] = lookupcache
84
85 return taskdeps
79 86
80 def finalise(self, fn, d, variant): 87 def finalise(self, fn, d, variant):
81 88
82 if variant: 89 if variant:
83 fn = "virtual:" + variant + ":" + fn 90 fn = "virtual:" + variant + ":" + fn
84 91
85 self._build_data(fn, d) 92 taskdeps = self._build_data(fn, d)
86 93
87 #Slow but can be useful for debugging mismatched basehashes 94 #Slow but can be useful for debugging mismatched basehashes
88 #for task in self.taskdeps[fn]: 95 #for task in self.taskdeps[fn]:
89 # self.dump_sigtask(fn, task, d.getVar("STAMP", True), False) 96 # self.dump_sigtask(fn, task, d.getVar("STAMP", True), False)
90 97
91 for task in self.taskdeps[fn]: 98 for task in taskdeps:
92 d.setVar("BB_BASEHASH_task-%s" % task, self.basehash[fn + "." + task]) 99 d.setVar("BB_BASEHASH_task-%s" % task, self.basehash[fn + "." + task])
93 100
94 def get_taskhash(self, fn, task, deps, dataCache): 101 def get_taskhash(self, fn, task, deps, dataCache):