summaryrefslogtreecommitdiffstats
path: root/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
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/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
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/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst116
1 files changed, 101 insertions, 15 deletions
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