Bug 14235

Summary: bbclass file name convention is not consistent wrt dash and underscore ( - _ )
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Randy MacLeod <randy.macleod>
Component: oe-core otherAssignee: Saul Wold <sgw>
Status: RESOLVED WORKSFORME QA Contact:
Severity: enhancement    
Priority: Medium CC: open.source, richard.purdie, sgw
Version: 3.3   
Target Milestone: 5.0   
Hardware: All   
OS: Multiple   
Whiteboard: NEWCOMER
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Yes (doc changes required)
Attachments:
Description Flags
Prototype script
none
test bbclass none

Description Randy MacLeod 2021-02-15 20:23:23 UTC
ls meta/classes/*_*
meta/classes/bin_package.bbclass            meta/classes/lib_package.bbclass         meta/classes/package_rpm.bbclass                meta/classes/rm_work.bbclass
...

$ ls meta/classes/*-*
meta/classes/autotools-brokensep.bbclass         meta/classes/go-mod.bbclass                     meta/classes/kernel-devicetree.bbclass    meta/classes/remove-libtool.bbclass
meta/classes/baremetal-image.bbclass             meta/classes/go-ptest.bbclass                   meta/classes/kernel-fitimage.bbclass      meta/classes/report-error.bbclass


Should we wrap the files witn an underscopre, issue a warning for a release or two and then make the evil _ files be an error at some point?
Comment 1 Randy MacLeod 2021-02-15 20:24:18 UTC
$ ls meta/classes/*-* | wc -l
68
$ ls meta/classes/*_* | wc -l
38

dashes win!
Comment 2 Randy MacLeod 2021-02-18 15:40:44 UTC
We should improve usability by:

1. Check export functions for dashes
2. Check for shell function names with dashes
3. Create a list of known classes and error if not in that list and contains a dash
4. We could do pattern matching on names that are not found.

Some of these things can be done by a NEWCOMER, Please comment on this bug if you are going to work on it.
Comment 3 Oleksandr Kravchuk 2021-02-20 20:21:13 UTC
I would happily work on this one. Is there a decision on how to handle the issue?
Comment 4 Randy MacLeod 2021-03-01 01:57:57 UTC
Oleksandr,
Richard wanted to do this incrementally and certainly not do a mass renaming.
Perhaps the best way to get started is to implement:

3. Create a list of known classes and error if not in that list and contains a dash
4. We could do pattern matching on names that are not found.

I think that 4. starts as a warning and becomes an error in a future release.
Comment 5 Randy MacLeod 2023-10-30 15:37:33 UTC
Build move to 5.0 -- ../Randy
Comment 6 Saul Wold 2024-01-09 01:39:19 UTC
Proof of concept scripts attached it uses tinfoil to scan the BBCLASS path and find bbclasses then searches for unknwon bbclasses that contains "_" in filename.

It also checks existing bbclasses for '-' in either addtask or EXPORT_FUNCTIONS directives.

/poky$ scripts/check-bbclasses
Loading cache: 100% |#################################################| Time: 0:00:00
Loaded 1927 entries from dependency cache.
Warning: BBClass file name contains '_': poky/meta/classes/bad_bbclass.bbclass
Warning: addtask contains '-': /poky/meta/classes/bad_bbclass.bbclass: addtask do-bad-task

Warning: EXPORT_FUNCTIONS contains '-': /poky/meta/classes/bad_bbclass.bbclass: EXPORT_FUNCTIONS do-bad-function
Comment 7 Saul Wold 2024-01-09 01:40:33 UTC
Created attachment 5003 [details]
Prototype script
Comment 8 Saul Wold 2024-01-09 01:41:15 UTC
Created attachment 5004 [details]
test bbclass
Comment 9 Saul Wold 2024-02-02 20:14:18 UTC
Due to the combination of '-' and shell function, we can not use '-' in bbclass file names, so instead it should be _, which just means more change over time.

ERROR: The classname dash-bbclass contains a dash character and is calling an sh function dash-bbclass_do_dash_shell_function using EXPORT_FUNCTIONS. Since a dash is illegal in sh function names, this cannot work, please rename the class or don't use EXPORT_FUNCTIONS.
ERROR: Unable to parse /home/swold/src/yocto/poky/bitbake/lib/bb/__init__.py
Comment 10 Randy MacLeod 2024-02-02 20:29:13 UTC
Saul,
Thanks for looking into this bug which aims at making the class file names follow a pattern.

I'm fine with picking "_" rather than "-" due to shell restrictions.
Comment 11 Richard Purdie 2024-02-09 14:57:09 UTC
As you've found, dashes give problems with shell and function names so underscores are preferred when used in class names. Users to tend to prefer dashes though.

I added the error to export functions a while back as a compromise around this issue, to ensure people know in the cases things really break.

I'm torn on all this to be honest, not sure what the best thing to do is.
Comment 12 Randy MacLeod 2024-05-23 15:06:50 UTC
Since we have limits to how consistent things can be we are closing this bug and if people are working on one of the files that can be renamed, they can do so.

-- YP bug review (Randy)
Comment 13 Randy MacLeod 2024-05-23 15:22:41 UTC
moving back to 5.0 since we aren't going to be doing a mass change.