@@ -15,6 +15,7 @@ Yocto Project Reference Manual
terms
release-process
structure
+ layers
classes
tasks
library-functions
new file mode 100644
@@ -0,0 +1,148 @@
+.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
+
+******
+Layers
+******
+
+This section of the Yocto Project Reference Manual contains reference
+documentation about :term:`Layers <layer>`, a core component of the
+:term:`OpenEmbedded Build System`.
+
+Layer Configuration Files
+=========================
+
+A :term:`layer` is a collection of :term:`metadata`, which can be
+:term:`configuration files <Configuration File>`, :doc:`classes
+</ref-manual/classes>`, recipes, bbappends, or :term:`configuration fragments
+<Configuration Fragment>`.
+
+This collection is represented as a directory, and its structure should at a
+minimum contain a ``conf/`` directory and a ``layer.conf`` configuration
+file:
+
+.. code-block:: text
+
+ meta-foo/
+ └── conf/
+ └── layer.conf
+
+A :term:`layer` directory name is prefixed with ``meta-`` by convention, such as
+``meta-example`` in the snippet above.
+
+.. _structure-conf-layer.conf:
+
+``conf/layer.conf``
+-------------------
+
+The :ref:`structure-conf-layer.conf` file is what :term:`BitBake` looks for when
+a :term:`layer` is included in the :ref:`structure-build-conf-bblayers.conf`
+file (located in the :term:`Build Directory`). It declares basic information
+about the layer and its dependencies.
+
+At a minimum, this file should contain the following variable assignments::
+
+ LAYERNAME = "meta-example"
+ LAYERVERSION = "1"
+ LAYERDEPENDS = "oe-core ..."
+ LAYERSERIES_COMPAT = "garburn"
+
+See each variable's definition in the :doc:`variable glossary
+</ref-manual/variables>` for more information.
+
+In addition to these variables:
+
+- Only the variable prefixes listed in :term:`LAYER_PASSTHROUGH_VARS_PREFIXES`
+ are allowed to be set from the :ref:`structure-conf-layer.conf` file. The
+ :term:`OpenEmbedded-Core (OE-Core)` layer sets this variable.
+
+ .. note::
+
+ While not recommended, a layer can override the
+ :term:`LAYER_PASSTHROUGH_VARS_PREFIXES` variable to allow other variables
+ to be set from the :ref:`structure-conf-layer.conf` file.
+
+ This layer must set *the entire list* of prefixes with a regular ``=``
+ assignment. It also must be the first one setting the
+ :term:`LAYER_PASSTHROUGH_VARS_PREFIXES` variable in the :term:`BBLAYERS`
+ list. As a consequence, any other statement made by another layer setting
+ or appending the :term:`LAYER_PASSTHROUGH_VARS_PREFIXES` variable is
+ ignored.
+
+ If setting a global variable is required, it is recommended to do so from
+ a distro :term:`configuration file` or from a :term:`configuration
+ fragment`.
+
+ .. warning::
+
+ Any other variables set in this file will have no effect! To set a
+ variable from a layer configuration file, which only affects the scope of
+ the :term:`metadata` part of the layer, see the
+ :ref:`structure-conf-layervars.conf` file definition.
+
+- The :ref:`addpylib <bitbake-user-manual/bitbake-user-manual-metadata:Extending
+ Python Library Code>` directive can be used to make an internal Python
+ library available to the :term:`metadata`.
+
+.. _structure-conf-layervars.conf:
+
+``conf/layervars.conf``
+-----------------------
+
+The :ref:`structure-conf-layervars.conf` is, like
+:ref:`structure-conf-layer.conf`, part of the layer's ``conf/`` directory, and
+can contain variable assignments. Those assignments only affect the
+:term:`metadata` part of the layer itself *without affecting the global scope*.
+
+For example, if a layer provides a global :doc:`class </ref-manual/classes>`,
+but this class only makes sense for the recipes part of the layer, then one
+could write the following in :ref:`structure-conf-layervars.conf`::
+
+ INHERIT += "myclass"
+
+This class would be inherited only by the recipes part of the layer containing
+the file, but other recipes *not* part of the layer would not inherit that
+class.
+
+Layer Metadata
+==============
+
+A layer can contain various forms of :term:`metadata`. The aim of this section
+is not to explain what each of these types of :term:`metadata` do, but rather
+enumerate and link to each part of the documentation associated with them:
+
+- Recipes: see the :ref:`bitbake-user-manual/bitbake-user-manual-intro:Recipes`
+ section for more information.
+
+- Append files (bbappends): see the :ref:`bitbake:append-bbappend-files`
+ section for information.
+
+- Configuration files:
+
+ - Machine configuration files, see the :ref:`bsp-manual/bsp:Hardware
+ Configuration Options` section for more information.
+
+ - Distro configuration files, see the :doc:`/dev-manual/custom-distribution`
+ section for more information.
+
+ - Configuration Fragments: see the :doc:`/dev-manual/creating-fragments`
+ section for more information.
+
+- :doc:`classes </ref-manual/classes>`: expected to be found by
+ :term:`BitBake` in any of the ``classes/``, ``classes-global/``, and
+ ``classes-recipe/`` directories at the root of the layer.
+
+ See the :doc:`/ref-manual/classes` section for more information on classes.
+
+- Internal Python libraries: see the
+ :ref:`bitbake-user-manual/bitbake-user-manual-metadata:Extending
+ Python Library Code` section for more information.
+
+Additional Information on Layers
+================================
+
+The BitBake User Manual contains additional information on layers which can be
+found here:
+
+- :ref:`bitbake-user-manual/bitbake-user-manual-execution:Locating and Parsing Recipes`.
+- :ref:`bitbake-user-manual/bitbake-user-manual-execution:Dynamic Recipes and Append Files`.
+- :ref:`bitbake-user-manual/bitbake-user-manual-execution:Parsing Order And Priorities`.
This document aims to hold basic, but concept information about what a layer is and how it is supposed to be organized. Signed-off-by: Antonin Godard <antonin.godard@bootlin.com> --- documentation/ref-manual/index.rst | 1 + documentation/ref-manual/layers.rst | 148 ++++++++++++++++++++++++++++++++++++ 2 files changed, 149 insertions(+)