diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2023-12-31 13:29:10 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-01-18 10:15:58 +0000 |
commit | c56fce9e5621bf4353eb112a2555be7aadb048e6 (patch) | |
tree | c2f6e9010fbeebe12ad7fe4557b5e94f59caa7d6 /bitbake/lib/bb/parse/parse_py | |
parent | 663f1805742ff6fb6955719d0ab7846a425debcf (diff) | |
download | poky-c56fce9e5621bf4353eb112a2555be7aadb048e6.tar.gz |
bitbake: ast/BBHandler: Add inherit_defer support
Add support for an inherit_defer statement which works as
inherit does but is only evaulated at the end of parsing.
This allows conditional expressions to be evaulated 'late' meaning changes
to PACKAGECONFIG from bbappends can be applied for example. This addresses
a usability/confusion issue users have with the current conditional
inherit mechanism since they don't realise the condition has to be
expanded immediately with the current model.
There is a commented out warning we could enable in future which
warns about the use of a conditional inherit that isn't deferred.
There is a behaviour difference in the placement of the inherit,
particularly around variables set using ?= which means wen swapping
from one to the other, caution must be used as values can change.
(Bitbake rev: 5c2e840eafeba1f0f754c226b87bfb674f7bea29)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/parse/parse_py')
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 4d5b45e1ef..cd1c998f8f 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -21,6 +21,7 @@ from .ConfHandler import include, init | |||
21 | 21 | ||
22 | __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>fakeroot(?=\s)))\s*)*(?P<func>[\w\.\-\+\{\}\$:]+)?\s*\(\s*\)\s*{$" ) | 22 | __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>fakeroot(?=\s)))\s*)*(?P<func>[\w\.\-\+\{\}\$:]+)?\s*\(\s*\)\s*{$" ) |
23 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) | 23 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) |
24 | __inherit_def_regexp__ = re.compile(r"inherit_defer\s+(.+)" ) | ||
24 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) | 25 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) |
25 | __addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") | 26 | __addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") |
26 | __deltask_regexp__ = re.compile(r"deltask\s+(.+)") | 27 | __deltask_regexp__ = re.compile(r"deltask\s+(.+)") |
@@ -40,8 +41,10 @@ def supports(fn, d): | |||
40 | """Return True if fn has a supported extension""" | 41 | """Return True if fn has a supported extension""" |
41 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] | 42 | return os.path.splitext(fn)[-1] in [".bb", ".bbclass", ".inc"] |
42 | 43 | ||
43 | def inherit(files, fn, lineno, d): | 44 | def inherit(files, fn, lineno, d, deferred=False): |
44 | __inherit_cache = d.getVar('__inherit_cache', False) or [] | 45 | __inherit_cache = d.getVar('__inherit_cache', False) or [] |
46 | #if "${" in files and not deferred: | ||
47 | # bb.warn("%s:%s has non deferred conditional inherit" % (fn, lineno)) | ||
45 | files = d.expand(files).split() | 48 | files = d.expand(files).split() |
46 | for file in files: | 49 | for file in files: |
47 | classtype = d.getVar("__bbclasstype", False) | 50 | classtype = d.getVar("__bbclasstype", False) |
@@ -265,6 +268,11 @@ def feeder(lineno, s, fn, root, statements, eof=False): | |||
265 | ast.handleInherit(statements, fn, lineno, m) | 268 | ast.handleInherit(statements, fn, lineno, m) |
266 | return | 269 | return |
267 | 270 | ||
271 | m = __inherit_def_regexp__.match(s) | ||
272 | if m: | ||
273 | ast.handleInheritDeferred(statements, fn, lineno, m) | ||
274 | return | ||
275 | |||
268 | return ConfHandler.feeder(lineno, s, fn, statements, conffile=False) | 276 | return ConfHandler.feeder(lineno, s, fn, statements, conffile=False) |
269 | 277 | ||
270 | # Add us to the handlers list | 278 | # Add us to the handlers list |