Search code examples
yoctobitbake

Inheritance clarification in bitbake


In bitbake, are inheritances transferable between include files when they are added with require keyword? Or do we need to reuse inherit keyword over and over again in each of the include files? I'm using bitbake to built images with Yocto.

exampleA.inc file

inherit exampleC

exampleB.inc file

require exampleA.inc

In that case, if I want exampleB.inc to be inherited from exampleC as well, do I need to specify it in this file?

Assume that the exampleC is a bbclass file.


Solution

  • TLDR: one inherit statement is enough.

    require and include just insert the content of the specified file at the current position in the recipe. This results in the same outcome, as if you had written the whole content of your .inc file into the recipe. Multiple layers of include / require should not change that. This means, that not the .inc file inherits from exanpleC, but rather the recipe, which requires said .inc file.

    I also ran some quick tests to confirm the theory, and it all seems to work.

    Do not be deterred by the BitBake documentation stating:

    [...] you can use the inherit directive to inherit the functionality of a class (.bbclass). BitBake only supports this directive when used within recipe and class files (i.e. .bb and .bbclass).

    This does not mean, that it does not work in .inc files, but rather that it will not work for configuration files.