Yocto Inheritance Clarification Request

I recently raided the creation of Linux-based embedded systems, far from my usual embedded material, where I have complete control over everything.

As part of this, I am looking at the Yocto / bitbake / OpenEmbedded build system.

There is one thing that I come across and that is the concept of layers, so I am trying to understand how layers use / affect other layers.

From my understanding today, the .bb recipe file uses require to simply add another file, similar to C #include "myheader.h" , which usually looks local.

The A .bbappend in the "upper" layer will automatically include the base file, and then make changes to it, a sort of built-in require .

In contrast, the inherit keyword inherit for a .bbclass class .bbclass in much the same way that it finds .bb files and inherits all the data from it (sort of like #include <stdio.h> , which again usually looks in the system area ( a) ).

So, the first part of my question is: do I understand correctly? Or am I too simplistic?

The second part of my question then includes the use of BBEXTENDS in the light of my current understanding. If we already have the opportunity to extend the recipe with require , what is the purpose of listing the recipes in the BBEXTENDS variable?


(a) Yes, I know that both of them are completely dependent on the implementation in terms of where the headers come from, I'm just talking about their common use.

+5
source share
1 answer

The learning curve for Yocto is different from another building system, so I understand your confusion, but trust me, it's worth it. Your questions are related to BitBake, so I recommend the BitBake User Guide . Just make sure you read the same version as your poky version.

require is similar to include and can be compared with #include with C and C ++ just like you wrote. Although, in general, both of them should be used to add some extensions to the recipe (* .bb), which are common to some recipes (just - you can reuse it). For example: path definitions, custom tasks used by pairs of recipes. The overall goal is to make the recipe cleaner and separate some constants for reuse.

Very important thing -> difference between include and require (from the BitBake manual):

The include directive does not generate an error when a file cannot be found. Therefore, it is recommended that if it is expected that the file you include will exist, you should use require instead of include. In doing so, make sure that an error occurs if the file is not found.

The result: when you include the file in * .bb, and it was not found, BitBake will not cause an error while parsing this recipe. If you use require , an error will be raised. You must use the requirement when the specified file must exist, since it contains important variables / tasks that are necessary for processing.

In the case of *.bbappend - it is very powerful. A typical case is that you add some custom changes to the recipe from another level using *.bbappend , because (for example): you are not the custodian of the original recipe or modifications are used only in your project (then it should be located in your meta layer). But you can also bbappend recipe on the same layer. BitBake parses all the layers and then โ€œcreatesโ€ the output and executes it. Read more in the Run from BitBake User chapter .

The inherit mechanism can be used to inherit *.bbclass , where common tasks are defined for a specific purpose, so you do not need to write them yourself, for example: you use inhert cmake or inherit autotools for your recipe when it needs to provide output for sources that are built respectively CMake (and you have CMakeLists.txt installed) or autotools (Makefile.am, etc.). The class definitions provided by OpenEmbedded are under / meta / classes / if you are using the Yocto release with poky. You can check them, and you will see that, for example, autotools.bbclass defined (among others) the task: autotools_do_configure() , so you do not need to write it from scratch. However, you can override it in your recipe (simply by providing your own definition of this function). If the recipe cannot be changed, you can simply create a *.bbappend file and write your own do_configure() function, which will override the function from *.bbclass . Just like in OO languages โ€‹โ€‹like C ++ or Java.

+7
source

All Articles