summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-02 14:07:58 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-02-10 15:47:11 +0000
commitaece74876271f692296c5f792104c627e15b5c3e (patch)
treee02326501eb4847567f59d4d2d178cb737ac337b /bitbake/lib/bb/data.py
parente39cfb1f9c491a1b8bc5730b83616ec56e3a6c64 (diff)
downloadpoky-aece74876271f692296c5f792104c627e15b5c3e.tar.gz
bitbake: build/data: Don't expand python functions before execution [API change]
Right now, if you have some python code like: X = "a" def somefunction(d): d.setVar("X", "b") d.setVar("Y", "${X}") then any sane person would expect that Y = "b" at the end of the function. This is not the case, Y = "a". This is due to the python function being expanded before execution, the executed code would read d.setVar("Y", "a"). This understandably confuses people, it also makes it near impossible to write ${} in a python function without unintended things happening. I think there is general agreement we should fix this and standardise on non-expansion of python functions. We already don't expand anonymous python (mostly). I've checked OE-Core with buildhistory before and after this change and there were a small number of issues this exposed which I've sent patches for. I propose we default to not expanding python code and then deal with any consequences from that if/as/where identified. This will improve new user understanding and usability of the system, it also allows several long standing weird expansion issues to be fixed. (Bitbake rev: 8bf33a8e92c0e188fa392030025756196c96fcbb) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data.py')
-rw-r--r--bitbake/lib/bb/data.py6
1 files changed, 3 insertions, 3 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 137ed4e3ee..dbc6dea68d 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -298,7 +298,7 @@ def emit_func_python(func, o=sys.__stdout__, d = init()):
298 """Emits all items in the data store in a format such that it can be sourced by a shell.""" 298 """Emits all items in the data store in a format such that it can be sourced by a shell."""
299 299
300 def write_func(func, o, call = False): 300 def write_func(func, o, call = False):
301 body = d.getVar(func, True) 301 body = d.getVar(func, False)
302 if not body.startswith("def"): 302 if not body.startswith("def"):
303 body = _functionfmt.format(function=func, body=body) 303 body = _functionfmt.format(function=func, body=body)
304 304
@@ -308,7 +308,7 @@ def emit_func_python(func, o=sys.__stdout__, d = init()):
308 308
309 write_func(func, o, True) 309 write_func(func, o, True)
310 pp = bb.codeparser.PythonParser(func, logger) 310 pp = bb.codeparser.PythonParser(func, logger)
311 pp.parse_python(d.getVar(func, True)) 311 pp.parse_python(d.getVar(func, False))
312 newdeps = pp.execs 312 newdeps = pp.execs
313 newdeps |= set((d.getVarFlag(func, "vardeps", True) or "").split()) 313 newdeps |= set((d.getVarFlag(func, "vardeps", True) or "").split())
314 seen = set() 314 seen = set()
@@ -320,7 +320,7 @@ def emit_func_python(func, o=sys.__stdout__, d = init()):
320 if d.getVarFlag(dep, "func", False) and d.getVarFlag(dep, "python", False): 320 if d.getVarFlag(dep, "func", False) and d.getVarFlag(dep, "python", False):
321 write_func(dep, o) 321 write_func(dep, o)
322 pp = bb.codeparser.PythonParser(dep, logger) 322 pp = bb.codeparser.PythonParser(dep, logger)
323 pp.parse_python(d.getVar(dep, True)) 323 pp.parse_python(d.getVar(dep, False))
324 newdeps |= pp.execs 324 newdeps |= pp.execs
325 newdeps |= set((d.getVarFlag(dep, "vardeps", True) or "").split()) 325 newdeps |= set((d.getVarFlag(dep, "vardeps", True) or "").split())
326 newdeps -= seen 326 newdeps -= seen