diff options
| -rw-r--r-- | bitbake/lib/bb/build.py | 52 | ||||
| -rw-r--r-- | bitbake/lib/bb/cooker.py | 8 | ||||
| -rw-r--r-- | bitbake/lib/bb/shell.py | 6 | 
3 files changed, 30 insertions, 36 deletions
| diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 9589313238..e800d5cf08 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
| @@ -41,13 +41,17 @@ logger = logging.getLogger("BitBake.Build") | |||
| 41 | __builtins__['bb'] = bb | 41 | __builtins__['bb'] = bb | 
| 42 | __builtins__['os'] = os | 42 | __builtins__['os'] = os | 
| 43 | 43 | ||
| 44 | # events | ||
| 45 | class FuncFailed(Exception): | 44 | class FuncFailed(Exception): | 
| 46 | """ | 45 | def __init__(self, name, metadata, logfile = None): | 
| 47 | Executed function failed | 46 | self.name = name | 
| 48 | First parameter a message | 47 | self.metadata = metadata | 
| 49 | Second paramter is a logfile (optional) | 48 | self.logfile = logfile | 
| 50 | """ | 49 | |
| 50 | def __str__(self): | ||
| 51 | msg = "Function '%s' failed" % self.name | ||
| 52 | if self.logfile: | ||
| 53 | msg += " (see %s for further information)" % self.logfile | ||
| 54 | return msg | ||
| 51 | 55 | ||
| 52 | class TaskBase(event.Event): | 56 | class TaskBase(event.Event): | 
| 53 | """Base class for task events""" | 57 | """Base class for task events""" | 
| @@ -74,13 +78,16 @@ class TaskSucceeded(TaskBase): | |||
| 74 | 78 | ||
| 75 | class TaskFailed(TaskBase): | 79 | class TaskFailed(TaskBase): | 
| 76 | """Task execution failed""" | 80 | """Task execution failed""" | 
| 77 | def __init__(self, msg, logfile, t, d ): | 81 | |
| 82 | def __init__(self, task, logfile, metadata): | ||
| 78 | self.logfile = logfile | 83 | self.logfile = logfile | 
| 79 | self.msg = msg | 84 | super(TaskFailed, self).__init__(task, metadata) | 
| 80 | TaskBase.__init__(self, t, d) | ||
| 81 | 85 | ||
| 82 | class TaskInvalid(TaskBase): | 86 | class TaskInvalid(TaskBase): | 
| 83 | """Invalid Task""" | 87 | |
| 88 | def __init__(self, task, metadata): | ||
| 89 | super(TaskInvalid, self).__init__(task, metadata) | ||
| 90 | self._message = "No such task '%s'" % task | ||
| 84 | 91 | ||
| 85 | # functions | 92 | # functions | 
| 86 | 93 | ||
| @@ -171,12 +178,11 @@ def exec_func_python(func, d, runfile, logfile): | |||
| 171 | comp = utils.better_compile(tmp, func, bbfile) | 178 | comp = utils.better_compile(tmp, func, bbfile) | 
| 172 | try: | 179 | try: | 
| 173 | utils.better_exec(comp, {"d": d}, tmp, bbfile) | 180 | utils.better_exec(comp, {"d": d}, tmp, bbfile) | 
| 174 | except: | 181 | except Exception as exc: | 
| 175 | (t, value, tb) = sys.exc_info() | 182 | if isinstance(exc, (bb.parse.SkipPackage, bb.build.FuncFailed)): | 
| 176 | |||
| 177 | if t in [bb.parse.SkipPackage, bb.build.FuncFailed]: | ||
| 178 | raise | 183 | raise | 
| 179 | raise FuncFailed("Function %s failed" % func, logfile) | 184 | |
| 185 | raise FuncFailed(func, d, logfile) | ||
| 180 | 186 | ||
| 181 | 187 | ||
| 182 | def exec_func_shell(func, d, runfile, logfile, flags): | 188 | def exec_func_shell(func, d, runfile, logfile, flags): | 
| @@ -207,7 +213,7 @@ def exec_func_shell(func, d, runfile, logfile, flags): | |||
| 207 | f.close() | 213 | f.close() | 
| 208 | os.chmod(runfile, 0775) | 214 | os.chmod(runfile, 0775) | 
| 209 | if not func: | 215 | if not func: | 
| 210 | raise FuncFailed("Function not specified for exec_func_shell") | 216 | raise TypeError("Function argument must be a string") | 
| 211 | 217 | ||
| 212 | # execute function | 218 | # execute function | 
| 213 | if flags['fakeroot'] and not flags['task']: | 219 | if flags['fakeroot'] and not flags['task']: | 
| @@ -219,7 +225,7 @@ def exec_func_shell(func, d, runfile, logfile, flags): | |||
| 219 | if ret == 0: | 225 | if ret == 0: | 
| 220 | return | 226 | return | 
| 221 | 227 | ||
| 222 | raise FuncFailed("function %s failed" % func, logfile) | 228 | raise FuncFailed(func, d, logfile) | 
| 223 | 229 | ||
| 224 | 230 | ||
| 225 | def exec_task(fn, task, d): | 231 | def exec_task(fn, task, d): | 
| @@ -310,16 +316,10 @@ def exec_task(fn, task, d): | |||
| 310 | if not data.getVarFlag(task, 'nostamp', d) and not data.getVarFlag(task, 'selfstamp', d): | 316 | if not data.getVarFlag(task, 'nostamp', d) and not data.getVarFlag(task, 'selfstamp', d): | 
| 311 | make_stamp(task, d) | 317 | make_stamp(task, d) | 
| 312 | 318 | ||
| 313 | except FuncFailed as message: | 319 | except FuncFailed as exc: | 
| 314 | # Try to extract the optional logfile | ||
| 315 | try: | ||
| 316 | (msg, logfile) = message | ||
| 317 | except: | ||
| 318 | logfile = None | ||
| 319 | msg = message | ||
| 320 | if not quieterr: | 320 | if not quieterr: | 
| 321 | logger.error("Task failed: %s" % message ) | 321 | logger.error(str(exc)) | 
| 322 | failedevent = TaskFailed(msg, logfile, task, d) | 322 | failedevent = TaskFailed(exc.name, exc.logfile, task, d) | 
| 323 | event.fire(failedevent, d) | 323 | event.fire(failedevent, d) | 
| 324 | return 1 | 324 | return 1 | 
| 325 | 325 | ||
| diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index de213f03f4..c1e2105c5e 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
| @@ -690,9 +690,7 @@ class BBCooker: | |||
| 690 | try: | 690 | try: | 
| 691 | retval = rq.execute_runqueue() | 691 | retval = rq.execute_runqueue() | 
| 692 | except runqueue.TaskFailure as exc: | 692 | except runqueue.TaskFailure as exc: | 
| 693 | for fnid in exc.args: | 693 | failures += len(exc.args) | 
| 694 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) | ||
| 695 | failures = failures + 1 | ||
| 696 | retval = False | 694 | retval = False | 
| 697 | if not retval: | 695 | if not retval: | 
| 698 | bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) | 696 | bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) | 
| @@ -727,9 +725,7 @@ class BBCooker: | |||
| 727 | try: | 725 | try: | 
| 728 | retval = rq.execute_runqueue() | 726 | retval = rq.execute_runqueue() | 
| 729 | except runqueue.TaskFailure as exc: | 727 | except runqueue.TaskFailure as exc: | 
| 730 | for fnid in exc.args: | 728 | failures += len(exc.args) | 
| 731 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) | ||
| 732 | failures = failures + 1 | ||
| 733 | retval = False | 729 | retval = False | 
| 734 | if not retval: | 730 | if not retval: | 
| 735 | bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) | 731 | bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) | 
| diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py index f9ca9d5bd3..c61e93a1cb 100644 --- a/bitbake/lib/bb/shell.py +++ b/bitbake/lib/bb/shell.py | |||
| @@ -180,11 +180,9 @@ class BitBakeShellCommands: | |||
| 180 | last_exception = Providers.NoProvider | 180 | last_exception = Providers.NoProvider | 
| 181 | 181 | ||
| 182 | except runqueue.TaskFailure as fnids: | 182 | except runqueue.TaskFailure as fnids: | 
| 183 | for fnid in fnids: | ||
| 184 | print("ERROR: '%s' failed" % td.fn_index[fnid]) | ||
| 185 | last_exception = runqueue.TaskFailure | 183 | last_exception = runqueue.TaskFailure | 
| 186 | 184 | ||
| 187 | except build.EventException as e: | 185 | except build.FuncFailed as e: | 
| 188 | print("ERROR: Couldn't build '%s'" % names) | 186 | print("ERROR: Couldn't build '%s'" % names) | 
| 189 | last_exception = e | 187 | last_exception = e | 
| 190 | 188 | ||
| @@ -247,7 +245,7 @@ class BitBakeShellCommands: | |||
| 247 | cooker.buildFile(bf, cmd) | 245 | cooker.buildFile(bf, cmd) | 
| 248 | except parse.ParseError: | 246 | except parse.ParseError: | 
| 249 | print("ERROR: Unable to open or parse '%s'" % bf) | 247 | print("ERROR: Unable to open or parse '%s'" % bf) | 
| 250 | except build.EventException as e: | 248 | except build.FuncFailed as e: | 
| 251 | print("ERROR: Couldn't build '%s'" % name) | 249 | print("ERROR: Couldn't build '%s'" % name) | 
| 252 | last_exception = e | 250 | last_exception = e | 
| 253 | 251 | ||
