Considering all freedom that yocto gives to the developer, I have a question. I would like to make this my_file.inc available only for recipes in one particular meta-layer. I know, that, for instance, using INHERIT keyword inside the local.conf will make my_class.bbclass file available globally for each recipe.
Is it a good practice to add this:
require my_file.inc
inside layer.conf? Or should I change my_file.inc to the my_file.bbclass, and, add INHERIT = "my_file.bbclass" to the layer.conf? Any other possibilities?
Even if it seems to work, neither of your approaches is technically completely correct. The key point is that all .conf
files are parsed first and everything they contain is globally visible throughout the whole build process. So if you add something through the layer.conf
file, itis not being pulled in through an unexpected place, it also is not being limited that layer only and might therefore cause breakage at other places.
While I do not have a really good and clean solution, maybe the following can help you:
You can make your custom recipes react on certain keywords in DISTRO_FEATURES
or MACHINE_FEATURES
. Then you can create a two-staged approach:
Add the desired keyword in local.conf
(or your MACHINE
, or DISTRO
, or whatever configuration)
Make the recipes react to it. If you need the mechanism in several places, then it might be useful to pour it into a .bbclass
that your layer brings along and that you pull in for the respective recipes.
This way the effect is properly contained.