Bug 15250 - bitbake not parsing "addtask binary_patch after do_unpack before do_deploy_deb# this is a comment" correctly
Summary: bitbake not parsing "addtask binary_patch after do_unpack before do_deploy_de...
Status: RESOLVED FIXED
Alias: None
Product: BitBake
Classification: Build System, Metadata & Runtime
Component: bitbake (show other bugs)
Version: unspecified
Hardware: x86 x86_64
: Medium normal
Target Milestone: 5.99
Assignee: Richard Purdie
QA Contact:
URL:
Whiteboard:
Depends on:
Blocks:
 
Reported: 2023-10-20 08:08 UTC by developerdong
Modified: 2024-09-03 10:54 UTC (History)
3 users (show)

See Also:
OS type for building Yocto: ---
Type of Regression: ---
Verified:
Documentation change: Don't know


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description developerdong 2023-10-20 08:08:24 UTC
Overview:

Firstly, there is a snippet of code to split the keyword 'before':
https://github.com/openembedded/bitbake/blob/5419a8473d6d4cd1d01537de68ad8d72cf5be0b2/lib/bb/build.py#L952

1. addtask binary_patch after do_unpack before do_deploy_deb

This code has no problem, because it is split into ['do_deploy_deb'].

2. addtask binary_patch after do_unpack before do_deploy_deb # this is a comment

This code is split into ['do_deploy_deb', '#', 'this', 'is', 'a', 'comment'].
Though I think the comment should not be in the split result, fortunately 'do_deploy_deb' is still a valid function what I want.

3. addtask binary_patch after do_unpack before do_deploy_deb# this is a comment

Unfortunately, this code is split into ['do_deploy_deb#', 'this', 'is', 'a', 'comment'], where 'do_deploy_deb#' is not the function I want.

I think the root cause is due to: https://github.com/openembedded/bitbake/blob/5419a8473d6d4cd1d01537de68ad8d72cf5be0b2/lib/bb/parse/parse_py/BBHandler.py#L25

bitbake use regexp to parse addtask, but does not ignore the comment.


Steps to Reproduce: 

1. In your recipe, write a line of code like "addtask A after B before C# comment". Please pay attention that there is no space between "C" and "#".
2. Build the target and check the dependencies.


Actual Results:

No dependency is added between A and C.


Expected Results:

There is a before dependency between A and C.


Build Date & Hardware:

Build 2023-10-09 on Debian 11


Additional Information: 

I don't know the whole procedure of how bitbake parse recipes.
- Maybe the bug is due to bitbake having no step to remove all the comments before parsing other syntaxes.
- Maybe changing the regular expression is one solution. (Other regular expressions may have the same bug.)
- Maybe it is acceptable to just write some hints in the documentation.
Comment 1 Randy MacLeod 2023-10-26 14:37:36 UTC
Good to fix but you can move the comment around to avoid the error - YP bug board review.