aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2010-08-03 14:30:20 +0100
committerRichard Purdie <rpurdie@linux.intel.com>2010-08-31 12:47:41 +0100
commit332c33af188c14dd0051d8a45fe0ad680611db69 (patch)
tree62b50d333ac8404671b591b7f6ba8fc71abc1c89 /bitbake
parent3492bff64a809b3a2a2376b83f41e099e16d22f6 (diff)
downloadopenembedded-core-contrib-332c33af188c14dd0051d8a45fe0ad680611db69.tar.gz
bitbake/data.py: Add emit_func() and generate_dependencies() functions
These functions allow generation of dependency data between funcitons and variables allowing moves to be made towards generating checksums and allowing use of the dependency information in other parts of bitbake. Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/build.py2
-rw-r--r--bitbake/lib/bb/data.py75
-rw-r--r--bitbake/lib/bb/parse/ast.py2
3 files changed, 78 insertions, 1 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index f49b2836b6d..ee138a914aa 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 223f9c50523..4cad495b0ad 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 8763362cdf0..3c341b0c70e 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):