summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2019-07-31 15:55:51 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2019-08-06 11:21:32 +0100
commit347c2056022d21deea6e2e7359eca2b96c6f01fe (patch)
tree521dd5daa3de4f23487eb84884d0ffd759b63207 /bitbake/lib/bb
parent4fbb862cdcdcfa44da83f9a7e7a74ab518ef67d0 (diff)
downloadpoky-347c2056022d21deea6e2e7359eca2b96c6f01fe.tar.gz
bitbake: build/utils: Drop bb.build.FuncFailed
Its hard to see what this exception adds in the current codebase. The logfile attribute is effectively ignored, the exception doesn't serve a defined purpose and mostly seems to be worked around. Remove it entirely. If this does cause output problems, we'll figure out better ways to address those. (Bitbake rev: cfeffb602dd5319f071cd6bcf84139ec77f2d170) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r--bitbake/lib/bb/build.py57
-rw-r--r--bitbake/lib/bb/data.py2
-rw-r--r--bitbake/lib/bb/utils.py2
3 files changed, 12 insertions, 49 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index e2f91fa3b7..30a2ba236f 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -54,23 +54,6 @@ else:
54builtins['bb'] = bb 54builtins['bb'] = bb
55builtins['os'] = os 55builtins['os'] = os
56 56
57class FuncFailed(Exception):
58 def __init__(self, name = None, logfile = None):
59 self.logfile = logfile
60 self.name = name
61 if name:
62 self.msg = 'Function failed: %s' % name
63 else:
64 self.msg = "Function failed"
65
66 def __str__(self):
67 if self.logfile and os.path.exists(self.logfile):
68 msg = ("%s (log file is located at %s)" %
69 (self.msg, self.logfile))
70 else:
71 msg = self.msg
72 return msg
73
74class TaskBase(event.Event): 57class TaskBase(event.Event):
75 """Base class for task events""" 58 """Base class for task events"""
76 59
@@ -189,12 +172,7 @@ class StdoutNoopContextManager:
189 return sys.stdout.name 172 return sys.stdout.name
190 173
191 174
192# 175def exec_func(func, d, dirs = None):
193# pythonexception allows the python exceptions generated to be raised
194# as the real exceptions (not FuncFailed) and without a backtrace at the
195# origin of the failure.
196#
197def exec_func(func, d, dirs = None, pythonexception=False):
198 """Execute a BB 'function'""" 176 """Execute a BB 'function'"""
199 177
200 try: 178 try:
@@ -266,7 +244,7 @@ def exec_func(func, d, dirs = None, pythonexception=False):
266 244
267 with bb.utils.fileslocked(lockfiles): 245 with bb.utils.fileslocked(lockfiles):
268 if ispython: 246 if ispython:
269 exec_func_python(func, d, runfile, cwd=adir, pythonexception=pythonexception) 247 exec_func_python(func, d, runfile, cwd=adir)
270 else: 248 else:
271 exec_func_shell(func, d, runfile, cwd=adir) 249 exec_func_shell(func, d, runfile, cwd=adir)
272 250
@@ -286,7 +264,7 @@ _functionfmt = """
286{function}(d) 264{function}(d)
287""" 265"""
288logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") 266logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
289def exec_func_python(func, d, runfile, cwd=None, pythonexception=False): 267def exec_func_python(func, d, runfile, cwd=None):
290 """Execute a python BB 'function'""" 268 """Execute a python BB 'function'"""
291 269
292 code = _functionfmt.format(function=func) 270 code = _functionfmt.format(function=func)
@@ -311,14 +289,7 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
311 bb.methodpool.insert_method(func, text, fn, lineno - 1) 289 bb.methodpool.insert_method(func, text, fn, lineno - 1)
312 290
313 comp = utils.better_compile(code, func, "exec_python_func() autogenerated") 291 comp = utils.better_compile(code, func, "exec_python_func() autogenerated")
314 utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated", pythonexception=pythonexception) 292 utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated")
315 except (bb.parse.SkipRecipe, bb.build.FuncFailed):
316 raise
317 except Exception as e:
318 if pythonexception:
319 raise
320 logger.error(str(e))
321 raise FuncFailed(func, None)
322 finally: 293 finally:
323 bb.debug(2, "Python function %s finished" % func) 294 bb.debug(2, "Python function %s finished" % func)
324 295
@@ -475,13 +446,8 @@ exit $ret
475 with open(fifopath, 'r+b', buffering=0) as fifo: 446 with open(fifopath, 'r+b', buffering=0) as fifo:
476 try: 447 try:
477 bb.debug(2, "Executing shell function %s" % func) 448 bb.debug(2, "Executing shell function %s" % func)
478 449 with open(os.devnull, 'r+') as stdin, logfile:
479 try: 450 bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
480 with open(os.devnull, 'r+') as stdin, logfile:
481 bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
482 except bb.process.CmdError:
483 logfn = d.getVar('BB_LOGFILE')
484 raise FuncFailed(func, logfn)
485 finally: 451 finally:
486 os.unlink(fifopath) 452 os.unlink(fifopath)
487 453
@@ -609,9 +575,6 @@ def _exec_task(fn, task, d, quieterr):
609 event.fire(TaskStarted(task, logfn, flags, localdata), localdata) 575 event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
610 except (bb.BBHandledException, SystemExit): 576 except (bb.BBHandledException, SystemExit):
611 return 1 577 return 1
612 except FuncFailed as exc:
613 logger.error(str(exc))
614 return 1
615 578
616 try: 579 try:
617 for func in (prefuncs or '').split(): 580 for func in (prefuncs or '').split():
@@ -619,7 +582,10 @@ def _exec_task(fn, task, d, quieterr):
619 exec_func(task, localdata) 582 exec_func(task, localdata)
620 for func in (postfuncs or '').split(): 583 for func in (postfuncs or '').split():
621 exec_func(func, localdata) 584 exec_func(func, localdata)
622 except FuncFailed as exc: 585 except bb.BBHandledException:
586 event.fire(TaskFailed(task, logfn, localdata, True), localdata)
587 return 1
588 except Exception as exc:
623 if quieterr: 589 if quieterr:
624 event.fire(TaskFailedSilent(task, logfn, localdata), localdata) 590 event.fire(TaskFailedSilent(task, logfn, localdata), localdata)
625 else: 591 else:
@@ -627,9 +593,6 @@ def _exec_task(fn, task, d, quieterr):
627 logger.error(str(exc)) 593 logger.error(str(exc))
628 event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata) 594 event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
629 return 1 595 return 1
630 except bb.BBHandledException:
631 event.fire(TaskFailed(task, logfn, localdata, True), localdata)
632 return 1
633 finally: 596 finally:
634 sys.stdout.flush() 597 sys.stdout.flush()
635 sys.stderr.flush() 598 sys.stderr.flush()
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 443615b977..0d75d0c1a9 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -130,7 +130,7 @@ def emit_var(var, o=sys.__stdout__, d = init(), all=False):
130 if all: 130 if all:
131 oval = d.getVar(var, False) 131 oval = d.getVar(var, False)
132 val = d.getVar(var) 132 val = d.getVar(var)
133 except (KeyboardInterrupt, bb.build.FuncFailed): 133 except (KeyboardInterrupt):
134 raise 134 raise
135 except Exception as exc: 135 except Exception as exc:
136 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc))) 136 o.write('# expansion of %s threw %s: %s\n' % (var, exc.__class__.__name__, str(exc)))
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index ed19825faf..0618e46fe6 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -394,7 +394,7 @@ def better_exec(code, context, text = None, realfile = "<code>", pythonexception
394 code = better_compile(code, realfile, realfile) 394 code = better_compile(code, realfile, realfile)
395 try: 395 try:
396 exec(code, get_context(), context) 396 exec(code, get_context(), context)
397 except (bb.BBHandledException, bb.parse.SkipRecipe, bb.build.FuncFailed, bb.data_smart.ExpansionError): 397 except (bb.BBHandledException, bb.parse.SkipRecipe, bb.data_smart.ExpansionError):
398 # Error already shown so passthrough, no need for traceback 398 # Error already shown so passthrough, no need for traceback
399 raise 399 raise
400 except Exception as e: 400 except Exception as e: