diff options
Diffstat (limited to 'bitbake/lib/bb/parse')
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index d2ae09a4a4..d767882e53 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -122,8 +122,12 @@ class MethodNode: | |||
122 | 122 | ||
123 | def eval(self, data): | 123 | def eval(self, data): |
124 | if self.func_name == "__anonymous": | 124 | if self.func_name == "__anonymous": |
125 | funcname = ("__anon_%s_%s" % (self.lineno, self.fn.translate(string.maketrans('/.+-', '____')))) | ||
126 | if not funcname in bb.methodpool._parsed_fns: | ||
127 | text = "def %s(d):\n" % (funcname) + '\n'.join(self.body) | ||
128 | bb.methodpool.insert_method(funcname, text, self.fn) | ||
125 | anonfuncs = bb.data.getVar('__BBANONFUNCS', data) or [] | 129 | anonfuncs = bb.data.getVar('__BBANONFUNCS', data) or [] |
126 | anonfuncs.append((self.fn, "\n".join(self.body))) | 130 | anonfuncs.append(funcname) |
127 | bb.data.setVar('__BBANONFUNCS', anonfuncs, data) | 131 | bb.data.setVar('__BBANONFUNCS', anonfuncs, data) |
128 | else: | 132 | else: |
129 | bb.data.setVarFlag(self.func_name, "func", 1, data) | 133 | bb.data.setVarFlag(self.func_name, "func", 1, data) |
@@ -297,9 +301,10 @@ def finalise(fn, d): | |||
297 | 301 | ||
298 | bb.data.expandKeys(d) | 302 | bb.data.expandKeys(d) |
299 | bb.data.update_data(d) | 303 | bb.data.update_data(d) |
300 | for fn, func in bb.data.getVar("__BBANONFUNCS", d) or []: | 304 | code = [] |
301 | funcdef = "def __anonfunc(d):\n%s\n__anonfunc(d)" % func.rstrip() | 305 | for funcname in bb.data.getVar("__BBANONFUNCS", d) or []: |
302 | bb.utils.better_exec(funcdef, {"d": d}, funcdef, fn) | 306 | code.append("%s(d)" % funcname) |
307 | bb.utils.simple_exec("\n".join(code), {"d": d}) | ||
303 | bb.data.update_data(d) | 308 | bb.data.update_data(d) |
304 | 309 | ||
305 | all_handlers = {} | 310 | all_handlers = {} |