Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to extend BitBake class

Tags:

yocto

bitbake

I'm building an image with Yocto, and need to patch a BitBake class in the upstream tree. I do not want to modify the upstream sources and would prefer to add the modification to a local layer.

For a BitBake recipe, I'd use a .bbappend file. What should be used for a class?

like image 746
Konstantin Shemyak Avatar asked Jun 09 '26 03:06

Konstantin Shemyak


2 Answers

Create classes folder in your meta layer and create a new class, e.g. myclass.bbclass. Inherit original class with inherit original-bitbake-CLASS and add whatever functionality you need.

Then use the new bbclass instead of the original.

like image 165
Oleksandr Kravchuk Avatar answered Jun 11 '26 22:06

Oleksandr Kravchuk


@lukaszgard method works except for one minor issue. BBFILE_PRIORITY does not provide override capability for bbclass and conf files, it only works for recipes (.bb). This is based on a section of the Yocto manual, Prioritizing Your Layer where it says

Note: It is possible for a recipe with a lower version number PV in a layer that has a higher priority to take precedence. Also, the layer priority does not currently affect the precedence order of .conf or .bbclass files. Future versions of BitBake might address this.

A method I found that works is to create a bblayer, create and apply changes of the required bbclass and then in /build/conf/bblayers.conf, place the created bblayer above the layer that you are trying to override.

This is based on another section of the Yocto manual which says

Note: During a build, the OpenEmbedded build system looks in the layers from the top of the list down to the bottom in that order.

An example:

BBLAYERS ?= " \
  ${TOPDIR}/../layers/<layer with new bbclass> \
  ${TOPDIR}/../layers/<layer with old bbclass> \
"
like image 21
Sheffield Dong Avatar answered Jun 11 '26 23:06

Sheffield Dong