summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r--bitbake/lib/bb/build.py15
1 files changed, 8 insertions, 7 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 1cd546a712..d20ee065b2 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -229,17 +229,13 @@ def exec_func(func, d, dirs = None):
229 exec_func_shell(func, d, runfile, cwd=adir) 229 exec_func_shell(func, d, runfile, cwd=adir)
230 230
231_functionfmt = """ 231_functionfmt = """
232def {function}(d):
233{body}
234
235{function}(d) 232{function}(d)
236""" 233"""
237logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s") 234logformatter = bb.msg.BBLogFormatter("%(levelname)s: %(message)s")
238def exec_func_python(func, d, runfile, cwd=None): 235def exec_func_python(func, d, runfile, cwd=None):
239 """Execute a python BB 'function'""" 236 """Execute a python BB 'function'"""
240 237
241 bbfile = d.getVar('FILE', True) 238 code = _functionfmt.format(function=func)
242 code = _functionfmt.format(function=func, body=d.getVar(func, False))
243 bb.utils.mkdirhier(os.path.dirname(runfile)) 239 bb.utils.mkdirhier(os.path.dirname(runfile))
244 with open(runfile, 'w') as script: 240 with open(runfile, 'w') as script:
245 bb.data.emit_func_python(func, script, d) 241 bb.data.emit_func_python(func, script, d)
@@ -254,8 +250,13 @@ def exec_func_python(func, d, runfile, cwd=None):
254 bb.debug(2, "Executing python function %s" % func) 250 bb.debug(2, "Executing python function %s" % func)
255 251
256 try: 252 try:
257 comp = utils.better_compile(code, func, bbfile) 253 text = "def %s(d):\n%s" % (func, d.getVar(func, False))
258 utils.better_exec(comp, {"d": d}, code, bbfile) 254 fn = d.getVarFlag(func, "filename", False)
255 lineno = int(d.getVarFlag(func, "lineno", False))
256 bb.methodpool.insert_method(func, text, fn, lineno - 1)
257
258 comp = utils.better_compile(code, func, "exec_python_func() autogenerated")
259 utils.better_exec(comp, {"d": d}, code, "exec_python_func() autogenerated")
259 except (bb.parse.SkipRecipe, bb.build.FuncFailed): 260 except (bb.parse.SkipRecipe, bb.build.FuncFailed):
260 raise 261 raise
261 except: 262 except: