summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-02 09:21:13 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2022-04-03 17:51:26 +0100
commit70d6360602766232ca096ee427bb85564ac16a69 (patch)
treeaf5c36db793b01bdec5156656f2632df98d0bc37 /bitbake
parentb868387c425cca35c06179b90d44422fbaf2a9ab (diff)
downloadpoky-70d6360602766232ca096ee427bb85564ac16a69.tar.gz
bitbake: data: Ensure vardepsexclude or BB_BASEHASH_IGNORE_VARS covers contains items
Adding bb.utils.filter('WARN_QA', 'patch-fuzz', d) when WARN_QA is in BB_BASEHASH_IGNORE_VARS or in vardepsexclude should not add a dependency on WARN_QA. Fix it and add some tests. (Bitbake rev: 6aecc2fe51a52020f6f13be08449e18d42e7a6b5) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/lib/bb/data.py21
-rw-r--r--bitbake/lib/bb/tests/codeparser.py28
2 files changed, 35 insertions, 14 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 5d02bab99b..363901b5d3 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -272,7 +272,7 @@ def update_data(d):
272 """Performs final steps upon the datastore, including application of overrides""" 272 """Performs final steps upon the datastore, including application of overrides"""
273 d.finalize(parent = True) 273 d.finalize(parent = True)
274 274
275def build_dependencies(key, keys, shelldeps, varflagsexcl, d): 275def build_dependencies(key, keys, shelldeps, varflagsexcl, ignored_vars, d):
276 deps = set() 276 deps = set()
277 try: 277 try:
278 if key[-1] == ']': 278 if key[-1] == ']':
@@ -283,12 +283,15 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
283 return deps, value 283 return deps, value
284 varflags = d.getVarFlags(key, ["vardeps", "vardepvalue", "vardepsexclude", "exports", "postfuncs", "prefuncs", "lineno", "filename"]) or {} 284 varflags = d.getVarFlags(key, ["vardeps", "vardepvalue", "vardepsexclude", "exports", "postfuncs", "prefuncs", "lineno", "filename"]) or {}
285 vardeps = varflags.get("vardeps") 285 vardeps = varflags.get("vardeps")
286 exclusions = varflags.get("vardepsexclude", "").split()
286 287
287 def handle_contains(value, contains, d): 288 def handle_contains(value, contains, exclusions, d):
288 newvalue = [] 289 newvalue = []
289 if value: 290 if value:
290 newvalue.append(str(value)) 291 newvalue.append(str(value))
291 for k in sorted(contains): 292 for k in sorted(contains):
293 if k in exclusions or k in ignored_vars:
294 continue
292 l = (d.getVar(k) or "").split() 295 l = (d.getVar(k) or "").split()
293 for item in sorted(contains[k]): 296 for item in sorted(contains[k]):
294 for word in item.split(): 297 for word in item.split():
@@ -316,7 +319,7 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
316 parser.parse_python(value, filename=varflags.get("filename"), lineno=varflags.get("lineno")) 319 parser.parse_python(value, filename=varflags.get("filename"), lineno=varflags.get("lineno"))
317 deps = deps | parser.references 320 deps = deps | parser.references
318 deps = deps | (keys & parser.execs) 321 deps = deps | (keys & parser.execs)
319 value = handle_contains(value, parser.contains, d) 322 value = handle_contains(value, parser.contains, exclusions, d)
320 else: 323 else:
321 value, parsedvar = d.getVarFlag(key, "_content", False, retparser=True) 324 value, parsedvar = d.getVarFlag(key, "_content", False, retparser=True)
322 parser = bb.codeparser.ShellParser(key, logger) 325 parser = bb.codeparser.ShellParser(key, logger)
@@ -324,9 +327,9 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
324 deps = deps | shelldeps 327 deps = deps | shelldeps
325 deps = deps | parsedvar.references 328 deps = deps | parsedvar.references
326 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs) 329 deps = deps | (keys & parser.execs) | (keys & parsedvar.execs)
327 value = handle_contains(value, parsedvar.contains, d) 330 value = handle_contains(value, parsedvar.contains, exclusions, d)
328 if hasattr(parsedvar, "removes"): 331 if hasattr(parsedvar, "removes"):
329 value = handle_remove(value, deps, parsedvar.removes, d) 332 value = handle_remove(value, deps, parsedvar.removes, varflags, d)
330 if vardeps is None: 333 if vardeps is None:
331 parser.log.flush() 334 parser.log.flush()
332 if "prefuncs" in varflags: 335 if "prefuncs" in varflags:
@@ -339,7 +342,7 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
339 value, parser = d.getVarFlag(key, "_content", False, retparser=True) 342 value, parser = d.getVarFlag(key, "_content", False, retparser=True)
340 deps |= parser.references 343 deps |= parser.references
341 deps = deps | (keys & parser.execs) 344 deps = deps | (keys & parser.execs)
342 value = handle_contains(value, parser.contains, d) 345 value = handle_contains(value, parser.contains, exclusions, d)
343 if hasattr(parser, "removes"): 346 if hasattr(parser, "removes"):
344 value = handle_remove(value, deps, parser.removes, d) 347 value = handle_remove(value, deps, parser.removes, d)
345 348
@@ -359,7 +362,7 @@ def build_dependencies(key, keys, shelldeps, varflagsexcl, d):
359 deps |= set(varfdeps) 362 deps |= set(varfdeps)
360 363
361 deps |= set((vardeps or "").split()) 364 deps |= set((vardeps or "").split())
362 deps -= set(varflags.get("vardepsexclude", "").split()) 365 deps -= set(exclusions)
363 except bb.parse.SkipRecipe: 366 except bb.parse.SkipRecipe:
364 raise 367 raise
365 except Exception as e: 368 except Exception as e:
@@ -380,7 +383,7 @@ def generate_dependencies(d, ignored_vars):
380 383
381 tasklist = d.getVar('__BBTASKS', False) or [] 384 tasklist = d.getVar('__BBTASKS', False) or []
382 for task in tasklist: 385 for task in tasklist:
383 deps[task], values[task] = build_dependencies(task, keys, shelldeps, varflagsexcl, d) 386 deps[task], values[task] = build_dependencies(task, keys, shelldeps, varflagsexcl, ignored_vars, d)
384 newdeps = deps[task] 387 newdeps = deps[task]
385 seen = set() 388 seen = set()
386 while newdeps: 389 while newdeps:
@@ -389,7 +392,7 @@ def generate_dependencies(d, ignored_vars):
389 newdeps = set() 392 newdeps = set()
390 for dep in nextdeps: 393 for dep in nextdeps:
391 if dep not in deps: 394 if dep not in deps:
392 deps[dep], values[dep] = build_dependencies(dep, keys, shelldeps, varflagsexcl, d) 395 deps[dep], values[dep] = build_dependencies(dep, keys, shelldeps, varflagsexcl, ignored_vars, d)
393 newdeps |= deps[dep] 396 newdeps |= deps[dep]
394 newdeps -= seen 397 newdeps -= seen
395 #print "For %s: %s" % (task, str(deps[task])) 398 #print "For %s: %s" % (task, str(deps[task]))
diff --git a/bitbake/lib/bb/tests/codeparser.py b/bitbake/lib/bb/tests/codeparser.py
index f485204791..71ed382ab8 100644
--- a/bitbake/lib/bb/tests/codeparser.py
+++ b/bitbake/lib/bb/tests/codeparser.py
@@ -318,7 +318,7 @@ d.getVar(a(), False)
318 "filename": "example.bb", 318 "filename": "example.bb",
319 }) 319 })
320 320
321 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), self.d) 321 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), self.d)
322 322
323 self.assertEqual(deps, set(["somevar", "bar", "something", "inexpand", "test", "test2", "a"])) 323 self.assertEqual(deps, set(["somevar", "bar", "something", "inexpand", "test", "test2", "a"]))
324 324
@@ -365,7 +365,7 @@ esac
365 self.d.setVarFlags("FOO", {"func": True}) 365 self.d.setVarFlags("FOO", {"func": True})
366 self.setEmptyVars(execs) 366 self.setEmptyVars(execs)
367 367
368 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), self.d) 368 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), self.d)
369 369
370 self.assertEqual(deps, set(["somevar", "inverted"] + execs)) 370 self.assertEqual(deps, set(["somevar", "inverted"] + execs))
371 371
@@ -375,7 +375,7 @@ esac
375 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo") 375 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo")
376 self.d.setVarFlag("FOO", "vardeps", "oe_libinstall") 376 self.d.setVarFlag("FOO", "vardeps", "oe_libinstall")
377 377
378 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), self.d) 378 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), self.d)
379 379
380 self.assertEqual(deps, set(["oe_libinstall"])) 380 self.assertEqual(deps, set(["oe_libinstall"]))
381 381
@@ -384,7 +384,7 @@ esac
384 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo") 384 self.d.setVar("FOO", "foo=oe_libinstall; eval $foo")
385 self.d.setVarFlag("FOO", "vardeps", "${@'oe_libinstall'}") 385 self.d.setVarFlag("FOO", "vardeps", "${@'oe_libinstall'}")
386 386
387 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), self.d) 387 deps, values = bb.data.build_dependencies("FOO", set(self.d.keys()), set(), set(), set(), self.d)
388 388
389 self.assertEqual(deps, set(["oe_libinstall"])) 389 self.assertEqual(deps, set(["oe_libinstall"]))
390 390
@@ -399,7 +399,7 @@ esac
399 # Check dependencies 399 # Check dependencies
400 self.d.setVar('ANOTHERVAR', expr) 400 self.d.setVar('ANOTHERVAR', expr)
401 self.d.setVar('TESTVAR', 'anothervalue testval testval2') 401 self.d.setVar('TESTVAR', 'anothervalue testval testval2')
402 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), self.d) 402 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), self.d)
403 self.assertEqual(sorted(values.splitlines()), 403 self.assertEqual(sorted(values.splitlines()),
404 sorted([expr, 404 sorted([expr,
405 'TESTVAR{anothervalue} = Set', 405 'TESTVAR{anothervalue} = Set',
@@ -412,6 +412,24 @@ esac
412 # Check final value 412 # Check final value
413 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['anothervalue', 'yetanothervalue', 'lastone']) 413 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['anothervalue', 'yetanothervalue', 'lastone'])
414 414
415 def test_contains_vardeps_excluded(self):
416 # Check the ignored_vars option to build_dependencies is handled by contains functionality
417 varval = '${TESTVAR2} ${@bb.utils.filter("TESTVAR", "somevalue anothervalue", d)}'
418 self.d.setVar('ANOTHERVAR', varval)
419 self.d.setVar('TESTVAR', 'anothervalue testval testval2')
420 self.d.setVar('TESTVAR2', 'testval3')
421 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(["TESTVAR"]), self.d)
422 self.assertEqual(sorted(values.splitlines()), sorted([varval]))
423 self.assertEqual(deps, set(["TESTVAR2"]))
424 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue'])
425
426 # Check the vardepsexclude flag is handled by contains functionality
427 self.d.setVarFlag('ANOTHERVAR', 'vardepsexclude', 'TESTVAR')
428 deps, values = bb.data.build_dependencies("ANOTHERVAR", set(self.d.keys()), set(), set(), set(), self.d)
429 self.assertEqual(sorted(values.splitlines()), sorted([varval]))
430 self.assertEqual(deps, set(["TESTVAR2"]))
431 self.assertEqual(self.d.getVar('ANOTHERVAR').split(), ['testval3', 'anothervalue'])
432
415 #Currently no wildcard support 433 #Currently no wildcard support
416 #def test_vardeps_wildcards(self): 434 #def test_vardeps_wildcards(self):
417 # self.d.setVar("oe_libinstall", "echo test") 435 # self.d.setVar("oe_libinstall", "echo test")