[OE-core] Yocto style guide change proposal

Martin Jansa martin.jansa at gmail.com
Fri Jul 20 09:32:08 UTC 2012


in "PLEASE READ: Major change landing shortly (python whitespace)"

RP said:
It's become clear we have a horrible mixture of whitespace (tabs and
space) in python functions.

That was resolved in following patches for bitbake, oe-core and other
layers.

Now we have horrible mixture of whitespaces (tabs and space) only in 
recipe files, because yocto style guide recommends tabs in shell
functions. So if recipe has e.g. do_install_append as well as
populate_packages_prepend (not so uncommon combination as tabs fixing
patches show), then according to yocto style guide it should look like
this:

do_install_append() {
	foo
}
python populate_packages_prepend () {
    libdir = bb.data.expand('${libdir}', d)
    do_split_packages(d, libdir, '^lib(.*)\.so\.*', 'lib%s', 'ORC %s library', extra_depends='', allow_links=True)
}

especially with default tab width 8 spaces it's ugly and because it
is inconsistent, many devs used spaces in shell functions too. Now when
someone accidentaly use tab also in python function it will show warning
or fail to parse. Some devs are using mix of tabs and spaces even on the
same line (e.g. to indent SRC_URI multiline entries).

Maybe this inconsistence in recipe files is because yocto style guide is
harder to find then openembedded style guide..

First google hit for "openembedded style guide":
http://www.openembedded.org/wiki/Styleguide

says about tabs only this:
- Use spaces for indentation as developers tends to use different amount
  of spaces per one tab.

So only in yocto wiki there are 2 more bullets after that
https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide
- Use spaces for indentation as developers tends to use different amount
  of spaces per one tab.
- Shell functions should use tabs
- Python functions should use spaces (4 spaces per indent).

And yocto style guide is not in first 5 pages of result when searching
for "openembedded style guide".

If we change the style guild to use 4 spaces per indent also for shell
functions then we can easily update bitbake/contrib/vim to highlight
tabs, so that every tab would be easily spotted in recipe/bbclass.

FWIW: I've prepared patch for whole meta-smartphone to unify that and
I've sent RFC for few bbclasses in meta-oe too.

Cheers,

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa at gmail.com
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://lists.openembedded.org/pipermail/openembedded-core/attachments/20120720/20301966/attachment-0002.sig>


More information about the Openembedded-core mailing list