diff options
Diffstat (limited to 'bitbake/lib/bb/build.py')
| -rw-r--r-- | bitbake/lib/bb/build.py | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 2ebe67306f..4fb2a77cfd 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
| @@ -35,6 +35,7 @@ import stat | |||
| 35 | import bb | 35 | import bb |
| 36 | import bb.msg | 36 | import bb.msg |
| 37 | import bb.process | 37 | import bb.process |
| 38 | import bb.progress | ||
| 38 | from bb import data, event, utils | 39 | from bb import data, event, utils |
| 39 | 40 | ||
| 40 | bblogger = logging.getLogger('BitBake') | 41 | bblogger = logging.getLogger('BitBake') |
| @@ -137,6 +138,25 @@ class TaskInvalid(TaskBase): | |||
| 137 | super(TaskInvalid, self).__init__(task, None, metadata) | 138 | super(TaskInvalid, self).__init__(task, None, metadata) |
| 138 | self._message = "No such task '%s'" % task | 139 | self._message = "No such task '%s'" % task |
| 139 | 140 | ||
| 141 | class TaskProgress(event.Event): | ||
| 142 | """ | ||
| 143 | Task made some progress that could be reported to the user, usually in | ||
| 144 | the form of a progress bar or similar. | ||
| 145 | NOTE: this class does not inherit from TaskBase since it doesn't need | ||
| 146 | to - it's fired within the task context itself, so we don't have any of | ||
| 147 | the context information that you do in the case of the other events. | ||
| 148 | The event PID can be used to determine which task it came from. | ||
| 149 | The progress value is normally 0-100, but can also be negative | ||
| 150 | indicating that progress has been made but we aren't able to determine | ||
| 151 | how much. | ||
| 152 | The rate is optional, this is simply an extra string to display to the | ||
| 153 | user if specified. | ||
| 154 | """ | ||
| 155 | def __init__(self, progress, rate=None): | ||
| 156 | self.progress = progress | ||
| 157 | self.rate = rate | ||
| 158 | event.Event.__init__(self) | ||
| 159 | |||
| 140 | 160 | ||
| 141 | class LogTee(object): | 161 | class LogTee(object): |
| 142 | def __init__(self, logger, outfile): | 162 | def __init__(self, logger, outfile): |
| @@ -340,6 +360,20 @@ exit $ret | |||
| 340 | else: | 360 | else: |
| 341 | logfile = sys.stdout | 361 | logfile = sys.stdout |
| 342 | 362 | ||
| 363 | progress = d.getVarFlag(func, 'progress', True) | ||
| 364 | if progress: | ||
| 365 | if progress == 'percent': | ||
| 366 | # Use default regex | ||
| 367 | logfile = bb.progress.BasicProgressHandler(d, outfile=logfile) | ||
| 368 | elif progress.startswith('percent:'): | ||
| 369 | # Use specified regex | ||
| 370 | logfile = bb.progress.BasicProgressHandler(d, regex=progress.split(':', 1)[1], outfile=logfile) | ||
| 371 | elif progress.startswith('outof:'): | ||
| 372 | # Use specified regex | ||
| 373 | logfile = bb.progress.OutOfProgressHandler(d, regex=progress.split(':', 1)[1], outfile=logfile) | ||
| 374 | else: | ||
| 375 | bb.warn('%s: invalid task progress varflag value "%s", ignoring' % (func, progress)) | ||
| 376 | |||
| 343 | def readfifo(data): | 377 | def readfifo(data): |
| 344 | lines = data.split(b'\0') | 378 | lines = data.split(b'\0') |
| 345 | for line in lines: | 379 | for line in lines: |
