summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorBob Foerster <rfoerster@layerzero.com>2010-11-22 10:13:56 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:51 +0000
commit2735a70ece44fa55282fb99e4f63c4ac269b07ac (patch)
treebca01db2dee721a0cfe8924f916d2ca16ba0a541 /bitbake
parent89a1b59d9a0c2ba7ec62dad41822dd7fdd831a81 (diff)
downloadpoky-2735a70ece44fa55282fb99e4f63c4ac269b07ac.tar.gz
Show the user progress when loading the cache
(Bitbake rev: bdd7813d8eecf7b6b636322e748ca6bf69118513) Signed-off-by: Bob Foerster <robert@erafx.com> Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/cache.py17
-rw-r--r--bitbake/lib/bb/cooker.py1
-rw-r--r--bitbake/lib/bb/event.py19
-rw-r--r--bitbake/lib/bb/ui/knotty.py32
4 files changed, 61 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index b3c632b81c..fb02deb8ef 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -204,14 +204,31 @@ class Cache(object):
204 logger.info('Bitbake version mismatch, rebuilding...') 204 logger.info('Bitbake version mismatch, rebuilding...')
205 return 205 return
206 206
207 cachesize = os.fstat(cachefile.fileno()).st_size
208 bb.event.fire(bb.event.CacheLoadStarted(cachesize), self.data)
209
210 previous_percent = 0
207 while cachefile: 211 while cachefile:
208 try: 212 try:
209 key = pickled.load() 213 key = pickled.load()
210 value = pickled.load() 214 value = pickled.load()
211 except Exception: 215 except Exception:
212 break 216 break
217
213 self.depends_cache[key] = value 218 self.depends_cache[key] = value
214 219
220 # only fire events on even percentage boundaries
221 current_progress = cachefile.tell()
222 current_percent = 100 * current_progress / cachesize
223 if current_percent > previous_percent:
224 previous_percent = current_percent
225 bb.event.fire(bb.event.CacheLoadProgress(current_progress),
226 self.data)
227
228 bb.event.fire(bb.event.CacheLoadCompleted(cachesize,
229 len(self.depends_cache)),
230 self.data)
231
215 @staticmethod 232 @staticmethod
216 def virtualfn2realfn(virtualfn): 233 def virtualfn2realfn(virtualfn):
217 """ 234 """
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 7a9b1d58d6..548273380f 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -1055,6 +1055,7 @@ class CookerParser(object):
1055 self.shutdown(clean=False) 1055 self.shutdown(clean=False)
1056 bb.fatal('Error parsing %s: %s' % (exc.recipe, exc)) 1056 bb.fatal('Error parsing %s: %s' % (exc.recipe, exc))
1057 1057
1058
1058 self.current += 1 1059 self.current += 1
1059 self.virtuals += len(result) 1060 self.virtuals += len(result)
1060 if parsed: 1061 if parsed:
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index c2bacc50c2..ad53ba015c 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -324,6 +324,25 @@ class ParseProgress(Event):
324 def __init__(self, current): 324 def __init__(self, current):
325 self.current = current 325 self.current = current
326 326
327class CacheLoadStarted(Event):
328 """Loading of the dependency cache has begun"""
329 def __init__(self, total):
330 Event.__init__(self)
331 self.total = total
332
333class CacheLoadProgress(Event):
334 """Cache loading progress"""
335 def __init__(self, current):
336 Event.__init__(self)
337 self.current = current
338
339class CacheLoadCompleted(Event):
340 """Cache loading is complete"""
341 def __init__(self, total, num_entries):
342 Event.__init__(self)
343 self.total = total
344 self.num_entries = num_entries
345
327class DepTreeGenerated(Event): 346class DepTreeGenerated(Event):
328 """ 347 """
329 Event when a dependency tree has been generated 348 Event when a dependency tree has been generated
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 69a84f7830..b9ad34f16a 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -31,12 +31,14 @@ from bb import ui
31from bb.ui import uihelper 31from bb.ui import uihelper
32 32
33logger = logging.getLogger("BitBake") 33logger = logging.getLogger("BitBake")
34widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ', 34interactive = sys.stdout.isatty()
35 progressbar.ETA()]
36 35
37class BBProgress(progressbar.ProgressBar): 36class BBProgress(progressbar.ProgressBar):
38 def __init__(self, msg, maxval): 37 def __init__(self, msg, maxval):
39 self.msg = msg 38 self.msg = msg
39 widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ',
40 progressbar.ETA()]
41
40 progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets) 42 progressbar.ProgressBar.__init__(self, maxval, [self.msg + ": "] + widgets)
41 43
42class NonInteractiveProgress(object): 44class NonInteractiveProgress(object):
@@ -58,6 +60,12 @@ class NonInteractiveProgress(object):
58 self.fobj.write("done.\n") 60 self.fobj.write("done.\n")
59 self.fobj.flush() 61 self.fobj.flush()
60 62
63def new_progress(msg, maxval):
64 if interactive:
65 return BBProgress(msg, maxval)
66 else:
67 return NonInteractiveProgress(msg, maxval)
68
61def main(server, eventHandler): 69def main(server, eventHandler):
62 70
63 # Get values of variables which control our output 71 # Get values of variables which control our output
@@ -93,8 +101,9 @@ def main(server, eventHandler):
93 print("XMLRPC Fault getting commandline:\n %s" % x) 101 print("XMLRPC Fault getting commandline:\n %s" % x)
94 return 1 102 return 1
95 103
104
96 parseprogress = None 105 parseprogress = None
97 interactive = os.isatty(sys.stdout.fileno()) 106 cacheprogress = None
98 shutdown = 0 107 shutdown = 0
99 return_value = 0 108 return_value = 0
100 while True: 109 while True:
@@ -149,11 +158,7 @@ def main(server, eventHandler):
149 logger.info(event._message) 158 logger.info(event._message)
150 continue 159 continue
151 if isinstance(event, bb.event.ParseStarted): 160 if isinstance(event, bb.event.ParseStarted):
152 if interactive: 161 parseprogress = new_progress("Parsing recipes", event.total).start()
153 progress = BBProgress
154 else:
155 progress = NonInteractiveProgress
156 parseprogress = progress("Parsing recipes", event.total).start()
157 continue 162 continue
158 if isinstance(event, bb.event.ParseProgress): 163 if isinstance(event, bb.event.ParseProgress):
159 parseprogress.update(event.current) 164 parseprogress.update(event.current)
@@ -164,6 +169,17 @@ def main(server, eventHandler):
164 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))) 169 % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors)))
165 continue 170 continue
166 171
172 if isinstance(event, bb.event.CacheLoadStarted):
173 cacheprogress = new_progress("Loading cache", event.total).start()
174 continue
175 if isinstance(event, bb.event.CacheLoadProgress):
176 cacheprogress.update(event.current)
177 continue
178 if isinstance(event, bb.event.CacheLoadCompleted):
179 cacheprogress.finish()
180 print("Loaded %d entries from dependency cache." % event.num_entries)
181 continue
182
167 if isinstance(event, bb.command.CommandCompleted): 183 if isinstance(event, bb.command.CommandCompleted):
168 break 184 break
169 if isinstance(event, bb.command.CommandFailed): 185 if isinstance(event, bb.command.CommandFailed):