summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-06 20:30:37 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2024-08-13 15:47:55 +0100
commit60cba6a0735d8f8ef690fc2e5db9148066cb18f6 (patch)
treeaf8098d3afad4a8cd6e399a5bc2cbcfa67064ef0
parent292e17315e82aa7a63a93cc6e8671f495217f14e (diff)
downloadpoky-60cba6a0735d8f8ef690fc2e5db9148066cb18f6.tar.gz
bitbake: BBHandler: Handle comments in addtask/deltask
Technically our syntax would allow for comments after an addtask/deltask. Currently these get silently processed in various ways by the code which is bad. Tweak the regex to drop any comments and add test cases to ensure this continues to work in the future. [YOCTO #15250] (Bitbake rev: 64f8796e55a8826ffec0d76b993c8256713f67a3) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py4
-rw-r--r--bitbake/lib/bb/tests/parse.py10
2 files changed, 12 insertions, 2 deletions
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index c13e4b9755..c1653faeee 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -23,8 +23,8 @@ __func_start_regexp__ = re.compile(r"(((?P<py>python(?=(\s|\()))|(?P<fr>faker
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__inherit_def_regexp__ = re.compile(r"inherit_defer\s+(.+)" )
25__export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" ) 25__export_func_regexp__ = re.compile(r"EXPORT_FUNCTIONS\s+(.+)" )
26__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>(([^#\n]*(?=after))|([^#\n]*))))|(after\s*(?P<after>(([^#\n]*(?=before))|([^#\n]*)))))*(?P<comment>#.*|.*?)")
27__deltask_regexp__ = re.compile(r"deltask\s+(.+)") 27__deltask_regexp__ = re.compile(r"deltask\s+([^#\n]+)(?P<comment>#.*|.*?)")
28__addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" ) 28__addhandler_regexp__ = re.compile(r"addhandler\s+(.+)" )
29__def_regexp__ = re.compile(r"def\s+(\w+).*:" ) 29__def_regexp__ = re.compile(r"def\s+(\w+).*:" )
30__python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" ) 30__python_func_regexp__ = re.compile(r"(\s+.*)|(^$)|(^#)" )
diff --git a/bitbake/lib/bb/tests/parse.py b/bitbake/lib/bb/tests/parse.py
index 72d1962e7e..d076fcc208 100644
--- a/bitbake/lib/bb/tests/parse.py
+++ b/bitbake/lib/bb/tests/parse.py
@@ -179,6 +179,15 @@ python () {
179addtask do_patch after do_foo after do_unpack before do_configure before do_compile 179addtask do_patch after do_foo after do_unpack before do_configure before do_compile
180addtask do_fetch do_patch 180addtask do_fetch do_patch
181 181
182addtask do_myplaintask
183addtask do_myplaintask2
184deltask do_myplaintask2
185addtask do_mytask# comment
186addtask do_mytask2 # comment2
187addtask do_mytask3
188deltask do_mytask3# comment
189deltask do_mytask4 # comment2
190
182MYVAR = "do_patch" 191MYVAR = "do_patch"
183EMPTYVAR = "" 192EMPTYVAR = ""
184deltask do_fetch ${MYVAR} ${EMPTYVAR} 193deltask do_fetch ${MYVAR} ${EMPTYVAR}
@@ -195,6 +204,7 @@ deltask ${EMPTYVAR}
195 self.assertTrue("addtask contained multiple 'before' keywords" in output) 204 self.assertTrue("addtask contained multiple 'before' keywords" in output)
196 self.assertTrue("addtask contained multiple 'after' keywords" in output) 205 self.assertTrue("addtask contained multiple 'after' keywords" in output)
197 self.assertTrue('addtask ignored: " do_patch"' in output) 206 self.assertTrue('addtask ignored: " do_patch"' in output)
207 self.assertEqual(['do_myplaintask', 'do_mytask', 'do_mytask2'], d.getVar("__BBTASKS"))
198 #self.assertTrue('dependent task do_foo for do_patch does not exist' in output) 208 #self.assertTrue('dependent task do_foo for do_patch does not exist' in output)
199 209
200 broken_multiline_comment = """ 210 broken_multiline_comment = """