diff options
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/__init__.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/event.py | 10 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 25 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 10 |
4 files changed, 34 insertions, 13 deletions
diff --git a/bitbake/lib/bb/__init__.py b/bitbake/lib/bb/__init__.py index c95c91a4cb..62ceaaef6e 100644 --- a/bitbake/lib/bb/__init__.py +++ b/bitbake/lib/bb/__init__.py | |||
@@ -9,7 +9,7 @@ | |||
9 | # SPDX-License-Identifier: GPL-2.0-only | 9 | # SPDX-License-Identifier: GPL-2.0-only |
10 | # | 10 | # |
11 | 11 | ||
12 | __version__ = "2.12.0" | 12 | __version__ = "2.15.0" |
13 | 13 | ||
14 | import sys | 14 | import sys |
15 | if sys.version_info < (3, 9, 0): | 15 | if sys.version_info < (3, 9, 0): |
diff --git a/bitbake/lib/bb/event.py b/bitbake/lib/bb/event.py index a12adbc937..b29f0a5568 100644 --- a/bitbake/lib/bb/event.py +++ b/bitbake/lib/bb/event.py | |||
@@ -431,6 +431,16 @@ class RecipeEvent(Event): | |||
431 | self.fn = fn | 431 | self.fn = fn |
432 | Event.__init__(self) | 432 | Event.__init__(self) |
433 | 433 | ||
434 | class RecipePreDeferredInherits(RecipeEvent): | ||
435 | """ | ||
436 | Called before deferred inherits are processed so code can snoop on class extensions for example | ||
437 | Limitations: It won't see inherits of inherited classes and the data is unexpanded | ||
438 | """ | ||
439 | def __init__(self, fn, inherits): | ||
440 | self.fn = fn | ||
441 | self.inherits = inherits | ||
442 | Event.__init__(self) | ||
443 | |||
434 | class RecipePreFinalise(RecipeEvent): | 444 | class RecipePreFinalise(RecipeEvent): |
435 | """ Recipe Parsing Complete but not yet finalised""" | 445 | """ Recipe Parsing Complete but not yet finalised""" |
436 | 446 | ||
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 290ed45048..ea1096f2de 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -340,9 +340,7 @@ class InheritDeferredNode(AstNode): | |||
340 | self.inherit = (classes, filename, lineno) | 340 | self.inherit = (classes, filename, lineno) |
341 | 341 | ||
342 | def eval(self, data): | 342 | def eval(self, data): |
343 | inherits = data.getVar('__BBDEFINHERITS', False) or [] | 343 | bb.parse.BBHandler.inherit_defer(*self.inherit, data) |
344 | inherits.append(self.inherit) | ||
345 | data.setVar('__BBDEFINHERITS', inherits) | ||
346 | 344 | ||
347 | class AddFragmentsNode(AstNode): | 345 | class AddFragmentsNode(AstNode): |
348 | def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable): | 346 | def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable): |
@@ -471,6 +469,17 @@ def finalize(fn, d, variant = None): | |||
471 | if d.getVar("_FAILPARSINGERRORHANDLED", False) == True: | 469 | if d.getVar("_FAILPARSINGERRORHANDLED", False) == True: |
472 | raise bb.BBHandledException() | 470 | raise bb.BBHandledException() |
473 | 471 | ||
472 | inherits = [x[0] for x in (d.getVar('__BBDEFINHERITS', False) or [('',)])] | ||
473 | bb.event.fire(bb.event.RecipePreDeferredInherits(fn, inherits), d) | ||
474 | |||
475 | while True: | ||
476 | inherits = d.getVar('__BBDEFINHERITS', False) or [] | ||
477 | if not inherits: | ||
478 | break | ||
479 | inherit, filename, lineno = inherits.pop(0) | ||
480 | d.setVar('__BBDEFINHERITS', inherits) | ||
481 | bb.parse.BBHandler.inherit(inherit, filename, lineno, d, deferred=True) | ||
482 | |||
474 | for var in d.getVar('__BBHANDLERS', False) or []: | 483 | for var in d.getVar('__BBHANDLERS', False) or []: |
475 | # try to add the handler | 484 | # try to add the handler |
476 | handlerfn = d.getVarFlag(var, "filename", False) | 485 | handlerfn = d.getVarFlag(var, "filename", False) |
@@ -525,14 +534,6 @@ def multi_finalize(fn, d): | |||
525 | logger.debug("Appending .bbappend file %s to %s", append, fn) | 534 | logger.debug("Appending .bbappend file %s to %s", append, fn) |
526 | bb.parse.BBHandler.handle(append, d, True) | 535 | bb.parse.BBHandler.handle(append, d, True) |
527 | 536 | ||
528 | while True: | ||
529 | inherits = d.getVar('__BBDEFINHERITS', False) or [] | ||
530 | if not inherits: | ||
531 | break | ||
532 | inherit, filename, lineno = inherits.pop(0) | ||
533 | d.setVar('__BBDEFINHERITS', inherits) | ||
534 | bb.parse.BBHandler.inherit(inherit, filename, lineno, d, deferred=True) | ||
535 | |||
536 | onlyfinalise = d.getVar("__ONLYFINALISE", False) | 537 | onlyfinalise = d.getVar("__ONLYFINALISE", False) |
537 | 538 | ||
538 | safe_d = d | 539 | safe_d = d |
@@ -568,7 +569,7 @@ def multi_finalize(fn, d): | |||
568 | d.setVar("BBEXTENDVARIANT", variantmap[name]) | 569 | d.setVar("BBEXTENDVARIANT", variantmap[name]) |
569 | else: | 570 | else: |
570 | d.setVar("PN", "%s-%s" % (pn, name)) | 571 | d.setVar("PN", "%s-%s" % (pn, name)) |
571 | bb.parse.BBHandler.inherit(extendedmap[name], fn, 0, d) | 572 | bb.parse.BBHandler.inherit_defer(extendedmap[name], fn, 0, d) |
572 | 573 | ||
573 | safe_d.setVar("BBCLASSEXTEND", extended) | 574 | safe_d.setVar("BBCLASSEXTEND", extended) |
574 | _create_variants(datastores, extendedmap.keys(), extendfunc, onlyfinalise) | 575 | _create_variants(datastores, extendedmap.keys(), extendfunc, onlyfinalise) |
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 4bdb11994f..008fec2308 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -42,12 +42,22 @@ def supports(fn, d): | |||
42 | """Return True if fn has a supported extension""" | 42 | """Return True if fn has a supported extension""" |
43 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] | 43 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] |
44 | 44 | ||
45 | def inherit_defer(expression, fn, lineno, d): | ||
46 | inherit = (expression, fn, lineno) | ||
47 | inherits = d.getVar('__BBDEFINHERITS', False) or [] | ||
48 | inherits.append(inherit) | ||
49 | d.setVar('__BBDEFINHERITS', inherits) | ||
50 | |||
45 | def inherit(files, fn, lineno, d, deferred=False): | 51 | def inherit(files, fn, lineno, d, deferred=False): |
46 | __inherit_cache = d.getVar('__inherit_cache', False) or [] | 52 | __inherit_cache = d.getVar('__inherit_cache', False) or [] |
47 | #if "${" in files and not deferred: | 53 | #if "${" in files and not deferred: |
48 | # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) | 54 | # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) |
49 | files = d.expand(files).split() | 55 | files = d.expand(files).split() |
50 | for file in files: | 56 | for file in files: |
57 | defer = (d.getVar("BB_DEFER_BBCLASSES") or "").split() | ||
58 | if not deferred and file in defer: | ||
59 | inherit_defer(file, fn, lineno, d) | ||
60 | continue | ||
51 | classtype = d.getVar("__bbclasstype", False) | 61 | classtype = d.getVar("__bbclasstype", False) |
52 | origfile = file | 62 | origfile = file |
53 | for t in ["classes-" + classtype, "classes"]: | 63 | for t in ["classes-" + classtype, "classes"]: |