summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/data.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-24 17:41:02 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-11-24 22:11:45 +0000
commitb62a7559a31fa1241954746ed67af575d8bd6ca5 (patch)
tree7e30f05b51575deba4c715e7747fa82d1043ce84 /bitbake/lib/bb/data.py
parent437928dfa4fdcf6abe4b4eb9ca03fd7db31404a0 (diff)
downloadpoky-b62a7559a31fa1241954746ed67af575d8bd6ca5.tar.gz
data/siggen: Add vardepvalue mechanism to allow the variable dependency code to be forced to specific values
We have a problem if we want to inject specific information into the variable dependency code. There are cases for example where we want a dependency on the value of X but it doesn't matter how X was constructed or what dependencies it might have had, we only care about the absolute value. With the current code, its near enough impossible to do this. This patch adds such a mechanism so the user can trigger this with code like: baselib[vardepvalue] = "${baselib}" It also refactors some of the code so we do variable lookups once instead of doing this in two different functions. [YOCTO #1583] (Bitbake rev: 6c879b44ccf42dc73fe4467076e114700d7ba81b) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/data.py')
-rw-r--r--bitbake/lib/bb/data.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 10188f3807..7c1533cfa9 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -275,18 +275,21 @@ def update_data(d):
275 """Performs final steps upon the datastore, including application of overrides""" 275 """Performs final steps upon the datastore, including application of overrides"""
276 d.finalize() 276 d.finalize()
277 277
278def build_dependencies(key, keys, shelldeps, d): 278def build_dependencies(key, keys, shelldeps, vardepvals, d):
279 deps = set() 279 deps = set()
280 vardeps = d.getVarFlag(key, "vardeps", True) 280 vardeps = d.getVarFlag(key, "vardeps", True)
281 try: 281 try:
282 if d.getVarFlag(key, "func"): 282 value = d.getVar(key, False)
283 if key in vardepvals:
284 value = d.getVarFlag(key, "vardepvalue", True)
285 elif d.getVarFlag(key, "func"):
283 if d.getVarFlag(key, "python"): 286 if d.getVarFlag(key, "python"):
284 parsedvar = d.expandWithRefs(d.getVar(key, False), key) 287 parsedvar = d.expandWithRefs(value, key)
285 parser = bb.codeparser.PythonParser(key, logger) 288 parser = bb.codeparser.PythonParser(key, logger)
286 parser.parse_python(parsedvar.value) 289 parser.parse_python(parsedvar.value)
287 deps = deps | parser.references 290 deps = deps | parser.references
288 else: 291 else:
289 parsedvar = d.expandWithRefs(d.getVar(key, False), key) 292 parsedvar = d.expandWithRefs(value, key)
290 parser = bb.codeparser.ShellParser(key, logger) 293 parser = bb.codeparser.ShellParser(key, logger)
291 parser.parse_shell(parsedvar.value) 294 parser.parse_shell(parsedvar.value)
292 deps = deps | shelldeps 295 deps = deps | shelldeps
@@ -295,7 +298,7 @@ def build_dependencies(key, keys, shelldeps, d):
295 deps = deps | parsedvar.references 298 deps = deps | parsedvar.references
296 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) 299 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs)
297 else: 300 else:
298 parser = d.expandWithRefs(d.getVar(key, False), key) 301 parser = d.expandWithRefs(value, key)
299 deps |= parser.references 302 deps |= parser.references
300 deps = deps | (keys & parser.execs) 303 deps = deps | (keys & parser.execs)
301 deps |= set((vardeps or "").split()) 304 deps |= set((vardeps or "").split())
@@ -303,7 +306,7 @@ def build_dependencies(key, keys, shelldeps, d):
303 except: 306 except:
304 bb.note("Error expanding variable %s" % key) 307 bb.note("Error expanding variable %s" % key)
305 raise 308 raise
306 return deps 309 return deps, value
307 #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs))) 310 #bb.note("Variable %s references %s and calls %s" % (key, str(deps), str(execs)))
308 #d.setVarFlag(key, "vardeps", deps) 311 #d.setVarFlag(key, "vardeps", deps)
309 312
@@ -311,12 +314,14 @@ def generate_dependencies(d):
311 314
312 keys = set(key for key in d.keys() if not key.startswith("__")) 315 keys = set(key for key in d.keys() if not key.startswith("__"))
313 shelldeps = set(key for key in keys if d.getVarFlag(key, "export") and not d.getVarFlag(key, "unexport")) 316 shelldeps = set(key for key in keys if d.getVarFlag(key, "export") and not d.getVarFlag(key, "unexport"))
317 vardepvals = set(key for key in keys if d.getVarFlag(key, "vardepvalue"))
314 318
315 deps = {} 319 deps = {}
320 values = {}
316 321
317 tasklist = bb.data.getVar('__BBTASKS', d) or [] 322 tasklist = bb.data.getVar('__BBTASKS', d) or []
318 for task in tasklist: 323 for task in tasklist:
319 deps[task] = build_dependencies(task, keys, shelldeps, d) 324 deps[task], values[task] = build_dependencies(task, keys, shelldeps, vardepvals, d)
320 newdeps = deps[task] 325 newdeps = deps[task]
321 seen = set() 326 seen = set()
322 while newdeps: 327 while newdeps:
@@ -325,11 +330,11 @@ def generate_dependencies(d):
325 newdeps = set() 330 newdeps = set()
326 for dep in nextdeps: 331 for dep in nextdeps:
327 if dep not in deps: 332 if dep not in deps:
328 deps[dep] = build_dependencies(dep, keys, shelldeps, d) 333 deps[dep], values[dep] = build_dependencies(dep, keys, shelldeps, vardepvals, d)
329 newdeps |= deps[dep] 334 newdeps |= deps[dep]
330 newdeps -= seen 335 newdeps -= seen
331 #print "For %s: %s" % (task, str(taskdeps[task])) 336 #print "For %s: %s" % (task, str(taskdeps[task]))
332 return tasklist, deps 337 return tasklist, deps, values
333 338
334def inherits_class(klass, d): 339def inherits_class(klass, d):
335 val = getVar('__inherit_cache', d) or [] 340 val = getVar('__inherit_cache', d) or []