diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-07-18 12:59:15 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2021-07-30 14:38:30 +0100 |
commit | f2d2136dbb3730abb87699ce03dd54c27ebb7833 (patch) | |
tree | 27c407e9a955d6dec7b26d6402372b169a0b6da4 /bitbake | |
parent | 7d3fb188bfe4dc9aebe80286a65b357ed2ae8b8f (diff) | |
download | poky-f2d2136dbb3730abb87699ce03dd54c27ebb7833.tar.gz |
bitbake: data_smart/parse: Allow ':' characters in variable/function names
It is becomming increasingly clear we need to find a way to show what
is/is not an override in our syntax. We need to do this in a way which
is clear to users, readable and in a way we can transition to.
The most effective way I've found to this is to use the ":" charater
to directly replace "_" where an override is being specified. This
includes "append", "prepend" and "remove" which are effectively special
override directives.
This patch simply adds the character to the parser so bitbake accepts
the value but maps it back to "_" internally so there is no behaviour
change.
This change is simple enough it could potentially be backported to older
version of bitbake meaning layers using the new syntax/markup could
work with older releases. Even if other no other changes are accepted
at this time and we don't backport, it does set us on a path where at
some point in future we could
require a more explict syntax.
I've tested this patch by converting oe-core/meta-yocto to the new
syntax for overrides (9000+ changes) and then seeing that builds
continue to work with this patch.
(Bitbake rev: aa9f7b80cfdb1119050af469a07ebd949829026c)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/lib/bb/data_smart.py | 12 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/ast.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 2 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/ConfHandler.py | 2 |
4 files changed, 16 insertions, 2 deletions
diff --git a/bitbake/lib/bb/data_smart.py b/bitbake/lib/bb/data_smart.py index 2328c334ac..f48726a348 100644 --- a/bitbake/lib/bb/data_smart.py +++ b/bitbake/lib/bb/data_smart.py | |||
@@ -481,6 +481,7 @@ class DataSmart(MutableMapping): | |||
481 | 481 | ||
482 | def setVar(self, var, value, **loginfo): | 482 | def setVar(self, var, value, **loginfo): |
483 | #print("var=" + str(var) + " val=" + str(value)) | 483 | #print("var=" + str(var) + " val=" + str(value)) |
484 | var = var.replace(":", "_") | ||
484 | self.expand_cache = {} | 485 | self.expand_cache = {} |
485 | parsing=False | 486 | parsing=False |
486 | if 'parsing' in loginfo: | 487 | if 'parsing' in loginfo: |
@@ -589,6 +590,8 @@ class DataSmart(MutableMapping): | |||
589 | """ | 590 | """ |
590 | Rename the variable key to newkey | 591 | Rename the variable key to newkey |
591 | """ | 592 | """ |
593 | key = key.replace(":", "_") | ||
594 | newkey = newkey.replace(":", "_") | ||
592 | if key == newkey: | 595 | if key == newkey: |
593 | bb.warn("Calling renameVar with equivalent keys (%s) is invalid" % key) | 596 | bb.warn("Calling renameVar with equivalent keys (%s) is invalid" % key) |
594 | return | 597 | return |
@@ -637,6 +640,7 @@ class DataSmart(MutableMapping): | |||
637 | self.setVar(var + "_prepend", value, ignore=True, parsing=True) | 640 | self.setVar(var + "_prepend", value, ignore=True, parsing=True) |
638 | 641 | ||
639 | def delVar(self, var, **loginfo): | 642 | def delVar(self, var, **loginfo): |
643 | var = var.replace(":", "_") | ||
640 | self.expand_cache = {} | 644 | self.expand_cache = {} |
641 | 645 | ||
642 | loginfo['detail'] = "" | 646 | loginfo['detail'] = "" |
@@ -664,6 +668,7 @@ class DataSmart(MutableMapping): | |||
664 | override = None | 668 | override = None |
665 | 669 | ||
666 | def setVarFlag(self, var, flag, value, **loginfo): | 670 | def setVarFlag(self, var, flag, value, **loginfo): |
671 | var = var.replace(":", "_") | ||
667 | self.expand_cache = {} | 672 | self.expand_cache = {} |
668 | 673 | ||
669 | if 'op' not in loginfo: | 674 | if 'op' not in loginfo: |
@@ -687,6 +692,7 @@ class DataSmart(MutableMapping): | |||
687 | self.dict["__exportlist"]["_content"].add(var) | 692 | self.dict["__exportlist"]["_content"].add(var) |
688 | 693 | ||
689 | def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False, retparser=False): | 694 | def getVarFlag(self, var, flag, expand=True, noweakdefault=False, parsing=False, retparser=False): |
695 | var = var.replace(":", "_") | ||
690 | if flag == "_content": | 696 | if flag == "_content": |
691 | cachename = var | 697 | cachename = var |
692 | else: | 698 | else: |
@@ -814,6 +820,7 @@ class DataSmart(MutableMapping): | |||
814 | return value | 820 | return value |
815 | 821 | ||
816 | def delVarFlag(self, var, flag, **loginfo): | 822 | def delVarFlag(self, var, flag, **loginfo): |
823 | var = var.replace(":", "_") | ||
817 | self.expand_cache = {} | 824 | self.expand_cache = {} |
818 | 825 | ||
819 | local_var, _ = self._findVar(var) | 826 | local_var, _ = self._findVar(var) |
@@ -831,6 +838,7 @@ class DataSmart(MutableMapping): | |||
831 | del self.dict[var][flag] | 838 | del self.dict[var][flag] |
832 | 839 | ||
833 | def appendVarFlag(self, var, flag, value, **loginfo): | 840 | def appendVarFlag(self, var, flag, value, **loginfo): |
841 | var = var.replace(":", "_") | ||
834 | loginfo['op'] = 'append' | 842 | loginfo['op'] = 'append' |
835 | loginfo['flag'] = flag | 843 | loginfo['flag'] = flag |
836 | self.varhistory.record(**loginfo) | 844 | self.varhistory.record(**loginfo) |
@@ -838,6 +846,7 @@ class DataSmart(MutableMapping): | |||
838 | self.setVarFlag(var, flag, newvalue, ignore=True) | 846 | self.setVarFlag(var, flag, newvalue, ignore=True) |
839 | 847 | ||
840 | def prependVarFlag(self, var, flag, value, **loginfo): | 848 | def prependVarFlag(self, var, flag, value, **loginfo): |
849 | var = var.replace(":", "_") | ||
841 | loginfo['op'] = 'prepend' | 850 | loginfo['op'] = 'prepend' |
842 | loginfo['flag'] = flag | 851 | loginfo['flag'] = flag |
843 | self.varhistory.record(**loginfo) | 852 | self.varhistory.record(**loginfo) |
@@ -845,6 +854,7 @@ class DataSmart(MutableMapping): | |||
845 | self.setVarFlag(var, flag, newvalue, ignore=True) | 854 | self.setVarFlag(var, flag, newvalue, ignore=True) |
846 | 855 | ||
847 | def setVarFlags(self, var, flags, **loginfo): | 856 | def setVarFlags(self, var, flags, **loginfo): |
857 | var = var.replace(":", "_") | ||
848 | self.expand_cache = {} | 858 | self.expand_cache = {} |
849 | infer_caller_details(loginfo) | 859 | infer_caller_details(loginfo) |
850 | if not var in self.dict: | 860 | if not var in self.dict: |
@@ -859,6 +869,7 @@ class DataSmart(MutableMapping): | |||
859 | self.dict[var][i] = flags[i] | 869 | self.dict[var][i] = flags[i] |
860 | 870 | ||
861 | def getVarFlags(self, var, expand = False, internalflags=False): | 871 | def getVarFlags(self, var, expand = False, internalflags=False): |
872 | var = var.replace(":", "_") | ||
862 | local_var, _ = self._findVar(var) | 873 | local_var, _ = self._findVar(var) |
863 | flags = {} | 874 | flags = {} |
864 | 875 | ||
@@ -875,6 +886,7 @@ class DataSmart(MutableMapping): | |||
875 | 886 | ||
876 | 887 | ||
877 | def delVarFlags(self, var, **loginfo): | 888 | def delVarFlags(self, var, **loginfo): |
889 | var = var.replace(":", "_") | ||
878 | self.expand_cache = {} | 890 | self.expand_cache = {} |
879 | if not var in self.dict: | 891 | if not var in self.dict: |
880 | self._makeShadowCopy(var) | 892 | self._makeShadowCopy(var) |
diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index 0714296af2..c8802c0587 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py | |||
@@ -97,6 +97,7 @@ class DataNode(AstNode): | |||
97 | def eval(self, data): | 97 | def eval(self, data): |
98 | groupd = self.groupd | 98 | groupd = self.groupd |
99 | key = groupd["var"] | 99 | key = groupd["var"] |
100 | key = key.replace(":", "_") | ||
100 | loginfo = { | 101 | loginfo = { |
101 | 'variable': key, | 102 | 'variable': key, |
102 | 'file': self.filename, | 103 | 'file': self.filename, |
@@ -207,6 +208,7 @@ class ExportFuncsNode(AstNode): | |||
207 | def eval(self, data): | 208 | def eval(self, data): |
208 | 209 | ||
209 | for func in self.n: | 210 | for func in self.n: |
211 | func = func.replace(":", "_") | ||
210 | calledfunc = self.classname + "_" + func | 212 | calledfunc = self.classname + "_" + func |
211 | 213 | ||
212 | if data.getVar(func, False) and not data.getVarFlag(func, 'export_func', False): | 214 | if data.getVar(func, False) and not data.getVarFlag(func, 'export_func', False): |
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index ea34f3a327..12a78b6502 100644 --- a/bitbake/lib/bb/parse/parse_py/BBHandler.py +++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py | |||
@@ -22,7 +22,7 @@ from .ConfHandler import include, init | |||
22 | # For compatibility | 22 | # For compatibility |
23 | bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"]) | 23 | bb.deprecate_import(__name__, "bb.parse", ["vars_from_file"]) |
24 | 24 | ||
25 | __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>fakeroot(?=\s)))\s*)*(?P<func>[\w\.\-\+\{\}\$]+)?\s*\(\s*\)\s*{$" ) | 25 | __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>fakeroot(?=\s)))\s*)*(?P<func>[\w\.\-\+\{\}\$:]+)?\s*\(\s*\)\s*{$" ) |
26 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) | 26 | __inherit_regexp__ = re.compile(r"inherit\s+(.+)" ) |
27 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) | 27 | __export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) |
28 | __addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") | 28 | __addtask_regexp__ = re.compile(r"addtask\s+(?P<func>\w+)\s*((before\s*(?P<before>((.*(?=after))|(.*))))|(after\s*(?P<after>((.*(?=before))|(.*)))))*") |
diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index af64d3446e..a7e81bd6ad 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py | |||
@@ -20,7 +20,7 @@ from bb.parse import ParseError, resolve_file, ast, logger, handle | |||
20 | __config_regexp__ = re.compile( r""" | 20 | __config_regexp__ = re.compile( r""" |
21 | ^ | 21 | ^ |
22 | (?P<exp>export\s+)? | 22 | (?P<exp>export\s+)? |
23 | (?P<var>[a-zA-Z0-9\-_+.${}/~]+?) | 23 | (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?) |
24 | (\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])? | 24 | (\[(?P<flag>[a-zA-Z0-9\-_+.]+)\])? |
25 | 25 | ||
26 | \s* ( | 26 | \s* ( |