summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/parse/parse_py
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-10-13 08:37:08 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2009-10-13 08:38:13 +0100
commit76425295541165421914ef354900a3f2534f59f2 (patch)
treedc871f1369b66f1f4c2fc92638f7758322a9f593 /bitbake/lib/bb/parse/parse_py
parent44549775ebc01edbca7d934875a43a2d315bdd9b (diff)
downloadpoky-76425295541165421914ef354900a3f2534f59f2.tar.gz
bitbake: Anonymous funciton improvements - use methodpool to allow cached code and remove anonymous function indentation mismatch problems
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py29
1 files changed, 17 insertions, 12 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index e918ce3bb8..03976d4d8c 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -25,7 +25,7 @@
25# with this program; if not, write to the Free Software Foundation, Inc., 25# with this program; if not, write to the Free Software Foundation, Inc.,
26# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 26# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 27
28import re, bb, os, sys, time 28import re, bb, os, sys, time, string
29import bb.fetch, bb.build, bb.utils 29import bb.fetch, bb.build, bb.utils
30from bb import data, fetch, methodpool 30from bb import data, fetch, methodpool
31 31
@@ -89,7 +89,12 @@ def finalise(fn, d):
89 try: 89 try:
90 t = data.getVar('T', d) 90 t = data.getVar('T', d)
91 data.setVar('T', '${TMPDIR}/', d) 91 data.setVar('T', '${TMPDIR}/', d)
92 build.exec_func("__anonfunc", d) 92 anonfuncs = data.getVar('__BBANONFUNCS', d) or []
93 code = ""
94 for f in anonfuncs:
95 code = code + " %s(d)\n" % f
96 data.setVar("__anonfunc", code, d)
97 build.exec_func_python("__anonfunc", d)
93 data.delVar('T', d) 98 data.delVar('T', d)
94 if t: 99 if t:
95 data.setVar('T', t, d) 100 data.setVar('T', t, d)
@@ -205,17 +210,17 @@ def feeder(lineno, s, fn, root, d):
205 if __infunc__: 210 if __infunc__:
206 if s == '}': 211 if s == '}':
207 __body__.append('') 212 __body__.append('')
208 data.setVar(__infunc__, '\n'.join(__body__), d)
209 data.setVarFlag(__infunc__, "func", 1, d)
210 if __infunc__ == "__anonymous": 213 if __infunc__ == "__anonymous":
211 anonqueue = bb.data.getVar("__anonqueue", d) or [] 214 funcname = ("__anon_%s_%s" % (lineno, fn.translate(string.maketrans('/.+-', '____'))))
212 anonitem = {} 215 if not funcname in methodpool._parsed_fns:
213 anonitem["content"] = bb.data.getVar("__anonymous", d) 216 text = "def %s(d):\n" % (funcname) + '\n'.join(__body__)
214 anonitem["flags"] = bb.data.getVarFlags("__anonymous", d) 217 methodpool.insert_method(funcname, text, fn)
215 anonqueue.append(anonitem) 218 anonfuncs = data.getVar('__BBANONFUNCS', d) or []
216 bb.data.setVar("__anonqueue", anonqueue, d) 219 anonfuncs.append(funcname)
217 bb.data.delVarFlags("__anonymous", d) 220 data.setVar('__BBANONFUNCS', anonfuncs, d)
218 bb.data.delVar("__anonymous", d) 221 else:
222 data.setVarFlag(__infunc__, "func", 1, d)
223 data.setVar(__infunc__, '\n'.join(__body__), d)
219 __infunc__ = "" 224 __infunc__ = ""
220 __body__ = [] 225 __body__ = []
221 else: 226 else: