summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShane Wang <shane.wang@intel.com>2012-02-23 21:47:16 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-02-23 22:52:17 +0000
commit8fa33800efa530c765d85a520110285467ff29c2 (patch)
tree62cdc94429ed5772df63d0f200fdc49ccf0528a0
parentde77b9752ab2df56d87dc15ed5cd0d2cd5544dc7 (diff)
downloadpoky-8fa33800efa530c765d85a520110285467ff29c2.tar.gz
bitbake: change for adding progress bar in Hob2.
The changes include: - Clean some events in event.py - Fire essential events for Hob2 to handle with more information. - knotty changes (Bitbake rev: 9ede881620c501574f014e600cea6947ea908ac2) Signed-off-by: Shane Wang <shane.wang@intel.com> Signed-off-by: Dongxiao Xu <dongxiao.xu@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/cache.py2
-rw-r--r--bitbake/lib/bb/cooker.py12
-rw-r--r--bitbake/lib/bb/event.py83
-rw-r--r--bitbake/lib/bb/ui/knotty.py5
4 files changed, 73 insertions, 29 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 3d89435211..47e814b577 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -336,7 +336,7 @@ class Cache(object):
336 current_percent = 100 * current_progress / cachesize 336 current_percent = 100 * current_progress / cachesize
337 if current_percent > previous_percent: 337 if current_percent > previous_percent:
338 previous_percent = current_percent 338 previous_percent = current_percent
339 bb.event.fire(bb.event.CacheLoadProgress(current_progress), 339 bb.event.fire(bb.event.CacheLoadProgress(current_progress, cachesize),
340 self.data) 340 self.data)
341 341
342 previous_progress += current_progress 342 previous_progress += current_progress
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 91fdc96b8a..d645454c7c 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -334,6 +334,7 @@ class BBCooker:
334 """ 334 """
335 Prepare a runqueue and taskdata object for iteration over pkgs_to_build 335 Prepare a runqueue and taskdata object for iteration over pkgs_to_build
336 """ 336 """
337 bb.event.fire(bb.event.TreeDataPreparationStarted(), self.configuration.data)
337 # Need files parsed 338 # Need files parsed
338 self.updateCache() 339 self.updateCache()
339 # If we are told to do the None task then query the default task 340 # If we are told to do the None task then query the default task
@@ -350,11 +351,14 @@ class BBCooker:
350 taskdata = bb.taskdata.TaskData(False, skiplist=self.skiplist) 351 taskdata = bb.taskdata.TaskData(False, skiplist=self.skiplist)
351 352
352 runlist = [] 353 runlist = []
354 current = 0
353 for k in pkgs_to_build: 355 for k in pkgs_to_build:
354 taskdata.add_provider(localdata, self.status, k) 356 taskdata.add_provider(localdata, self.status, k)
355 runlist.append([k, "do_%s" % task]) 357 runlist.append([k, "do_%s" % task])
358 current += 1
359 bb.event.fire(bb.event.TreeDataPreparationProgress(current, len(pkgs_to_build)), self.configuration.data)
356 taskdata.add_unresolved(localdata, self.status) 360 taskdata.add_unresolved(localdata, self.status)
357 361 bb.event.fire(bb.event.TreeDataPreparationCompleted(len(pkgs_to_build)), self.configuration.data)
358 return runlist, taskdata 362 return runlist, taskdata
359 363
360 def generateTaskDepTreeData(self, pkgs_to_build, task): 364 def generateTaskDepTreeData(self, pkgs_to_build, task):
@@ -1100,7 +1104,7 @@ class BBCooker:
1100 return False 1104 return False
1101 1105
1102 if not retval: 1106 if not retval:
1103 bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) 1107 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, item, failures), self.configuration.event_data)
1104 self.command.finishAsyncCommand() 1108 self.command.finishAsyncCommand()
1105 return False 1109 return False
1106 if retval is True: 1110 if retval is True:
@@ -1140,7 +1144,7 @@ class BBCooker:
1140 return False 1144 return False
1141 1145
1142 if not retval: 1146 if not retval:
1143 bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.data) 1147 bb.event.fire(bb.event.BuildCompleted(len(rq.rqdata.runq_fnid), buildname, targets, failures), self.configuration.data)
1144 self.command.finishAsyncCommand() 1148 self.command.finishAsyncCommand()
1145 return False 1149 return False
1146 if retval is True: 1150 if retval is True:
@@ -1663,7 +1667,7 @@ class CookerParser(object):
1663 if parsed: 1667 if parsed:
1664 self.parsed += 1 1668 self.parsed += 1
1665 if self.parsed % self.progress_chunk == 0: 1669 if self.parsed % self.progress_chunk == 0:
1666 bb.event.fire(bb.event.ParseProgress(self.parsed), 1670 bb.event.fire(bb.event.ParseProgress(self.parsed, self.toparse),
1667 self.cfgdata) 1671 self.cfgdata)
1668 else: 1672 else:
1669 self.cached += 1 1673 self.cached += 1
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py
index 10036c05c9..bbece583d1 100644
--- a/bitbake/lib/bb/event.py
+++ b/bitbake/lib/bb/event.py
@@ -204,6 +204,27 @@ def getName(e):
204 else: 204 else:
205 return e.__name__ 205 return e.__name__
206 206
207class OperationStarted(Event):
208 """An operation has begun"""
209 def __init__(self, msg = "Operation Started"):
210 Event.__init__(self)
211 self.msg = msg
212
213class OperationCompleted(Event):
214 """An operation has completed"""
215 def __init__(self, total, msg = "Operation Completed"):
216 Event.__init__(self)
217 self.total = total
218 self.msg = msg
219
220class OperationProgress(Event):
221 """An operation is in progress"""
222 def __init__(self, current, total, msg = "Operation in Progress"):
223 Event.__init__(self)
224 self.current = current
225 self.total = total
226 self.msg = msg + ": %s/%s" % (current, total);
227
207class ConfigParsed(Event): 228class ConfigParsed(Event):
208 """Configuration Parsing Complete""" 229 """Configuration Parsing Complete"""
209 230
@@ -276,14 +297,20 @@ class BuildBase(Event):
276 297
277 298
278 299
279class BuildStarted(BuildBase): 300class BuildStarted(BuildBase, OperationStarted):
280 """bbmake build run started""" 301 """bbmake build run started"""
302 def __init__(self, n, p, failures = 0):
303 OperationStarted.__init__(self, "Building Started")
304 BuildBase.__init__(self, n, p, failures)
281 305
282 306class BuildCompleted(BuildBase, OperationCompleted):
283class BuildCompleted(BuildBase):
284 """bbmake build run completed""" 307 """bbmake build run completed"""
285 308 def __init__(self, total, n, p, failures = 0):
286 309 if not failures:
310 OperationCompleted.__init__(self, total, "Building Succeeded")
311 else:
312 OperationCompleted.__init__(self, total, "Building Failed")
313 BuildBase.__init__(self, n, p, failures)
287 314
288 315
289class NoProvider(Event): 316class NoProvider(Event):
@@ -329,17 +356,16 @@ class MultipleProviders(Event):
329 """ 356 """
330 return self._candidates 357 return self._candidates
331 358
332class ParseStarted(Event): 359class ParseStarted(OperationStarted):
333 """Recipe parsing for the runqueue has begun""" 360 """Recipe parsing for the runqueue has begun"""
334 def __init__(self, total): 361 def __init__(self, total):
335 Event.__init__(self) 362 OperationStarted.__init__(self, "Recipe parsing Started")
336 self.total = total 363 self.total = total
337 364
338class ParseCompleted(Event): 365class ParseCompleted(OperationCompleted):
339 """Recipe parsing for the runqueue has completed""" 366 """Recipe parsing for the runqueue has completed"""
340
341 def __init__(self, cached, parsed, skipped, masked, virtuals, errors, total): 367 def __init__(self, cached, parsed, skipped, masked, virtuals, errors, total):
342 Event.__init__(self) 368 OperationCompleted.__init__(self, total, "Recipe parsing Completed")
343 self.cached = cached 369 self.cached = cached
344 self.parsed = parsed 370 self.parsed = parsed
345 self.skipped = skipped 371 self.skipped = skipped
@@ -347,33 +373,44 @@ class ParseCompleted(Event):
347 self.masked = masked 373 self.masked = masked
348 self.errors = errors 374 self.errors = errors
349 self.sofar = cached + parsed 375 self.sofar = cached + parsed
350 self.total = total
351 376
352class ParseProgress(Event): 377class ParseProgress(OperationProgress):
353 """Recipe parsing progress""" 378 """Recipe parsing progress"""
379 def __init__(self, current, total):
380 OperationProgress.__init__(self, current, total, "Recipe parsing")
354 381
355 def __init__(self, current):
356 self.current = current
357 382
358class CacheLoadStarted(Event): 383class CacheLoadStarted(OperationStarted):
359 """Loading of the dependency cache has begun""" 384 """Loading of the dependency cache has begun"""
360 def __init__(self, total): 385 def __init__(self, total):
361 Event.__init__(self) 386 OperationStarted.__init__(self, "Loading cache Started")
362 self.total = total 387 self.total = total
363 388
364class CacheLoadProgress(Event): 389class CacheLoadProgress(OperationProgress):
365 """Cache loading progress""" 390 """Cache loading progress"""
366 def __init__(self, current): 391 def __init__(self, current, total):
367 Event.__init__(self) 392 OperationProgress.__init__(self, current, total, "Loading cache")
368 self.current = current
369 393
370class CacheLoadCompleted(Event): 394class CacheLoadCompleted(OperationCompleted):
371 """Cache loading is complete""" 395 """Cache loading is complete"""
372 def __init__(self, total, num_entries): 396 def __init__(self, total, num_entries):
373 Event.__init__(self) 397 OperationCompleted.__init__(self, total, "Loading cache Completed")
374 self.total = total
375 self.num_entries = num_entries 398 self.num_entries = num_entries
376 399
400class TreeDataPreparationStarted(OperationStarted):
401 """Tree data preparation started"""
402 def __init__(self):
403 OperationStarted.__init__(self, "Preparing tree data Started")
404
405class TreeDataPreparationProgress(OperationProgress):
406 """Tree data preparation is in progress"""
407 def __init__(self, current, total):
408 OperationProgress.__init__(self, current, total, "Preparing tree data")
409
410class TreeDataPreparationCompleted(OperationCompleted):
411 """Tree data preparation completed"""
412 def __init__(self, total):
413 OperationCompleted.__init__(self, total, "Preparing tree data Completed")
377 414
378class DepTreeGenerated(Event): 415class DepTreeGenerated(Event):
379 """ 416 """
diff --git a/bitbake/lib/bb/ui/knotty.py b/bitbake/lib/bb/ui/knotty.py
index 158a132726..e2e6ac3d65 100644
--- a/bitbake/lib/bb/ui/knotty.py
+++ b/bitbake/lib/bb/ui/knotty.py
@@ -263,7 +263,10 @@ def main(server, eventHandler):
263 bb.event.RecipeParsed, 263 bb.event.RecipeParsed,
264 bb.event.RecipePreFinalise, 264 bb.event.RecipePreFinalise,
265 bb.runqueue.runQueueEvent, 265 bb.runqueue.runQueueEvent,
266 bb.runqueue.runQueueExitWait)): 266 bb.runqueue.runQueueExitWait,
267 bb.event.OperationStarted,
268 bb.event.OperationCompleted,
269 bb.event.OperationProgress)):
267 continue 270 continue
268 271
269 logger.error("Unknown event: %s", event) 272 logger.error("Unknown event: %s", event)