diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/build.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/data.py | 75 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 2 |
3 files changed, 78 insertions, 1 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index f49b2836b6..ee138a914a 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -246,7 +246,7 @@ def exec_func_shell(func, d, runfile, logfile, flags): f = open(runfile, "w") f.write("#!/bin/sh -e\n") if bb.msg.debug_level['default'] > 0: f.write("set -x\n") - data.emit_env(f, d) + data.emit_func(func, f, d) f.write("cd %s\n" % os.getcwd()) if func: f.write("%s\n" % func) diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index 223f9c5052..4cad495b0a 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py @@ -46,6 +46,7 @@ sys.path.insert(0, path) from itertools import groupby from bb import data_smart +from bb import codeparser import bb _dict_type = data_smart.DataSmart @@ -243,10 +244,84 @@ def export_vars(d): pass return ret +def emit_func(func, o=sys.__stdout__, d = init()): + """Emits all items in the data store in a format such that it can be sourced by a shell.""" + + keys = (key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func")) + for key in keys: + emit_var(key, o, d, False) and o.write('\n') + + emit_var(func, o, d, False) and o.write('\n') + newdeps = bb.codeparser.ShellParser().parse_shell(d.getVar(func, True)) + seen = set() + while newdeps: + deps = newdeps + seen |= deps + newdeps = set() + for dep in deps: + if bb.data.getVarFlag(dep, "func", d): + emit_var(dep, o, d, False) and o.write('\n') + newdeps |= bb.codeparser.ShellParser().parse_shell(d.getVar(dep, True)) + newdeps -= seen + def update_data(d): """Performs final steps upon the datastore, including application of overrides""" d.finalize() +def build_dependencies(key, keys, shelldeps, d): + deps = set() + try: + if d.getVarFlag(key, "func"): + if d.getVarFlag(key, "python"): + parsedvar = d.expandWithRefs(d.getVar(key, False), key) + parser = bb.codeparser.PythonParser() + parser.parse_python(parsedvar.value) + deps = deps | parser.references + else: + parsedvar = d.expandWithRefs(d.getVar(key, False), key) + parser = bb.codeparser.ShellParser() + parser.parse_shell(parsedvar.value) + deps = deps | shelldeps + deps = deps | parsedvar.references + deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) + else: + parser = d.expandWithRefs(d.getVar(key, False), key) + deps |= parser.references + deps = deps | (keys & parser.execs) + except: + bb.note("Error expanding variable %s" % key) + raise + return deps + #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs))) + #d.setVarFlag(key, "vardeps", deps) + +def generate_dependencies(d): + + keys = set(key for key in d.keys() if not key.startswith("__")) + shelldeps = set(key for key in keys if d.getVarFlag(key, "export") and not d.getVarFlag(key, "unexport")) + + deps = {} + taskdeps = {} + + tasklist = bb.data.getVar('__BBTASKS', d) or [] + for task in tasklist: + deps[task] = build_dependencies(task, keys, shelldeps, d) + + newdeps = deps[task] + seen = set() + while newdeps: + nextdeps = newdeps + seen |= nextdeps + newdeps = set() + for dep in nextdeps: + if dep not in deps: + deps[dep] = build_dependencies(dep, keys, shelldeps, d) + newdeps |= deps[dep] + newdeps -= seen + taskdeps[task] = seen | newdeps + #print "For %s: %s" % (task, str(taskdeps[task])) + return taskdeps, deps + def inherits_class(klass, d): val = getVar('__inherit_cache', d) or [] if os.path.join('classes', '%s.bbclass' % klass) in val: diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 8763362cdf..3c341b0c70 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py @@ -323,6 +323,8 @@ def finalize(fn, d): tasklist = bb.data.getVar('__BBTASKS', d) or [] bb.build.add_tasks(tasklist, d) + #bb.data.generate_dependencies(d) + bb.event.fire(bb.event.RecipeParsed(fn), d) def _create_variants(datastores, names, function): |