From: Antonin Godard <antonin.godard@bootlin.com>
To: docs@lists.yoctoproject.org
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Antonin Godard <antonin.godard@bootlin.com>
Subject: [PATCH 10/18] dev-manual/layers.rst: refresh after layer configuration format changes
Date: Wed, 02 Dec 2026 15:55:45 +0100 [thread overview]
Message-ID: <20261202-layer-conf-changes-v1-10-da34d4c770c6@bootlin.com> (raw)
In-Reply-To: <20261202-layer-conf-changes-v1-0-da34d4c770c6@bootlin.com>
Rework the layers development manual document to reflect the new layer
configuration formation. This removes all the details about the various
BBFILE* variables that were removed and instead links to the layers
reference manual document we now have. Otherwise the rest of this patch
are added links or rewordings.
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
documentation/dev-manual/layers.rst | 238 ++++++------------------------------
1 file changed, 37 insertions(+), 201 deletions(-)
diff --git a/documentation/dev-manual/layers.rst b/documentation/dev-manual/layers.rst
index cfe476624..b4a8571ac 100644
--- a/documentation/dev-manual/layers.rst
+++ b/documentation/dev-manual/layers.rst
@@ -9,7 +9,10 @@ Layers allow you to isolate different types of customizations from each
other. For introductory information on the Yocto Project Layer Model,
see the
":ref:`overview-manual/yp-intro:the yocto project layer model`"
-section in the Yocto Project Overview and Concepts Manual.
+section in the Yocto Project Overview and Concepts Manual. For reference
+documentation on layers, see the :doc:`/ref-manual/layers` section. This
+document shows how to create and manipulate layers within the
+:term:`OpenEmbedded Build System`.
Note well that to properly call the ``bitbake-layers`` command explained
below, you must first
@@ -83,58 +86,12 @@ Follow these general steps to create your layer without using tools:
By default, the ``bitbake-layers create-layer`` command creates a layer
with the following:
- - A ``conf/layer.conf`` configuration file with default definitions.
-
- Here is an explanation of the typical content of the layer configuration file:
-
- - :term:`BBPATH`: Adds the layer's root directory to BitBake's search
- path. Through the use of the :term:`BBPATH` variable, BitBake locates
- class files (``.bbclass``), configuration files, and files that are
- included with ``include`` and ``require`` statements. For these cases,
- BitBake uses the first file that matches the name found in
- :term:`BBPATH`. This is similar to the way the ``PATH`` variable is
- used for binaries. It is recommended, therefore, that you use unique
- class and configuration filenames in your custom layer.
-
- See the :ref:`bitbake:bitbake-user-manual/bitbake-user-manual-metadata:Locating Include
- Files` section of the BitBake User Manual for more details on how
- files are included with :term:`BitBake`.
-
- - :term:`BBFILES`: Defines the location for all recipes in the layer.
-
- - :term:`BBFILE_COLLECTIONS`: Establishes the current layer through a
- unique identifier that is used throughout the :term:`OpenEmbedded Build
- System` to refer to the layer. In this example, the identifier
- "yoctobsp" is the representation for the container layer named
- "meta-yocto-bsp".
-
- This name is used by other layers when specifying the layer
- dependencies via the :term:`LAYERDEPENDS` variable.
-
- - :term:`BBFILE_PATTERN`: Expands immediately during parsing to provide
- the directory of the layer.
-
- - :term:`BBFILE_PRIORITY`: Establishes a priority to use for recipes in
- the layer when the :term:`OpenEmbedded Build System` finds recipes of
- the same name in different layers.
-
- - :term:`LAYERVERSION`: Establishes a version number for the layer. You
- can use this version number to specify this exact version of the layer
- as a dependency when using the :term:`LAYERDEPENDS` variable.
-
- - :term:`LAYERDEPENDS`: Lists all layers on which this layer depends (if
- any). It uses the layer names specified by the
- :term:`BBFILE_COLLECTIONS` variable.
-
- - :term:`LAYERSERIES_COMPAT`: Lists the :yocto_home:`Yocto Project
- release </development/releases/>` codenames (in lowercase) this layer is
- compatible with. For example: "&DISTRO_NAME_NO_CAP;".
-
- This variable is a good way to indicate if a particular layer is
- current.
+ - A ``conf/layer.conf`` configuration file with default definitions. See the
+ :ref:`structure-conf-layer.conf` section for reference documentation on
+ this file.
- A ``recipes-example`` subdirectory that itself contains a
- subdirectory named ``example``, which contains an ``example.bb``
+ subdirectory named ``example``, which contains an ``example_0.1.bb``
recipe file.
- A ``COPYING.MIT``, which is the license statement for the layer. The
@@ -144,11 +101,7 @@ Follow these general steps to create your layer without using tools:
- A ``README`` file, which is a file describing the contents of your
new layer.
-
- If you want to set the priority of the layer to other than the default value
- of "6", you can either use the ``--priority`` option or you can edit the
- :term:`BBFILE_PRIORITY` value in the ``conf/layer.conf`` after the script
- creates it. Furthermore, if you want to give the example recipe file some
+ If you want to give the example recipe file some
name or version other than the defaults, you can use the ``--example-recipe-name``
and/or ``--example-recipe-version`` options.
@@ -156,18 +109,23 @@ Follow these general steps to create your layer without using tools:
works is to experiment with the script. You can also read the usage
information by running ``bitbake-layers create-layer --help``.
-#. *Add Content:* Depending on the type of layer, add the content. If
- the layer adds support for a machine, add the machine configuration
- in a ``conf/machine/`` file within the layer. If the layer adds
- distro policy, add the distro configuration in a ``conf/distro/``
- file within the layer. If the layer introduces new recipes, put the
- recipes you need in ``recipes-*`` subdirectories within the layer.
+#. *Add Content:* Depending on the type of layer, add the content:
+
+ - If the layer adds support for a machine, add the machine configuration in
+ a ``conf/machine/`` file within the layer. See the :doc:`/bsp-manual/index`
+ section for more information.
+
+ - If the layer adds distro policy, add the distro configuration in a
+ ``conf/distro/`` file within the layer. See the
+ :doc:`/dev-manual/custom-distribution` section for more information.
+
+ - If the layer introduces new recipes, put the recipes you need in
+ ``recipes-*`` subdirectories within the layer.
.. note::
For an explanation of layer hierarchy that is compliant with the
- Yocto Project, see the ":ref:`bsp-manual/bsp:example filesystem layout`"
- section in the Yocto Project Board Support Package (BSP) Developer's Guide.
+ Yocto Project, see the :doc:`/ref-manual/layers` section.
#. *Optionally Test for Compatibility:* If you want permission to use
the Yocto Project Compatibility logo with your layer or application
@@ -185,11 +143,11 @@ following list:
- *Avoid "Overlaying" Entire Recipes from Other Layers in Your
Configuration:* In other words, do not copy an entire recipe into
- your layer and then modify it. Rather, use an append file
+ your layer and then modify it. Rather, use an :term:`append file <Append Files>`
(``.bbappend``) to override only those parts of the original recipe
you need to modify.
-- *Avoid Duplicating Include Files:* Use append files (``.bbappend``)
+- *Avoid Duplicating Include Files:* Use :term:`append files` (``.bbappend``)
for each recipe that uses an include file. Or, if you are introducing
a new recipe that requires the included file, use the path relative
to the original layer directory to refer to the file. For example,
@@ -506,19 +464,14 @@ enable it. To enable your layer, simply add your layer's path to the
found in the :term:`Build Directory`. The following example shows how to
enable your new ``meta-mylayer`` layer::
- # POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
- # changes incompatibly
- POKY_BBLAYERS_CONF_VERSION = "2"
- BBPATH = "${TOPDIR}"
- BBFILES ?= ""
BBLAYERS ?= " \
- /home/user/poky/meta \
- /home/user/poky/meta-poky \
- /home/user/poky/meta-yocto-bsp \
- /home/user/mystuff/meta-mylayer \
+ /home/user/openembedded-core/meta \
+ /home/user/meta-poky \
+ /home/user/meta-yocto-bsp \
+ /home/user/meta-mylayer \
"
-BitBake parses each ``conf/layer.conf`` file from the top down as
+BitBake parses each :ref:`structure-conf-layer.conf` file from the top down as
specified in the :term:`BBLAYERS` variable within the :ref:`structure-build-conf-bblayers.conf`
file. During the processing of each ``conf/layer.conf`` file, BitBake
adds the recipes, classes and configurations contained within the
@@ -528,7 +481,7 @@ Appending Other Layers Metadata With Your Layer
===============================================
A recipe that appends Metadata to another recipe is called a BitBake
-append file. A BitBake append file uses the ``.bbappend`` file type
+:term:`append file <Append Files>`. A BitBake append file uses the ``.bbappend`` file type
suffix, while the corresponding recipe to which Metadata is being
appended uses the ``.bb`` file type suffix.
@@ -706,123 +659,6 @@ check for an additional :term:`MACHINE_FEATURES` that if set will cause these
additional files to be installed. These additional files are listed in
:term:`FILES` so that they will be packaged.
-Prioritizing Your Layer
-=======================
-
-Each layer is assigned a priority value. Priority values control which
-layer takes precedence if there are recipe files with the same name in
-multiple layers. For these cases, the recipe file from the layer with a
-higher priority number takes precedence. Priority values also affect the
-order in which multiple ``.bbappend`` files for the same recipe are
-applied. You can either specify the priority manually, or allow the
-build system to calculate it based on the layer's dependencies.
-
-To specify the layer's priority manually, use the
-:term:`BBFILE_PRIORITY`
-variable and append the layer's root name::
-
- BBFILE_PRIORITY_mylayer = "1"
-
-.. note::
-
- It is possible for a recipe with a lower version number
- :term:`PV` in a layer that has a higher
- priority to take precedence.
-
- Also, the layer priority does not currently affect the precedence
- order of ``.conf`` or ``.bbclass`` files. Future versions of BitBake
- might address this.
-
-Providing Global-level Configurations With Your Layer
------------------------------------------------------
-
-When creating a layer, you may need to define configurations that should take
-effect globally in your build environment when the layer is part of the build.
-The ``layer.conf`` file is a :term:`configuration file` that affects the build
-system globally, so it is a candidate for this use-case.
-
-.. warning::
-
- Providing unconditional global level configuration from the ``layer.conf``
- file is *not* a good practice, and should be avoided. For this reason, the
- section :ref:`ref-conditional-layer-confs` below shows how the ``layer.conf``
- file can be used to provide configurations only if a certain condition is
- met.
-
-For example, if your layer provides a Linux kernel recipe named
-``linux-custom``, you may want to make :term:`PREFERRED_PROVIDER_virtual/kernel
-<PREFERRED_PROVIDER>` point to ``linux-custom``::
-
- PREFERRED_PROVIDER_virtual/kernel = "linux-custom"
-
-This can be defined in the ``layer.conf`` file. If your layer is at the last
-position in the :term:`BBLAYERS` list, it will take precedence over previous
-``PREFERRED_PROVIDER_virtual/kernel`` assignments (unless one is set from a
-:term:`configuration file` that is parsed later, such as machine or distro
-configuration files).
-
-.. _ref-conditional-layer-confs:
-
-Conditionally Provide Global-level Configurations With Your Layer
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
-
-In some cases, your layer may provide global configurations only if some
-features it provides are enabled. Since the ``layer.conf`` file is parsed at an
-earlier stage in the parsing process, the :term:`DISTRO_FEATURES` and
-:term:`MACHINE_FEATURES` variables are not yet available to ``layer.conf``, and
-declaring conditional assignments based on these variables is not possible. The
-following technique shows a way to bypass this limitation by using the
-:term:`USER_CLASSES` variable and a conditional ``require`` command.
-
-In the following steps, let's assume our layer is named ``meta-mylayer`` and
-that this layer defines a custom :ref:`distro feature <ref-features-distro>`
-named ``mylayer-kernel``. We will set the :term:`PREFERRED_PROVIDER` variable
-for the kernel only if our feature ``mylayer-kernel`` is part of the
-:term:`DISTRO_FEATURES`:
-
-#. Create an include file in the directory
- ``meta-mylayer/conf/distro/include/``, for example a file named
- ``mylayer-kernel-provider.inc`` that sets the kernel provider to
- ``linux-custom``::
-
- PREFERRED_PROVIDER_virtual/kernel = "linux-custom"
-
-#. Provide a path to this include file in your ``layer.conf``::
-
- META_MYLAYER_KERNEL_PROVIDER_PATH = "${LAYERDIR}/conf/distro/include/mylayer-kernel-provider.inc"
-
-#. Create a new class in ``meta-mylayer/classes-global/``, for example a class
- ``meta-mylayer-cfg.bbclass``. Make it conditionally require the file
- ``mylayer-kernel-provider.inc`` defined above, using the variable
- ``META_MYLAYER_KERNEL_PROVIDER_PATH`` defined in ``layer.conf``::
-
- require ${@bb.utils.contains('DISTRO_FEATURES', 'mylayer-kernel', '${META_MYLAYER_KERNEL_PROVIDER_PATH}', '', d)}
-
- For details on the ``bb.utils.contains`` function, see its definition in
- :bitbake_git:`lib/bb/utils.py </tree/lib/bb/utils.py>`.
-
- .. note::
-
- The ``require`` command is designed to not fail if the function
- ``bb.utils.contains`` returns an empty string.
-
-#. Back to your ``layer.conf`` file, add the class ``meta-mylayer-cfg`` class to
- the :term:`USER_CLASSES` variable::
-
- USER_CLASSES:append = " meta-mylayer-cfg"
-
- This will add the class ``meta-mylayer-cfg`` to the list of classes to
- globally inherit. Since the ``require`` command is conditional in
- ``meta-mylayer-cfg.bbclass``, even though inherited the class will have no
- effect unless the feature ``mylayer-kernel`` is enabled through
- :term:`DISTRO_FEATURES`.
-
-This technique can also be used for :ref:`Machine features
-<ref-features-machine>` by following the same steps. Though not mandatory, it is
-recommended to put include files for :term:`DISTRO_FEATURES` in your layer's
-``conf/distro/include`` and the ones for :term:`MACHINE_FEATURES` in your
-layer's ``conf/machine/include``.
-
Managing Layers
===============
@@ -948,13 +784,13 @@ shows the layers that are in your :ref:`structure-build-conf-bblayers.conf` file
Parsing of 1441 .bb files complete (0 cached, 1441 parsed). 2055 targets, 56 skipped, 0 masked, 0 errors.
$ bitbake-layers show-layers
NOTE: Starting bitbake server...
- layer path priority
- ==============================================================================================
- meta /home/user/bitbake-builds/layers/openembedded-core/meta 5
- meta-poky /home/user/bitbake-builds/layers/meta-yocto/meta-poky 5
- meta-yocto-bsp /home/user/bitbake-builds/layers/meta-yocto/meta-yocto-bsp 5
- workspace /home/user/bitbake-builds/build/workspace 99
- meta-scottrif /home/user/bitbake-builds/build/meta-scottrif 6
+ layer path version depends
+ =================================================================================================================
+ oe-core /home/user/bitbake-builds/layers/openembedded-core/meta 1
+ meta-yocto-poky /home/user/bitbake-builds/layers/meta-yocto/meta-poky 1 oe-core
+ meta-yocto-bsp /home/user/bitbake-builds/layers/meta-yocto/meta-yocto-bsp 1 oe-core
+ workspace /home/user/bitbake-builds/build/workspace 1 oe-core
+ meta-scottrif /home/user/bitbake-builds/build/meta-scottrif 1 oe-core
Adding the layer to this file
enables the build system to locate the layer during the build.
--
2.56.0
next prev parent reply other threads:[~2026-12-02 14:56 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 14:55 [PATCH 00/18] docs: refresh after layer configuration format changes Antonin Godard
2026-12-02 14:55 ` [PATCH 01/18] ref-manual/layers.rst: add document Antonin Godard
2026-12-02 14:55 ` [PATCH 02/18] ref-manual/variables.rst: BBFILES: refresh the definition Antonin Godard
2026-12-02 14:55 ` [PATCH 03/18] ref-manual/variables.rst: drop obsolete BBFILE* variables Antonin Godard
2026-12-02 14:55 ` [PATCH 04/18] ref-manual/variables.rst: drop LAYERDIR_RE Antonin Godard
2026-12-02 14:55 ` [PATCH 05/18] ref-manual/variables.rst: link bitbake-specific to the bitbake manual Antonin Godard
2026-12-02 14:55 ` [PATCH 06/18] ref-manual/variables.rst: document LAYER_FRAGMENTS_OPTED_OUT/LAYER_FRAGMENT_RECOMMENDS_ANY Antonin Godard
2026-12-02 14:55 ` [PATCH 07/18] migration-guides/migration-6.2.rst: add section on now layer format Antonin Godard
2026-12-02 14:55 ` [PATCH 08/18] migration-guides/migration-6.2.rst: add a section on the new core layer names Antonin Godard
2026-12-02 14:55 ` [PATCH 09/18] dev-manual/layers.rst: remove a leftover poky repo reference Antonin Godard
2026-12-02 14:55 ` Antonin Godard [this message]
2026-12-02 14:55 ` [PATCH 11/18] bsp-manual/bsp.rst: remove obsolete layer.conf references Antonin Godard
2026-12-02 14:55 ` [PATCH 12/18] kernel-dev/common.rst: " Antonin Godard
2026-12-02 14:55 ` [PATCH 13/18] docs-wide: rename core/* fragments to oe-core/* Antonin Godard
2026-12-02 14:55 ` [PATCH 14/18] dev-manual/creating-fragments.rst: remove obsolete BBFILE_COLLECTIONS reference Antonin Godard
2026-12-02 14:55 ` [PATCH 15/18] dev-manual/licenses.rst: refresh obsolete bblayers.conf.sample example Antonin Godard
2026-12-02 14:55 ` [PATCH 16/18] dev-manual/new-recipe.rst: remove obsolete BBFILES statement Antonin Godard
2026-12-02 14:55 ` [PATCH 17/18] security-manual/vulnerabilities.rst: rename core -> oe-core in JSON snippet Antonin Godard
2026-12-02 14:55 ` [PATCH 18/18] test-manual/runtime-testing.rst: fix wrong BBPATH statements Antonin Godard
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261202-layer-conf-changes-v1-10-da34d4c770c6@bootlin.com \
--to=antonin.godard@bootlin.com \
--cc=docs@lists.yoctoproject.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox