diff options
Diffstat (limited to 'bitbake/lib/bb')
| -rw-r--r-- | bitbake/lib/bb/build.py | 2 | ||||
| -rw-r--r-- | bitbake/lib/bb/data.py | 35 |
2 files changed, 36 insertions, 1 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index f2922f3087..65cc851df4 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
| @@ -227,7 +227,7 @@ def exec_func_python(func, d, runfile, cwd=None): | |||
| 227 | code = _functionfmt.format(function=func, body=d.getVar(func, True)) | 227 | code = _functionfmt.format(function=func, body=d.getVar(func, True)) |
| 228 | bb.utils.mkdirhier(os.path.dirname(runfile)) | 228 | bb.utils.mkdirhier(os.path.dirname(runfile)) |
| 229 | with open(runfile, 'w') as script: | 229 | with open(runfile, 'w') as script: |
| 230 | script.write(code) | 230 | bb.data.emit_func_python(func, script, d) |
| 231 | 231 | ||
| 232 | if cwd: | 232 | if cwd: |
| 233 | try: | 233 | try: |
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index 3d776b32bf..91b1eb1298 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py | |||
| @@ -281,6 +281,41 @@ def emit_func(func, o=sys.__stdout__, d = init()): | |||
| 281 | newdeps |= set((d.getVarFlag(dep, "vardeps", True) or "").split()) | 281 | newdeps |= set((d.getVarFlag(dep, "vardeps", True) or "").split()) |
| 282 | newdeps -= seen | 282 | newdeps -= seen |
| 283 | 283 | ||
| 284 | _functionfmt = """ | ||
| 285 | def {function}(d): | ||
| 286 | {body}""" | ||
| 287 | |||
| 288 | def emit_func_python(func, o=sys.__stdout__, d = init()): | ||
| 289 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" | ||
| 290 | |||
| 291 | def write_func(func, o, call = False): | ||
| 292 | body = d.getVar(func, True) | ||
| 293 | if not body.startswith("def"): | ||
| 294 | body = _functionfmt.format(function=func, body=body) | ||
| 295 | |||
| 296 | o.write(body.strip() + "\n\n") | ||
| 297 | if call: | ||
| 298 | o.write(func + "(d)" + "\n\n") | ||
| 299 | |||
| 300 | write_func(func, o, True) | ||
| 301 | pp = bb.codeparser.PythonParser(func, logger) | ||
| 302 | pp.parse_python(d.getVar(func, True)) | ||
| 303 | newdeps = pp.execs | ||
| 304 | newdeps |= set((d.getVarFlag(func, "vardeps", True) or "").split()) | ||
| 305 | seen = set() | ||
| 306 | while newdeps: | ||
| 307 | deps = newdeps | ||
| 308 | seen |= deps | ||
| 309 | newdeps = set() | ||
| 310 | for dep in deps: | ||
| 311 | if d.getVarFlag(dep, "func") and d.getVarFlag(dep, "python"): | ||
| 312 | write_func(dep, o) | ||
| 313 | pp = bb.codeparser.PythonParser(dep, logger) | ||
| 314 | pp.parse_python(d.getVar(dep, True)) | ||
| 315 | newdeps |= pp.execs | ||
| 316 | newdeps |= set((d.getVarFlag(dep, "vardeps", True) or "").split()) | ||
| 317 | newdeps -= seen | ||
| 318 | |||
| 284 | def update_data(d): | 319 | def update_data(d): |
| 285 | """Performs final steps upon the datastore, including application of overrides""" | 320 | """Performs final steps upon the datastore, including application of overrides""" |
| 286 | d.finalize(parent = True) | 321 | d.finalize(parent = True) |
