Skip to contentSkip to conversation

bitbake: ConfHandler: Allow variable flag name with a single character

PATCH Superseded [email protected] 2 participants 3 messages Apr 11, 2023

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bitbake: ConfHandler: Allow variable flag name with a single character

From: Kai Kang <[email protected]>

Update regex pattern to allow variable flag name with a single character.

Regression tests have also been updated in bb.parse and bin/bitbake-selftest -k ParseTest has been successfully executed.

---
 bitbake/lib/bb/parse/parse_py/ConfHandler.py | 2 +-
 bitbake/lib/bb/tests/parse.py                | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
bitbake/lib/bb/parse/parse_py/ConfHandler.py +1 -1
index 05c627ec8b..0bfe357012 100644
@@ -21,7 +21,7 @@ __config_regexp__  = re.compile( r"""
     ^
     (?P<exp>export\s+)?
     (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?)
-    (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\])?
+    (\[(?P<flag>[a-zA-Z0-9\-_+.]([a-zA-Z0-9\-_+.@]+)?)\])?
 
     \s* (
         (?P<colon>:=) |
bitbake/lib/bb/tests/parse.py +2 -0
index d27c7c6f15..a3165d95bd 100644
@@ -222,6 +222,7 @@ VAR = " \\
     at_sign_in_var_flag = """
 A[[email protected]] = "nonet"
 B[[email protected]] = "ntb"
+C[f] = "flag"
 
 unset A[[email protected]]
 """
@@ -232,6 +233,7 @@ unset A[[email protected]]
         self.assertEqual(d.getVar("B"), None)
         self.assertEqual(d.getVarFlag("A","[email protected]"), None)
         self.assertEqual(d.getVarFlag("B","[email protected]"), "ntb")
+        self.assertEqual(d.getVarFlag("C","f"), "flag")
 
     def test_parse_invalid_at_sign_in_var_flag(self):
         invalid_at_sign = self.at_sign_in_var_flag.replace("B[f", "B[@f")
Signature · 1 line
2.17.1
#1 lore raw
Quoted 18 lines · Kai Kang

From: Kai Kang <[email protected]>

Update regex pattern to allow variable flag name with a single character.

Regression tests have also been updated in bb.parse and bin/bitbake-selftest -k ParseTest has been successfully executed.

---
 bitbake/lib/bb/parse/parse_py/ConfHandler.py | 2 +-
 bitbake/lib/bb/tests/parse.py                | 2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)
bitbake/lib/bb/parse/parse_py/ConfHandler.py +0 -0
index 05c627ec8b..0bfe357012 100644

bitbake/lib/bb/parse/parse_py/ConfHandler.py __config_regexp__ = re.compile( r""" · line 24

Quoted 5 lines
bitbake/lib/bb/parse/parse_py/ConfHandler.py +1 -1
@@ -21,7 +21,7 @@ __config_regexp__  = re.compile( r"""
     ^
     (?P<exp>export\s+)?
     (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?)
-    (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\])?
+    (\[(?P<flag>[a-zA-Z0-9\-_+.]([a-zA-Z0-9\-_+.@]+)?)\])?

It would be better to use the simpler expression (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]*)\])?

/Ola

Quoted 22 lines
bitbake/lib/bb/parse/parse_py/ConfHandler.py +0 -0
     \s* (
         (?P<colon>:=) |
bitbake/lib/bb/tests/parse.py +2 -0
index d27c7c6f15..a3165d95bd 100644
@@ -222,6 +222,7 @@ VAR = " \\
     at_sign_in_var_flag = """
 A[[email protected]] = "nonet"
 B[[email protected]] = "ntb"
+C[f] = "flag"
 
 unset A[[email protected]]
 """
@@ -232,6 +233,7 @@ unset A[[email protected]]
         self.assertEqual(d.getVar("B"), None)
         self.assertEqual(d.getVarFlag("A","[email protected]"), None)
         self.assertEqual(d.getVarFlag("B","[email protected]"), "ntb")
+        self.assertEqual(d.getVarFlag("C","f"), "flag")
 
     def test_parse_invalid_at_sign_in_var_flag(self):
         invalid_at_sign = self.at_sign_in_var_flag.replace("B[f", "B[@f")
author
#2 lore raw
Quoted 15 lines · Ola x Nilsson
Quoted 13 lines · Kai Kang

From: Kai Kang <[email protected]>

Update regex pattern to allow variable flag name with a single character.

Regression tests have also been updated in bb.parse and bin/bitbake-selftest -k ParseTest has been successfully executed.

---
  bitbake/lib/bb/parse/parse_py/ConfHandler.py | 2 +-
  bitbake/lib/bb/tests/parse.py                | 2 ++
  2 files changed, 3 insertions(+), 1 deletion(-)
Quoted 12 lines

bitbake/lib/bb/parse/parse_py/ConfHandler.py __config_regexp__ = re.compile( r""" · line 24

Quoted 10 lines
bitbake/lib/bb/parse/parse_py/ConfHandler.py +1 -1
index 05c627ec8b..0bfe357012 100644
@@ -21,7 +21,7 @@ __config_regexp__  = re.compile( r"""
      ^
      (?P<exp>export\s+)?
      (?P<var>[a-zA-Z0-9\-_+.${}/~:]+?)
-    (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\])?
+    (\[(?P<flag>[a-zA-Z0-9\-_+.]([a-zA-Z0-9\-_+.@]+)?)\])?

It would be better to use the simpler expression (\[(?P<flag>[a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]*)\])?

Oh, yes, it is better. Thanks and v2 will be sent.

Kai

Quoted 36 lines

/Ola

Quoted 15 lines
bitbake/lib/bb/parse/parse_py/ConfHandler.py +0 -0
      \s* (
          (?P<colon>:=) |
bitbake/lib/bb/tests/parse.py +1 -0
index d27c7c6f15..a3165d95bd 100644
@@ -222,6 +222,7 @@ VAR = " \\
      at_sign_in_var_flag = """
  A[[email protected]] = "nonet"
  B[[email protected]] = "ntb"
+C[f] = "flag"
 
  unset A[[email protected]]
  """

bitbake/lib/bb/tests/parse.py unset A[[email protected]] · line 239

Quoted 7 lines
bitbake/lib/bb/tests/parse.py +1 -0
@@ -232,6 +233,7 @@ unset A[[email protected]]
          self.assertEqual(d.getVar("B"), None)
          self.assertEqual(d.getVarFlag("A","[email protected]"), None)
          self.assertEqual(d.getVarFlag("B","[email protected]"), "ntb")
+        self.assertEqual(d.getVarFlag("C","f"), "flag")
 
      def test_parse_invalid_at_sign_in_var_flag(self):
          invalid_at_sign = self.at_sign_in_var_flag.replace("B[f", "B[@f")

-=-=-=-=-=-=-=-=-=-=-=-
Links: You receive all messages sent to this group.
View/Reply Online (#14690): https://lists.openembedded.org/g/bitbake-devel/message/14690
Mute This Topic: https://lists.openembedded.org/mt/98192343/3616933
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/bitbake-devel/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-

Signature · 2 lines
Kai Kang
Wind River Linux