summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorAntonin Godard <antonin.godard@bootlin.com>2025-09-18 14:16:25 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2025-09-24 00:01:44 +0100
commitae290dd4024e6b41954539c6f9fca4f088ec37b6 (patch)
tree7f25f66395d163b09aa03446a60e089ddd3204a2 /bitbake
parent44029f9fb590b7f15abbea94ce40343947d11047 (diff)
downloadpoky-ae290dd4024e6b41954539c6f9fca4f088ec37b6.tar.gz
bitbake: doc: extend classes and include/require documentation
The current documentation is lacking details on the different kinds of directories for putting classes as well as the order in which BitBake includes files (classes or include files). This patch does the following changes: - Mention the missing classes-recipe and classes-global when applicable. - Add a Class Types section detailed the three different directories for putting classes. - Move the existing section on locating classes/include files below the documentation on the different directives (include/require/inherit). - Extend the documentation on locating files with include/require and inherit to give proper examples, hopefully demystifying this mechanism a bit. [YOCTO #15724] (Bitbake rev: 7bd36f6c6d33211bb2a6b6fc6d40bdbd83b8b7c3) Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst10
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst34
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst116
3 files changed, 131 insertions, 29 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst
index d58fbb32ea..d407f59c0d 100644
--- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst
@@ -64,11 +64,11 @@ data itself is of various types:
64 together. 64 together.
65 65
66The ``layer.conf`` files are used to construct key variables such as 66The ``layer.conf`` files are used to construct key variables such as
67:term:`BBPATH` and :term:`BBFILES`. 67:term:`BBPATH` and :term:`BBFILES`. :term:`BBPATH` is used to search for
68:term:`BBPATH` is used to search for configuration and class files under the 68configuration files under the ``conf`` directory and class files under the
69``conf`` and ``classes`` directories, respectively. :term:`BBFILES` is used 69``classes-global``, ``classes-recipe`` and ``classes`` directories.
70to locate both recipe and recipe append files (``.bb`` and 70:term:`BBFILES` is used to locate both recipe and recipe append files (``.bb``
71``.bbappend``). If there is no ``bblayers.conf`` file, it is assumed the 71and ``.bbappend``). If there is no ``bblayers.conf`` file, it is assumed the
72user has set the :term:`BBPATH` and :term:`BBFILES` directly in the environment. 72user has set the :term:`BBPATH` and :term:`BBFILES` directly in the environment.
73 73
74Next, the ``bitbake.conf`` file is located using the :term:`BBPATH` variable 74Next, the ``bitbake.conf`` file is located using the :term:`BBPATH` variable
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
index d941e212bf..9837b009ea 100644
--- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
@@ -206,17 +206,33 @@ installing (empty by default) and packaging (empty by default). These
206tasks are often overridden or extended by other classes added during the 206tasks are often overridden or extended by other classes added during the
207project development process. 207project development process.
208 208
209.. note:: 209Class Types
210~~~~~~~~~~~
211
212BitBake supports class files installed in three different directories:
213
214- ``classes-global/``: these classes must be inherited globally through the
215 :term:`INHERIT` variable in a :ref:`configuration file
216 <bitbake-user-manual/bitbake-user-manual-intro:Configuration Files>`. These
217 classes are included for every recipe being built. For example, you would use
218 the global class named ``myclass`` like so::
219
220 INHERIT += "myclass"
221
222- ``classes-recipe/``: these classes must be inherited from a recipe using the
223 :ref:`inherit <ref-bitbake-user-manual-metadata-inherit>` directive. They do
224 not support being inherited globally. For example, you would use the recipe
225 class named ``myclass`` like so::
226
227 inherit myclass
210 228
211 While BitBake comes with just the one ``base.bbclass`` file in the 229- ``classes/``: this final directory is meant for classes that can be used in
212 ``classes`` directory, it supports class files also being installed 230 the two contexts explain above. In other words, they can be inherit either
213 in related directories ``classes-global`` and ``classes-recipe`` and 231 globally or in a recipe.
214 will automatically search all three directories for a selected class
215 file.
216 232
217 This means that, in this documentation, when you see a reference to 233For details on how BitBake locates class files, see the
218 class files being in the ``classes`` directory, you can interpret that 234:ref:`bitbake-user-manual/bitbake-user-manual-metadata:Locating Class Files`
219 as meaning in any one of the above three directories. 235section of the Bitbake User Manual.
220 236
221Layers 237Layers
222------ 238------
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
index 9d4f426bf7..4dadf0bc7b 100644
--- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
@@ -758,21 +758,6 @@ directives. There is also a higher-level abstraction called
758``configuration fragments`` that is enabled with ``addfragments`` 758``configuration fragments`` that is enabled with ``addfragments``
759directive. 759directive.
760 760
761Locating Include and Class Files
762--------------------------------
763
764BitBake uses the :term:`BBPATH` variable to locate
765needed include and class files. Additionally, BitBake searches the
766current directory for ``include`` and ``require`` directives.
767
768.. note::
769
770 The BBPATH variable is analogous to the environment variable PATH .
771
772In order for include and class files to be found by BitBake, they need
773to be located in a "classes" subdirectory that can be found in
774:term:`BBPATH`.
775
776.. _ref-bitbake-user-manual-metadata-inherit: 761.. _ref-bitbake-user-manual-metadata-inherit:
777 762
778``inherit`` Directive 763``inherit`` Directive
@@ -874,6 +859,8 @@ becomes a no-op.
874See also :term:`BB_DEFER_BBCLASSES` for automatically promoting classes 859See also :term:`BB_DEFER_BBCLASSES` for automatically promoting classes
875``inherit`` calls to ``inherit_defer``. 860``inherit`` calls to ``inherit_defer``.
876 861
862.. _ref-include-directive:
863
877``include`` Directive 864``include`` Directive
878--------------------- 865---------------------
879 866
@@ -908,6 +895,8 @@ if the file cannot be found.
908 If you need to include all matching files, you need to use the 895 If you need to include all matching files, you need to use the
909 ``include_all`` directive, explained below. 896 ``include_all`` directive, explained below.
910 897
898.. _ref-include-all-directive:
899
911``include_all`` Directive 900``include_all`` Directive
912------------------------- 901-------------------------
913 902
@@ -1062,6 +1051,103 @@ bitbake will treat that as direct value assignment in its configuration::
1062 1051
1063 SOMEVARIABLE = "somevalue" 1052 SOMEVARIABLE = "somevalue"
1064 1053
1054Locating Include Files
1055----------------------
1056
1057BitBake uses the :term:`BBPATH` variable to locate needed include files.
1058Additionally, BitBake searches the current directory for :ref:`include
1059<ref-include-directive>` and :ref:`require <require-inclusion>` directives.
1060
1061.. note::
1062
1063 The BBPATH variable is analogous to the environment variable PATH .
1064
1065For these two directives, BitBake includes the first file it finds.
1066
1067.. note::
1068
1069 It is also possible to include *all* occurences of a file with the same name
1070 with the :ref:`include_all <ref-include-all-directive>` directive.
1071
1072Let's consider the following statement called from a recipe file located in
1073``/layers/meta-custom2/recipes-example/example_0.1.bb``::
1074
1075 require myfile.inc
1076
1077Where ``myfile.inc`` is located in ``/layers/meta-custom2/recipes-example/``.
1078
1079And let's assume that the value of :term:`BBPATH` is
1080``/layers/meta-custom1:/layers/meta-custom2``. Then BitBake will try to find
1081``myfile.inc`` in this order::
1082
1083 /layers/meta-custom2/recipes-example/example/myfile.inc
1084 /layers/meta-custom1/myfile.inc
1085 /layers/meta-custom2/myfile.inc
1086
1087In this case the first path of the list matches and BitBake includes this file
1088in ``example_0.1.bb``.
1089
1090Another common example would be::
1091
1092 require recipes-other/other/otherfile.inc
1093
1094Where ``otherfile.inc`` is located in
1095``/layers/meta-custom1/recipes-other/other/``.
1096
1097In this case, the following paths would be searched::
1098
1099 /layers/meta-custom2/recipes-example/example/recipes-other/other/otherfile.inc
1100 /layers/meta-custom1/recipes-other/other/otherfile.inc
1101 /layers/meta-custom2/recipes-other/other/otherfile.inc
1102
1103This time, the second item of this list would be matched.
1104
1105.. note::
1106
1107 In the above examples, the exact same search order applies for the
1108 :ref:`include <ref-include-directive>` directive.
1109
1110Locating Class Files
1111--------------------
1112
1113Like include files, class files are located using the :term:`BBPATH` variable.
1114The classes can be included in the ``classes-recipe``, ``classes-global`` and
1115``classes`` directories, as explained in the
1116:ref:`bitbake-user-manual/bitbake-user-manual-intro:Class types` section of the
1117Bitbake User Manual. Like for the :ref:`include <ref-include-directive>` and
1118:ref:`require <require-inclusion>` directives, BitBake stops and inherits the
1119first class that it finds.
1120
1121For classes inherited with the :ref:`inherit
1122<ref-bitbake-user-manual-metadata-inherit>` directive, BitBake will try to
1123locate the class under each ``classes-recipe`` directory for each path in
1124:term:`BBPATH`, and then do the same for each ``classes`` directory for each
1125path in :term:`BBPATH`.
1126
1127For example, if the value :term:`BBPATH` is
1128``/layers/meta-custom1:/layers/meta-custom2`` then the ``hello`` class
1129would be searched in this order::
1130
1131 /layers/meta-custom1/classes-recipe/hello.bbclass
1132 /layers/meta-custom2/classes-recipe/hello.bbclass
1133 /layers/meta-custom1/classes/hello.bbclass
1134 /layers/meta-custom2/classes/hello.bbclass
1135
1136.. note::
1137
1138 Note that the order of the list above does not depend on where the class in
1139 inherited from.
1140
1141Likewise, for classes inherited with the :term:`INHERIT` variable, the
1142``classes-global`` directory is searched first, and the ``classes`` directory is
1143searched second. Taking the above example, this would result in the following
1144list::
1145
1146 /layers/meta-custom1/classes-global/hello.bbclass
1147 /layers/meta-custom2/classes-global/hello.bbclass
1148 /layers/meta-custom1/classes/hello.bbclass
1149 /layers/meta-custom2/classes/hello.bbclass
1150
1065Functions 1151Functions
1066========= 1152=========
1067 1153