parse/ast: Abstract anonymous function execution into a function
PATCH 1/2 parse/ast: Abstract anonymous function execution into a function
This allows us to call this code from other contexts without duplicating it.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/parse/ast.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
lib/bb/parse/ast.py +7 -4
@@ -335,6 +335,12 @@ def handleInherit(statements, filename, lineno, m): classes = m.group(1) statements.append(InheritNode(filename, lineno, classes)) +def runAnonFuncs(d): + code = [] + for funcname in d.getVar("__BBANONFUNCS", False) or []: + code.append("%s(d)" % funcname) + bb.utils.better_exec("\n".join(code), {"d": d}) + def finalize(fn, d, variant = None): saved_handlers = bb.event.get_handlers().copy()
@@ -349,10 +355,7 @@ def finalize(fn, d, variant = None): bb.event.fire(bb.event.RecipePreFinalise(fn), d) bb.data.expandKeys(d) - code = [] - for funcname in d.getVar("__BBANONFUNCS", False) or []: - code.append("%s(d)" % funcname) - bb.utils.better_exec("\n".join(code), {"d": d}) + runAnonFuncs(d) tasklist = d.getVar('__BBTASKS', False) or [] bb.event.fire(bb.event.RecipeTaskPreProcess(fn, list(tasklist)), d)
Signature · 1 line
2.7.4
PATCH 2/2 cooker: Run registered anonymous python before displaying environment
The output of bitbake -e can differ from what actually is used due to anonymous python making changes to the data store. Execute any anonymous python added in the base configuration to make things more consistent.
Signed-off-by Richard Purdie <[email protected]>
--- lib/bb/cooker.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
lib/bb/cooker.py +3 -1
@@ -530,13 +530,15 @@ class BBCooker: self.data.inchistory.emit(env) logger.plain(env.getvalue()) + data.expandKeys(envdata) + parse.ast.runAnonFuncs(envdata) + # emit variables and shell functions with closing(StringIO()) as env: data.emit_env(env, envdata, True) logger.plain(env.getvalue()) # emit the metadata which isnt valid shell - data.expandKeys(envdata) for e in sorted(envdata.keys()): if envdata.getVarFlag(e, 'func', False) and envdata.getVarFlag(e, 'python', False): logger.plain("\npython %s () {\n%s}\n", e, envdata.getVar(e, False))
Signature · 1 line
2.7.4