diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-08-06 20:30:37 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-08-13 15:47:55 +0100 |
commit | 60cba6a0735d8f8ef690fc2e5db9148066cb18f6 (patch) | |
tree | af8098d3afad4a8cd6e399a5bc2cbcfa67064ef0 | |
parent | 292e17315e82aa7a63a93cc6e8671f495217f14e (diff) | |
download | poky-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.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/tests/parse.py | 10 |
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 () { | |||
179 | addtask do_patch after do_foo after do_unpack before do_configure before do_compile | 179 | addtask do_patch after do_foo after do_unpack before do_configure before do_compile |
180 | addtask do_fetch do_patch | 180 | addtask do_fetch do_patch |
181 | 181 | ||
182 | addtask do_myplaintask | ||
183 | addtask do_myplaintask2 | ||
184 | deltask do_myplaintask2 | ||
185 | addtask do_mytask# comment | ||
186 | addtask do_mytask2 # comment2 | ||
187 | addtask do_mytask3 | ||
188 | deltask do_mytask3# comment | ||
189 | deltask do_mytask4 # comment2 | ||
190 | |||
182 | MYVAR = "do_patch" | 191 | MYVAR = "do_patch" |
183 | EMPTYVAR = "" | 192 | EMPTYVAR = "" |
184 | deltask do_fetch ${MYVAR} ${EMPTYVAR} | 193 | deltask 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 = """ |