data_smart.py: remove unnecessary ? from __expand_var_regexp__
PATCH 1/4 data_smart.py: remove unnecessary ? from __expand_var_regexp__
From: Chen Qi <[email protected]>
The non-greedy modifier suffix ? is not necessary here because } is not in the character set [a-zA-Z0-9\-_+./~:].
--- bitbake/lib/bb/data_smart.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
bitbake/lib/bb/data_smart.py +1 -1
@@ -31,7 +31,7 @@ logger = logging.getLogger("BitBake.Data") __setvar_keyword__ = [":append", ":prepend", ":remove"] __setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$') -__expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+?}") +__expand_var_regexp__ = re.compile(r"\${[a-zA-Z0-9\-_+./~:]+}") __expand_python_regexp__ = re.compile(r"\${@(?:{.*?}|.)+?}") __whitespace_split__ = re.compile(r'(\s)') __override_regexp__ = re.compile(r'[a-z0-9]+')
Signature · 1 line
2.25.1
PATCH 2/4 data_smart.py: fix indentation
From: Chen Qi <[email protected]>
Fix 8 spaces indentation to be 4 spaces.
--- bitbake/lib/bb/data_smart.py | 80 ++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 40 deletions(-)
bitbake/lib/bb/data_smart.py +40 -40
@@ -106,52 +106,52 @@ class VariableParse: self.contains = {} def var_sub(self, match): - key = match.group()[2:-1] - if self.varname and key: - if self.varname == key: - raise Exception("variable %s references itself!" % self.varname) - var = self.d.getVarFlag(key, "_content") - self.references.add(key) - if var is not None: - return var - else: - return match.group() + key = match.group()[2:-1] + if self.varname and key: + if self.varname == key: + raise Exception("variable %s references itself!" % self.varname) + var = self.d.getVarFlag(key, "_content") + self.references.add(key) + if var is not None: + return var + else: + return match.group() def python_sub(self, match): - if isinstance(match, str): - code = match - else: - code = match.group()[3:-1] + if isinstance(match, str): + code = match + else: + code = match.group()[3:-1] - # Do not run code that contains one or more unexpanded variables - # instead return the code with the characters we removed put back - if __expand_var_regexp__.findall(code): - return "${@" + code + "}" + # Do not run code that contains one or more unexpanded variables + # instead return the code with the characters we removed put back + if __expand_var_regexp__.findall(code): + return "${@" + code + "}" - if self.varname: - varname = 'Var <%s>' % self.varname - else: - varname = '<expansion>' - codeobj = compile(code.strip(), varname, "eval") - - parser = bb.codeparser.PythonParser(self.varname, logger) - parser.parse_python(code) - if self.varname: - vardeps = self.d.getVarFlag(self.varname, "vardeps") - if vardeps is None: - parser.log.flush() - else: + if self.varname: + varname = 'Var <%s>' % self.varname + else: + varname = '<expansion>' + codeobj = compile(code.strip(), varname, "eval") + + parser = bb.codeparser.PythonParser(self.varname, logger) + parser.parse_python(code) + if self.varname: + vardeps = self.d.getVarFlag(self.varname, "vardeps") + if vardeps is None: parser.log.flush() - self.references |= parser.references - self.execs |= parser.execs + else: + parser.log.flush() + self.references |= parser.references + self.execs |= parser.execs - for k in parser.contains: - if k not in self.contains: - self.contains[k] = parser.contains[k].copy() - else: - self.contains[k].update(parser.contains[k]) - value = utils.better_eval(codeobj, DataContext(self.d), {'d' : self.d}) - return str(value) + for k in parser.contains: + if k not in self.contains: + self.contains[k] = parser.contains[k].copy() + else: + self.contains[k].update(parser.contains[k]) + value = utils.better_eval(codeobj, DataContext(self.d), {'d' : self.d}) + return str(value) class DataContext(dict): excluded = set([i for i in dir(builtins) if not i.startswith('_')] + ['oe'])
Signature · 1 line
2.25.1
PATCH 3/4 data_smart.py: simple clean up
In reply to [email protected]From: Chen Qi <[email protected]>
When var matches __setvar_regexp__, which has the value as below,__setvar_regexp__ = re.compile(r'(?P<base>.*?)(?P<keyword>:append|:prepend|:remove)(:(?P<add>[^A-Z]*))?$') the keyword will not be __doc__ or __module__ and var will always
contain ":".
--- bitbake/lib/bb/data_smart.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
bitbake/lib/bb/data_smart.py +1 -4
@@ -580,12 +580,9 @@ class DataSmart(MutableMapping): else: loginfo['op'] = keyword self.varhistory.record(**loginfo) - # todo make sure keyword is not __doc__ or __module__ - # pay the cookie monster # more cookies for the cookie monster - if ':' in var: - self._setvar_update_overrides(base, **loginfo) + self._setvar_update_overrides(base, **loginfo) if base in self.overridevars: self._setvar_update_overridevars(var, value)
Signature · 1 line
2.25.1
PATCH 4/4 data_smart.py: clear expand_cache in _setvar_update_overridevars
In reply to [email protected]From: Chen Qi <[email protected]>
At the end of this function, self.overrides is cleared, which means we'll construct a new self.overrides after this call. And a new self.overrides will give out different expand_cache, so the old expand_cache should also be cleared to avoid any wrong value.
Currently, there's a problem revealed by recent recipe specific virtual provider patch. If we enable multilib and set "OVERRIDES:prepend" in local.conf, things don't work.
Here's the error message:
ERROR: Nothing PROVIDES 'lib32-gcc-cross-x86_64'
Below are reproduce steps:
1. Add in local.conf the following lines:
MACHINE ?= "qemux86-64"
require conf/multilib.conf
MULTILIBS ?= "multilib:lib32" DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32" OVERRIDES:prepend = "some-override:"
(Note that using :append and :remove also reproduces the issue.)
2. bitbake -n lib32-sysstat
(bitbake -n core-image-minimal also reproduces the issue)
The expandWithRefs calls getVar, which fills expand_cache. So when setting OVERRIDES:prepend, this will fill the expand_cache. When overridevars are updated, if we don't clear expand_cache, we'll retrieve wrong values.
Previously, things happened to work because there's a call to expand PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc, which in turn expands TARGET_VENDOR. Now what we expand is PREFERRED_PROVIDER_ virtual/cross-cc, so the problem is revealed.
--- bitbake/lib/bb/data_smart.py | 1 + 1 file changed, 1 insertion(+)
bitbake/lib/bb/data_smart.py +1 -0
@@ -635,6 +635,7 @@ class DataSmart(MutableMapping): nextnew.update(vardata.contains.keys()) new = nextnew self.overrides = None + self.expand_cache = {} def _setvar_update_overrides(self, var, **loginfo): # aka pay the cookie monster
Signature · 1 line
2.25.1
Re: [bitbake-devel][PATCH 4/4] data_smart.py: clear expand_cache in _setvar_update_overridevars
kindly ping
Quoted 61 lines · Chen Qi via lists.openembedded.org
From: Chen Qi <[email protected]>
At the end of this function, self.overrides is cleared, which means we'll construct a new self.overrides after this call. And a new self.overrides will give out different
expand_cache, so the oldexpand_cacheshould also be cleared to avoid any wrong value.Currently, there's a problem revealed by recent recipe specific virtual provider patch. If we enable multilib and set "OVERRIDES:prepend" in local.conf, things don't work.
Here's the error message:
ERROR: Nothing PROVIDES 'lib32-gcc-cross-x86_64'Below are reproduce steps:
1. Add in local.conf the following lines:
MACHINE ?= "qemux86-64"
requireconf/multilib.conf
MULTILIBS ?= "multilib:lib32" DEFAULTTUNE:virtclass-multilib-lib32 ?= "core2-32" OVERRIDES:prepend = "some-override:"
(Note that using :append and :remove also reproduces the issue.)
2. bitbake -n lib32-sysstat
(bitbake -n core-image-minimal also reproduces the issue)The expandWithRefs calls getVar, which fills
expand_cache. So when setting OVERRIDES:prepend, this will fill theexpand_cache. When overridevars are updated, if we don't clearexpand_cache, we'll retrieve wrong values.Previously, things happened to work because there's a call to expand PREFERRED_PROVIDER_virtual/${TARGET_PREFIX}gcc, which in turn expands
TARGET_VENDOR. Now what we expand isPREFERRED_PROVIDER_virtual/cross-cc, so the problem is revealed.Signed-off-by Chen Qi <[email protected]>--- bitbake/lib/bb/data_smart.py | 1 + 1 file changed, 1 insertion(+)bitbake/lib/bb/data_smart.py +1
-1@@ -635,6 +635,7 @@ class DataSmart(MutableMapping): nextnew.update(vardata.contains.keys()) new = nextnew self.overrides = None + self.expand_cache = {} def _setvar_update_overrides(self, var, **loginfo): # aka pay the cookie monster -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#17301): https://lists.openembedded.org/g/bitbake-devel/message/17301
Mute This Topic: https://lists.openembedded.org/mt/111373619/7304865
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Re: [bitbake-devel][PATCH 4/4] data_smart.py: clear expand_cache in _setvar_update_overridevars
Quoted 1 line · Chen Qi via lists.openembedded.org
kindly ping
Sorry, very briefly, 4/4 looks right, I merged 2/4, 3/4 removes a cookie monster reference which needs to stay somehow. I need to double check the rest of 3/4 but it probably is right after we switched override characters. 1/4 is probably fine if all the tests pass.
Cheers,
Richard