summaryrefslogtreecommitdiffstats
path: root/lib/bb/parse/ast.py
diff options
context:
space:
mode:
authorHolger Freyther <ich@tamarin.(none)>2009-05-18 19:56:36 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-02-12 17:59:14 +0000
commit15e3e7233ea42b109d42f00576485cd041da51d5 (patch)
treea12bcd41fabdec06efded5985ce559e63480097d /lib/bb/parse/ast.py
parent9fe314b8b86d3e8be442140a338663f926bd3769 (diff)
downloadbitbake-15e3e7233ea42b109d42f00576485cd041da51d5.tar.gz
[parser] Move the finalise into the ast as well
Diffstat (limited to 'lib/bb/parse/ast.py')
-rw-r--r--lib/bb/parse/ast.py39
1 files changed, 39 insertions, 0 deletions
diff --git a/lib/bb/parse/ast.py b/lib/bb/parse/ast.py
index 8e7ba7fde..f21b0aeb4 100644
--- a/lib/bb/parse/ast.py
+++ b/lib/bb/parse/ast.py
@@ -197,3 +197,42 @@ def handleInherit(statements, m, d):
n = __word__.findall(files)
bb.parse.BBHandler.inherit(statements, n, d)
+def finalise(fn, d):
+ bb.data.expandKeys(d)
+ bb.data.update_data(d)
+ anonqueue = bb.data.getVar("__anonqueue", d, 1) or []
+ body = [x['content'] for x in anonqueue]
+ flag = { 'python' : 1, 'func' : 1 }
+ bb.data.setVar("__anonfunc", "\n".join(body), d)
+ bb.data.setVarFlags("__anonfunc", flag, d)
+ from bb import build
+ try:
+ t = bb.data.getVar('T', d)
+ bb.data.setVar('T', '${TMPDIR}/anonfunc/', d)
+ anonfuncs = bb.data.getVar('__BBANONFUNCS', d) or []
+ code = ""
+ for f in anonfuncs:
+ code = code + " %s(d)\n" % f
+ bb.data.setVar("__anonfunc", code, d)
+ build.exec_func("__anonfunc", d)
+ bb.data.delVar('T', d)
+ if t:
+ bb.data.setVar('T', t, d)
+ except Exception, e:
+ bb.msg.debug(1, bb.msg.domain.Parsing, "Exception when executing anonymous function: %s" % e)
+ raise
+ bb.data.delVar("__anonqueue", d)
+ bb.data.delVar("__anonfunc", d)
+ bb.data.update_data(d)
+
+ all_handlers = {}
+ for var in bb.data.getVar('__BBHANDLERS', d) or []:
+ # try to add the handler
+ handler = bb.data.getVar(var,d)
+ bb.event.register(var, handler)
+
+ tasklist = bb.data.getVar('__BBTASKS', d) or []
+ bb.build.add_tasks(tasklist, d)
+
+ bb.event.fire(bb.event.RecipeParsed(fn), d)
+