summaryrefslogtreecommitdiffstats
path: root/lib/bb/build.py
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:07 +0100
commitcfeffb602dd5319f071cd6bcf84139ec77f2d170 (patch)
tree83bbe8843488d4f69963a7286f7865277a7c8e23 /lib/bb/build.py
parent07e539e1c566ca3434901e1a00335cb76c69d496 (diff)
downloadbitbake-cfeffb602dd5319f071cd6bcf84139ec77f2d170.tar.gz
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. Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/build.py')
-rw-r--r--lib/bb/build.py57
1 files changed, 10 insertions, 47 deletions
diff --git a/lib/bb/build.py b/lib/bb/build.py
index e2f91fa3b..30a2ba236 100644
--- a/lib/bb/build.py
+++ b/lib/bb/build.py
@@ -54,23 +54,6 @@ else:
builtins['bb'] = bb
builtins['os'] = os
-class FuncFailed(Exception):
- def __init__(self, name = None, logfile = None):
- self.logfile = logfile
- self.name = name
- if name:
- self.msg = 'Function failed: %s' % name
- else:
- self.msg = "Function failed"
-
- def __str__(self):
- if self.logfile and os.path.exists(self.logfile):
- msg = ("%s (log file is located at %s)" %
- (self.msg, self.logfile))
- else:
- msg = self.msg
- return msg
-
class TaskBase(event.Event):
"""Base class for task events"""
@@ -189,12 +172,7 @@ class StdoutNoopContextManager:
return sys.stdout.name
-#
-# pythonexception allows the python exceptions generated to be raised
-# as the real exceptions (not FuncFailed) and without a backtrace at the
-# origin of the failure.
-#
-def exec_func(func, d, dirs = None, pythonexception=False):
+def exec_func(func, d, dirs = None):
"""Execute a BB 'function'"""
try:
@@ -266,7 +244,7 @@ def exec_func(func, d, dirs = None, pythonexception=False):
with bb.utils.fileslocked(lockfiles):
if ispython:
- exec_func_python(func, d, runfile, cwd=adir, pythonexception=pythonexception)
+ exec_func_python(func, d, runfile, cwd=adir)
else:
exec_func_shell(func, d, runfile, cwd=adir)
@@ -286,7 +264,7 @@ _functionfmt = """
{function}(d)
"""
logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
-def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
+def exec_func_python(func, d, runfile, cwd=None):
"""Execute a python BB 'function'"""
code = _functionfmt.format(function=func)
@@ -311,14 +289,7 @@ def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
bb.methodpool.insert_method(func, text, fn, lineno - 1)
comp = utils.better_compile(code, func, "exec_python_func() autogenerated")
- utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated", pythonexception=pythonexception)
- except (bb.parse.SkipRecipe, bb.build.FuncFailed):
- raise
- except Exception as e:
- if pythonexception:
- raise
- logger.error(str(e))
- raise FuncFailed(func, None)
+ utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated")
finally:
bb.debug(2, "Python function %s finished" % func)
@@ -475,13 +446,8 @@ exit $ret
with open(fifopath, 'r+b', buffering=0) as fifo:
try:
bb.debug(2, "Executing shell function %s" % func)
-
- try:
- with open(os.devnull, 'r+') as stdin, logfile:
- bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
- except bb.process.CmdError:
- logfn = d.getVar('BB_LOGFILE')
- raise FuncFailed(func, logfn)
+ with open(os.devnull, 'r+') as stdin, logfile:
+ bb.process.run(cmd, shell=False, stdin=stdin, log=logfile, extrafiles=[(fifo,readfifo)])
finally:
os.unlink(fifopath)
@@ -609,9 +575,6 @@ def _exec_task(fn, task, d, quieterr):
event.fire(TaskStarted(task, logfn, flags, localdata), localdata)
except (bb.BBHandledException, SystemExit):
return 1
- except FuncFailed as exc:
- logger.error(str(exc))
- return 1
try:
for func in (prefuncs or '').split():
@@ -619,7 +582,10 @@ def _exec_task(fn, task, d, quieterr):
exec_func(task, localdata)
for func in (postfuncs or '').split():
exec_func(func, localdata)
- except FuncFailed as exc:
+ except bb.BBHandledException:
+ event.fire(TaskFailed(task, logfn, localdata, True), localdata)
+ return 1
+ except Exception as exc:
if quieterr:
event.fire(TaskFailedSilent(task, logfn, localdata), localdata)
else:
@@ -627,9 +593,6 @@ def _exec_task(fn, task, d, quieterr):
logger.error(str(exc))
event.fire(TaskFailed(task, logfn, localdata, errprinted), localdata)
return 1
- except bb.BBHandledException:
- event.fire(TaskFailed(task, logfn, localdata, True), localdata)
- return 1
finally:
sys.stdout.flush()
sys.stderr.flush()