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): | |||
246 | f = open(runfile, "w") | 246 | f = open(runfile, "w") |
247 | f.write("#!/bin/sh -e\n") | 247 | f.write("#!/bin/sh -e\n") |
248 | if bb.msg.debug_level['default'] > 0: f.write("set -x\n") | 248 | if bb.msg.debug_level['default'] > 0: f.write("set -x\n") |
249 | data.emit_env(f, d) | 249 | data.emit_func(func, f, d) |
250 | 250 | ||
251 | f.write("cd %s\n" % os.getcwd()) | 251 | f.write("cd %s\n" % os.getcwd()) |
252 | if func: f.write("%s\n" % func) | 252 | 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) | |||
46 | from itertools import groupby | 46 | from itertools import groupby |
47 | 47 | ||
48 | from bb import data_smart | 48 | from bb import data_smart |
49 | from bb import codeparser | ||
49 | import bb | 50 | import bb |
50 | 51 | ||
51 | _dict_type = data_smart.DataSmart | 52 | _dict_type = data_smart.DataSmart |
@@ -243,10 +244,84 @@ def export_vars(d): | |||
243 | pass | 244 | pass |
244 | return ret | 245 | return ret |
245 | 246 | ||
247 | def emit_func(func, o=sys.__stdout__, d = init()): | ||
248 | """Emits all items in the data store in a format such that it can be sourced by a shell.""" | ||
249 | |||
250 | keys = (key for key in d.keys() if not key.startswith("__") and not d.getVarFlag(key, "func")) | ||
251 | for key in keys: | ||
252 | emit_var(key, o, d, False) and o.write('\n') | ||
253 | |||
254 | emit_var(func, o, d, False) and o.write('\n') | ||
255 | newdeps = bb.codeparser.ShellParser().parse_shell(d.getVar(func, True)) | ||
256 | seen = set() | ||
257 | while newdeps: | ||
258 | deps = newdeps | ||
259 | seen |= deps | ||
260 | newdeps = set() | ||
261 | for dep in deps: | ||
262 | if bb.data.getVarFlag(dep, "func", d): | ||
263 | emit_var(dep, o, d, False) and o.write('\n') | ||
264 | newdeps |= bb.codeparser.ShellParser().parse_shell(d.getVar(dep, True)) | ||
265 | newdeps -= seen | ||
266 | |||
246 | def update_data(d): | 267 | def update_data(d): |
247 | """Performs final steps upon the datastore, including application of overrides""" | 268 | """Performs final steps upon the datastore, including application of overrides""" |
248 | d.finalize() | 269 | d.finalize() |
249 | 270 | ||
271 | def build_dependencies(key, keys, shelldeps, d): | ||
272 | deps = set() | ||
273 | try: | ||
274 | if d.getVarFlag(key, "func"): | ||
275 | if d.getVarFlag(key, "python"): | ||
276 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) | ||
277 | parser = bb.codeparser.PythonParser() | ||
278 | parser.parse_python(parsedvar.value) | ||
279 | deps = deps | parser.references | ||
280 | else: | ||
281 | parsedvar = d.expandWithRefs(d.getVar(key, False), key) | ||
282 | parser = bb.codeparser.ShellParser() | ||
283 | parser.parse_shell(parsedvar.value) | ||
284 | deps = deps | shelldeps | ||
285 | deps = deps | parsedvar.references | ||
286 | deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) | ||
287 | else: | ||
288 | parser = d.expandWithRefs(d.getVar(key, False), key) | ||
289 | deps |= parser.references | ||
290 | deps = deps | (keys & parser.execs) | ||
291 | except: | ||
292 | bb.note("Error expanding variable %s" % key) | ||
293 | raise | ||
294 | return deps | ||
295 | #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs))) | ||
296 | #d.setVarFlag(key, "vardeps", deps) | ||
297 | |||
298 | def generate_dependencies(d): | ||
299 | |||
300 | keys = set(key for key in d.keys() if not key.startswith("__")) | ||
301 | shelldeps = set(key for key in keys if d.getVarFlag(key, "export") and not d.getVarFlag(key, "unexport")) | ||
302 | |||
303 | deps = {} | ||
304 | taskdeps = {} | ||
305 | |||
306 | tasklist = bb.data.getVar('__BBTASKS', d) or [] | ||
307 | for task in tasklist: | ||
308 | deps[task] = build_dependencies(task, keys, shelldeps, d) | ||
309 | |||
310 | newdeps = deps[task] | ||
311 | seen = set() | ||
312 | while newdeps: | ||
313 | nextdeps = newdeps | ||
314 | seen |= nextdeps | ||
315 | newdeps = set() | ||
316 | for dep in nextdeps: | ||
317 | if dep not in deps: | ||
318 | deps[dep] = build_dependencies(dep, keys, shelldeps, d) | ||
319 | newdeps |= deps[dep] | ||
320 | newdeps -= seen | ||
321 | taskdeps[task] = seen | newdeps | ||
322 | #print "For %s: %s" % (task, str(taskdeps[task])) | ||
323 | return taskdeps, deps | ||
324 | |||
250 | def inherits_class(klass, d): | 325 | def inherits_class(klass, d): |
251 | val = getVar('__inherit_cache', d) or [] | 326 | val = getVar('__inherit_cache', d) or [] |
252 | if os.path.join('classes', '%s.bbclass' % klass) in val: | 327 | 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): | |||
323 | tasklist = bb.data.getVar('__BBTASKS', d) or [] | 323 | tasklist = bb.data.getVar('__BBTASKS', d) or [] |
324 | bb.build.add_tasks(tasklist, d) | 324 | bb.build.add_tasks(tasklist, d) |
325 | 325 | ||
326 | #bb.data.generate_dependencies(d) | ||
327 | |||
326 | bb.event.fire(bb.event.RecipeParsed(fn), d) | 328 | bb.event.fire(bb.event.RecipeParsed(fn), d) |
327 | 329 | ||
328 | def _create_variants(datastores, names, function): | 330 | def _create_variants(datastores, names, function): |