* Comments inside bb files are allowed using the '#' character at the beginning of a line.

* Comments inside bb files are allowed using the '#' character at the beginning of a line.

−

* Use either tabs '''or''' spaces for indentation, but don't mix the two in the same file

+

* Use spaces for indentation as developers tends to use different amount of spaces per one tab.

−

* The correct spacing for a variable is FOO = "BAR".

+

* Indentation of multiline variables such as SRC_URI is desireable.

* Indentation of multiline variables such as SRC_URI is desireable.

+

* Python functions should be four space indented, no tabs.

+

* Shell functions are usually tab character indented.

+

+

= Style Checking tools =

+

+

Please run ./contrib/oe-stylize.py on your recipes before submitting them.

= Style Guidelines =

= Style Guidelines =

* Put the ''inherit'' declaration after the initial variables are set up and before any custom ''do_'' routines. This is flexible as ordering is often important.

* Put the ''inherit'' declaration after the initial variables are set up and before any custom ''do_'' routines. This is flexible as ordering is often important.

−

* If you define custom ''do_'' routines, keep them in the order of the tasks being executed, that is:

* If you define custom ''do_'' routines, keep them in the order of the tasks being executed, that is:

** do_fetch

** do_fetch

Line 23:

Line 28:

** do_compile

** do_compile

** do_install

** do_install

+

** do_populate_sysroot

** do_package

** do_package

−

** do_stage

* Don't use ''cp'' to put files into staging or destination directories, use ''install'' instead.

* Don't use ''cp'' to put files into staging or destination directories, use ''install'' instead.

Line 54:

Line 59:

** PACKAGES

** PACKAGES

** FILES

** FILES

+

+

* Package related variables for a given package are often grouped together for clarity.

= Example Recipe =

= Example Recipe =

Line 66:

Line 73:

DEPENDS = "libsm libx11 libxext libxaw"

DEPENDS = "libsm libx11 libxext libxaw"

RDEPENDS = "shared-mime-info"

RDEPENDS = "shared-mime-info"

−

RRECOMMENTS = "ctags"

+

RRECOMMENDS = "ctags"

RCONFLICTS = "xcv2"

RCONFLICTS = "xcv2"

SRCDATE = "20060815"

SRCDATE = "20060815"

Line 93:

Line 100:

</pre>

</pre>

+

= PR variables with recipes that use INC files =

+

When recipe include files are used, the PR handling gets kind of messy. Its a pain to have to audit the PR in all the dependent recipes when you change something in an INC file. We usually use the following solution:

+

+

<pre>

+

recipe: PR = "${INC_PR}.1"

+

+

inc file: INC_PR = "r1"

+

</pre>

+

+

When converting existing recipes to use INC_PR, set the initial INC_PR to the maximum of the current PRs.

[[Category:Policy]]

[[Category:Policy]]

+

+

Also see https://wiki.yoctoproject.org/wiki/Recipe_%26_Patch_Style_Guide

PR variables with recipes that use INC files

When recipe include files are used, the PR handling gets kind of messy. Its a pain to have to audit the PR in all the dependent recipes when you change something in an INC file. We usually use the following solution:

recipe: PR = "${INC_PR}.1"
inc file: INC_PR = "r1"

When converting existing recipes to use INC_PR, set the initial INC_PR to the maximum of the current PRs.