summaryrefslogtreecommitdiff
path: root/yocto-poky/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'yocto-poky/bitbake/lib/bb/build.py')
-rw-r--r--yocto-poky/bitbake/lib/bb/build.py55
1 files changed, 31 insertions, 24 deletions
diff --git a/yocto-poky/bitbake/lib/bb/build.py b/yocto-poky/bitbake/lib/bb/build.py
index 22428a649..db5072cb4 100644
--- a/yocto-poky/bitbake/lib/bb/build.py
+++ b/yocto-poky/bitbake/lib/bb/build.py
@@ -156,7 +156,12 @@ class LogTee(object):
def flush(self):
self.outfile.flush()
-def exec_func(func, d, dirs = None):
+#
+# 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):
"""Execute a BB 'function'"""
body = d.getVar(func, False)
@@ -224,22 +229,18 @@ def exec_func(func, d, dirs = None):
with bb.utils.fileslocked(lockfiles):
if ispython:
- exec_func_python(func, d, runfile, cwd=adir)
+ exec_func_python(func, d, runfile, cwd=adir, pythonexception=pythonexception)
else:
exec_func_shell(func, d, runfile, cwd=adir)
_functionfmt = """
-def {function}(d):
-{body}
-
{function}(d)
"""
logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
-def exec_func_python(func, d, runfile, cwd=None):
+def exec_func_python(func, d, runfile, cwd=None, pythonexception=False):
"""Execute a python BB 'function'"""
- bbfile = d.getVar('FILE', True)
- code = _functionfmt.format(function=func, body=d.getVar(func, True))
+ code = _functionfmt.format(function=func)
bb.utils.mkdirhier(os.path.dirname(runfile))
with open(runfile, 'w') as script:
bb.data.emit_func_python(func, script, d)
@@ -254,11 +255,18 @@ def exec_func_python(func, d, runfile, cwd=None):
bb.debug(2, "Executing python function %s" % func)
try:
- comp = utils.better_compile(code, func, bbfile)
- utils.better_exec(comp, {"d": d}, code, bbfile)
+ text = "def %s(d):\n%s" % (func, d.getVar(func, False))
+ fn = d.getVarFlag(func, "filename", False)
+ lineno = int(d.getVarFlag(func, "lineno", 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:
+ if pythonexception:
+ raise
raise FuncFailed(func, None)
finally:
bb.debug(2, "Python function %s finished" % func)
@@ -277,9 +285,8 @@ bb_exit_handler() {
case $ret in
0) ;;
*) case $BASH_VERSION in
- "") echo "WARNING: exit code $ret from a shell command.";;
- *) echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from
- \"$BASH_COMMAND\"";;
+ "") echo "WARNING: exit code $ret from a shell command.";;
+ *) echo "WARNING: ${BASH_SOURCE[0]}:${BASH_LINENO[0]} exit $ret from '$BASH_COMMAND'";;
esac
exit $ret
esac
@@ -319,7 +326,7 @@ exit $ret
os.chmod(runfile, 0775)
cmd = runfile
- if d.getVarFlag(func, 'fakeroot'):
+ if d.getVarFlag(func, 'fakeroot', False):
fakerootcmd = d.getVar('FAKEROOT', True)
if fakerootcmd:
cmd = [fakerootcmd, runfile]
@@ -394,7 +401,7 @@ def _exec_task(fn, task, d, quieterr):
Execution of a task involves a bit more setup than executing a function,
running it with its own local metadata, and with some useful variables set.
"""
- if not d.getVarFlag(task, 'task'):
+ if not d.getVarFlag(task, 'task', False):
event.fire(TaskInvalid(task, d), d)
logger.error("No such task: %s" % task)
return 1
@@ -533,7 +540,7 @@ def _exec_task(fn, task, d, quieterr):
bb.utils.remove(loglink)
event.fire(TaskSucceeded(task, logfn, localdata), localdata)
- if not localdata.getVarFlag(task, 'nostamp') and not localdata.getVarFlag(task, 'selfstamp'):
+ if not localdata.getVarFlag(task, 'nostamp', False) and not localdata.getVarFlag(task, 'selfstamp', False):
make_stamp(task, localdata)
return 0
@@ -541,7 +548,7 @@ def _exec_task(fn, task, d, quieterr):
def exec_task(fn, task, d, profile = False):
try:
quieterr = False
- if d.getVarFlag(task, "quieterrors") is not None:
+ if d.getVarFlag(task, "quieterrors", False) is not None:
quieterr = True
if profile:
@@ -582,10 +589,10 @@ def stamp_internal(taskname, d, file_name, baseonly=False):
taskflagname = taskname.replace("_setscene", "")
if file_name:
- stamp = d.stamp_base[file_name].get(taskflagname) or d.stamp[file_name]
+ stamp = d.stamp[file_name]
extrainfo = d.stamp_extrainfo[file_name].get(taskflagname) or ""
else:
- stamp = d.getVarFlag(taskflagname, 'stamp-base', True) or d.getVar('STAMP', True)
+ stamp = d.getVar('STAMP', True)
file_name = d.getVar('BB_FILENAME', True)
extrainfo = d.getVarFlag(taskflagname, 'stamp-extra-info', True) or ""
@@ -616,10 +623,10 @@ def stamp_cleanmask_internal(taskname, d, file_name):
taskflagname = taskname.replace("_setscene", "")
if file_name:
- stamp = d.stamp_base_clean[file_name].get(taskflagname) or d.stampclean[file_name]
+ stamp = d.stampclean[file_name]
extrainfo = d.stamp_extrainfo[file_name].get(taskflagname) or ""
else:
- stamp = d.getVarFlag(taskflagname, 'stamp-base-clean', True) or d.getVar('STAMPCLEAN', True)
+ stamp = d.getVar('STAMPCLEAN', True)
file_name = d.getVar('BB_FILENAME', True)
extrainfo = d.getVarFlag(taskflagname, 'stamp-extra-info', True) or ""
@@ -746,7 +753,7 @@ def addtask(task, before, after, d):
bbtasks.append(task)
d.setVar('__BBTASKS', bbtasks)
- existing = d.getVarFlag(task, "deps") or []
+ existing = d.getVarFlag(task, "deps", False) or []
if after is not None:
# set up deps for function
for entry in after.split():
@@ -756,7 +763,7 @@ def addtask(task, before, after, d):
if before is not None:
# set up things that depend on this func
for entry in before.split():
- existing = d.getVarFlag(entry, "deps") or []
+ existing = d.getVarFlag(entry, "deps", False) or []
if task not in existing:
d.setVarFlag(entry, "deps", [task] + existing)
@@ -771,7 +778,7 @@ def deltask(task, d):
d.delVarFlag(task, 'deps')
for bbtask in d.getVar('__BBTASKS', False) or []:
- deps = d.getVarFlag(bbtask, 'deps') or []
+ deps = d.getVarFlag(bbtask, 'deps', False) or []
if task in deps:
deps.remove(task)
d.setVarFlag(bbtask, 'deps', deps)