diff options
| -rw-r--r-- | bitbake/lib/bb/cache.py | 17 | ||||
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 1 | ||||
| -rw-r--r-- | bitbake/lib/bb/event.py | 19 | ||||
| -rw-r--r-- | bitbake/lib/bb/ui/knotty.py | 32 |
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 | ||
| 327 | class CacheLoadStarted(Event): | ||
| 328 | """Loading of the dependency cache has begun""" | ||
| 329 | def __init__(self, total): | ||
| 330 | Event.__init__(self) | ||
| 331 | self.total = total | ||
| 332 | |||
| 333 | class CacheLoadProgress(Event): | ||
| 334 | """Cache loading progress""" | ||
| 335 | def __init__(self, current): | ||
| 336 | Event.__init__(self) | ||
| 337 | self.current = current | ||
| 338 | |||
| 339 | class 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 | |||
| 327 | class DepTreeGenerated(Event): | 346 | class 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 | |||
| 31 | from bb.ui import uihelper | 31 | from bb.ui import uihelper |
| 32 | 32 | ||
| 33 | logger = logging.getLogger("BitBake") | 33 | logger = logging.getLogger("BitBake") |
| 34 | widgets = [progressbar.Percentage(), ' ', progressbar.Bar(), ' ', | 34 | interactive = sys.stdout.isatty() |
| 35 | progressbar.ETA()] | ||
| 36 | 35 | ||
| 37 | class BBProgress(progressbar.ProgressBar): | 36 | class 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 | ||
| 42 | class NonInteractiveProgress(object): | 44 | class 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 | ||
| 63 | def new_progress(msg, maxval): | ||
| 64 | if interactive: | ||
| 65 | return BBProgress(msg, maxval) | ||
| 66 | else: | ||
| 67 | return NonInteractiveProgress(msg, maxval) | ||
| 68 | |||
| 61 | def main(server, eventHandler): | 69 | def 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): |
