summaryrefslogtreecommitdiffstats
path: root/documentation/dev-manual/layers.rst
diff options
context:
space:
mode:
Diffstat (limited to 'documentation/dev-manual/layers.rst')
-rw-r--r--documentation/dev-manual/layers.rst144
1 files changed, 122 insertions, 22 deletions
diff --git a/documentation/dev-manual/layers.rst b/documentation/dev-manual/layers.rst
index f7929e630e..67482bf544 100644
--- a/documentation/dev-manual/layers.rst
+++ b/documentation/dev-manual/layers.rst
@@ -80,7 +80,7 @@ Follow these general steps to create your layer without using tools:
80 BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/" 80 BBFILE_PATTERN_yoctobsp = "^${LAYERDIR}/"
81 BBFILE_PRIORITY_yoctobsp = "5" 81 BBFILE_PRIORITY_yoctobsp = "5"
82 LAYERVERSION_yoctobsp = "4" 82 LAYERVERSION_yoctobsp = "4"
83 LAYERSERIES_COMPAT_yoctobsp = "dunfell" 83 LAYERSERIES_COMPAT_yoctobsp = "walnascar"
84 84
85 Here is an explanation of the layer configuration file: 85 Here is an explanation of the layer configuration file:
86 86
@@ -306,7 +306,7 @@ The Yocto Project Compatibility Program consists of a layer application
306process that requests permission to use the Yocto Project Compatibility 306process that requests permission to use the Yocto Project Compatibility
307Logo for your layer and application. The process consists of two parts: 307Logo for your layer and application. The process consists of two parts:
308 308
309#. Successfully passing a script (``yocto-check-layer``) that when run 309#. Successfully passing a script (``yocto-check-layer``) that, when run
310 against your layer, tests it against constraints based on experiences 310 against your layer, tests it against constraints based on experiences
311 of how layers have worked in the real world and where pitfalls have 311 of how layers have worked in the real world and where pitfalls have
312 been found. Getting a "PASS" result from the script is required for 312 been found. Getting a "PASS" result from the script is required for
@@ -470,11 +470,23 @@ corresponding recipe file. For example, the append file
470means the original recipe and append filenames are version 470means the original recipe and append filenames are version
471number-specific. If the corresponding recipe is renamed to update to a 471number-specific. If the corresponding recipe is renamed to update to a
472newer version, you must also rename and possibly update the 472newer version, you must also rename and possibly update the
473corresponding ``.bbappend`` as well. During the build process, BitBake 473corresponding ``.bbappend`` as well.
474displays an error on starting if it detects a ``.bbappend`` file that 474
475does not have a corresponding recipe with a matching name. See the 475During the build process, BitBake displays an error on startup if it detects a
476:term:`BB_DANGLINGAPPENDS_WARNONLY` 476``.bbappend`` file that does not have a corresponding recipe with a matching
477variable for information on how to handle this error. 477name. To handle these errors, the best practice is to rename the ``.bbappend``
478to match the original recipe version. This also gives you the opportunity to see
479if the ``.bbappend`` is still relevant for the new version of the recipe.
480
481Another method is to use the character ``%`` in the ``.bbappend`` filename. For
482example, to append information to every ``6.*`` minor versions of the recipe
483``someapp``, the ``someapp_6.%.bbappend`` file can be created. This way, an
484error will only be triggered if the ``someapp`` recipe has a major version
485update.
486
487Finally, another method to deal with these errors is to use the variable
488:term:`BBMASK`, especially in cases where modifying the ``.bbappend`` is not
489possible.
478 490
479Overlaying a File Using Your Layer 491Overlaying a File Using Your Layer
480---------------------------------- 492----------------------------------
@@ -492,21 +504,20 @@ the "meta" layer at ``meta/recipes-bsp/formfactor``::
492 SECTION = "base" 504 SECTION = "base"
493 LICENSE = "MIT" 505 LICENSE = "MIT"
494 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 506 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
495 PR = "r45"
496 507
497 SRC_URI = "file://config file://machconfig" 508 SRC_URI = "file://config file://machconfig"
498 S = "${WORKDIR}" 509 S = "${UNPACKDIR}"
499 510
500 PACKAGE_ARCH = "${MACHINE_ARCH}" 511 PACKAGE_ARCH = "${MACHINE_ARCH}"
501 INHIBIT_DEFAULT_DEPS = "1" 512 INHIBIT_DEFAULT_DEPS = "1"
502 513
503 do_install() { 514 do_install() {
504 # Install file only if it has contents 515 # Install file only if it has contents
505 install -d ${D}${sysconfdir}/formfactor/ 516 install -d ${D}${sysconfdir}/formfactor/
506 install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/ 517 install -m 0644 ${S}/config ${D}${sysconfdir}/formfactor/
507 if [ -s "${S}/machconfig" ]; then 518 if [ -s "${S}/machconfig" ]; then
508 install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/ 519 install -m 0644 ${S}/machconfig ${D}${sysconfdir}/formfactor/
509 fi 520 fi
510 } 521 }
511 522
512In the main recipe, note the :term:`SRC_URI` 523In the main recipe, note the :term:`SRC_URI`
@@ -570,11 +581,10 @@ Directory`. Here is the main ``xserver-xf86-config`` recipe, which is named
570 SECTION = "x11/base" 581 SECTION = "x11/base"
571 LICENSE = "MIT" 582 LICENSE = "MIT"
572 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 583 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
573 PR = "r33"
574 584
575 SRC_URI = "file://xorg.conf" 585 SRC_URI = "file://xorg.conf"
576 586
577 S = "${WORKDIR}" 587 S = "${UNPACKDIR}"
578 588
579 CONFFILES:${PN} = "${sysconfdir}/X11/xorg.conf" 589 CONFFILES:${PN} = "${sysconfdir}/X11/xorg.conf"
580 590
@@ -582,10 +592,10 @@ Directory`. Here is the main ``xserver-xf86-config`` recipe, which is named
582 ALLOW_EMPTY:${PN} = "1" 592 ALLOW_EMPTY:${PN} = "1"
583 593
584 do_install () { 594 do_install () {
585 if test -s ${WORKDIR}/xorg.conf; then 595 if test -s ${UNPACKDIR}/xorg.conf; then
586 install -d ${D}/${sysconfdir}/X11 596 install -d ${D}/${sysconfdir}/X11
587 install -m 0644 ${WORKDIR}/xorg.conf ${D}/${sysconfdir}/X11/ 597 install -m 0644 ${UNPACKDIR}/xorg.conf ${D}/${sysconfdir}/X11/
588 fi 598 fi
589 } 599 }
590 600
591Here is the append file, which is named ``xserver-xf86-config_%.bbappend`` 601Here is the append file, which is named ``xserver-xf86-config_%.bbappend``
@@ -602,8 +612,8 @@ file is in the layer at ``recipes-graphics/xorg-xserver``::
602 PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}" 612 PITFT="${@bb.utils.contains("MACHINE_FEATURES", "pitft", "1", "0", d)}"
603 if [ "${PITFT}" = "1" ]; then 613 if [ "${PITFT}" = "1" ]; then
604 install -d ${D}/${sysconfdir}/X11/xorg.conf.d/ 614 install -d ${D}/${sysconfdir}/X11/xorg.conf.d/
605 install -m 0644 ${WORKDIR}/xorg.conf.d/98-pitft.conf ${D}/${sysconfdir}/X11/xorg.conf.d/ 615 install -m 0644 ${UNPACKDIR}/xorg.conf.d/98-pitft.conf ${D}/${sysconfdir}/X11/xorg.conf.d/
606 install -m 0644 ${WORKDIR}/xorg.conf.d/99-calibration.conf ${D}/${sysconfdir}/X11/xorg.conf.d/ 616 install -m 0644 ${UNPACKDIR}/xorg.conf.d/99-calibration.conf ${D}/${sysconfdir}/X11/xorg.conf.d/
607 fi 617 fi
608 } 618 }
609 619
@@ -644,6 +654,96 @@ variable and append the layer's root name::
644 order of ``.conf`` or ``.bbclass`` files. Future versions of BitBake 654 order of ``.conf`` or ``.bbclass`` files. Future versions of BitBake
645 might address this. 655 might address this.
646 656
657Providing Global-level Configurations With Your Layer
658-----------------------------------------------------
659
660When creating a layer, you may need to define configurations that should take
661effect globally in your build environment when the layer is part of the build.
662The ``layer.conf`` file is a :term:`configuration file` that affects the build
663system globally, so it is a candidate for this use-case.
664
665.. warning::
666
667 Providing unconditional global level configuration from the ``layer.conf``
668 file is *not* a good practice, and should be avoided. For this reason, the
669 section :ref:`ref-conditional-layer-confs` below shows how the ``layer.conf``
670 file can be used to provide configurations only if a certain condition is
671 met.
672
673For example, if your layer provides a Linux kernel recipe named
674``linux-custom``, you may want to make :term:`PREFERRED_PROVIDER_virtual/kernel
675<PREFERRED_PROVIDER>` point to ``linux-custom``::
676
677 PREFERRED_PROVIDER_virtual/kernel = "linux-custom"
678
679This can be defined in the ``layer.conf`` file. If your layer is at the last
680position in the :term:`BBLAYERS` list, it will take precedence over previous
681``PREFERRED_PROVIDER_virtual/kernel`` assignments (unless one is set from a
682:term:`configuration file` that is parsed later, such as machine or distro
683configuration files).
684
685.. _ref-conditional-layer-confs:
686
687Conditionally Provide Global-level Configurations With Your Layer
688^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
689
690In some cases, your layer may provide global configurations only if some
691features it provides are enabled. Since the ``layer.conf`` file is parsed at an
692earlier stage in the parsing process, the :term:`DISTRO_FEATURES` and
693:term:`MACHINE_FEATURES` variables are not yet available to ``layer.conf``, and
694declaring conditional assignments based on these variables is not possible. The
695following technique shows a way to bypass this limitation by using the
696:term:`USER_CLASSES` variable and a conditional ``require`` command.
697
698In the following steps, let's assume our layer is named ``meta-mylayer`` and
699that this layer defines a custom :ref:`distro feature <ref-features-distro>`
700named ``mylayer-kernel``. We will set the :term:`PREFERRED_PROVIDER` variable
701for the kernel only if our feature ``mylayer-kernel`` is part of the
702:term:`DISTRO_FEATURES`:
703
704#. Create an include file in the directory
705 ``meta-mylayer/conf/distro/include/``, for example a file named
706 ``mylayer-kernel-provider.inc`` that sets the kernel provider to
707 ``linux-custom``::
708
709 PREFERRED_PROVIDER_virtual/kernel = "linux-custom"
710
711#. Provide a path to this include file in your ``layer.conf``::
712
713 META_MYLAYER_KERNEL_PROVIDER_PATH = "${LAYERDIR}/conf/distro/include/mylayer-kernel-provider.inc"
714
715#. Create a new class in ``meta-mylayer/classes-global/``, for example a class
716 ``meta-mylayer-cfg.bbclass``. Make it conditionally require the file
717 ``mylayer-kernel-provider.inc`` defined above, using the variable
718 ``META_MYLAYER_KERNEL_PROVIDER_PATH`` defined in ``layer.conf``::
719
720 require ${@bb.utils.contains('DISTRO_FEATURES', 'mylayer-kernel', '${META_MYLAYER_KERNEL_PROVIDER_PATH}', '', d)}
721
722 For details on the ``bb.utils.contains`` function, see its definition in
723 :bitbake_git:`lib/bb/utils.py </tree/lib/bb/utils.py>`.
724
725 .. note::
726
727 The ``require`` command is designed to not fail if the function
728 ``bb.utils.contains`` returns an empty string.
729
730#. Back to your ``layer.conf`` file, add the class ``meta-mylayer-cfg`` class to
731 the :term:`USER_CLASSES` variable::
732
733 USER_CLASSES:append = " meta-mylayer-cfg"
734
735 This will add the class ``meta-mylayer-cfg`` to the list of classes to
736 globally inherit. Since the ``require`` command is conditional in
737 ``meta-mylayer-cfg.bbclass``, even though inherited the class will have no
738 effect unless the feature ``mylayer-kernel`` is enabled through
739 :term:`DISTRO_FEATURES`.
740
741This technique can also be used for :ref:`Machine features
742<ref-features-machine>` by following the same steps. Though not mandatory, it is
743recommended to put include files for :term:`DISTRO_FEATURES` in your layer's
744``conf/distro/include`` and the ones for :term:`MACHINE_FEATURES` in your
745layer's ``conf/machine/include``.
746
647Managing Layers 747Managing Layers
648=============== 748===============
649 749
@@ -732,7 +832,7 @@ The following list describes the available commands:
732 832
733- ``save-build-conf``: Saves the currently active build configuration 833- ``save-build-conf``: Saves the currently active build configuration
734 (``conf/local.conf``, ``conf/bblayers.conf``) as a template into a layer. 834 (``conf/local.conf``, ``conf/bblayers.conf``) as a template into a layer.
735 This template can later be used for setting up builds via :term:``TEMPLATECONF``. 835 This template can later be used for setting up builds via :term:`TEMPLATECONF`.
736 For information about saving and using configuration templates, see 836 For information about saving and using configuration templates, see
737 ":ref:`dev-manual/custom-template-configuration-directory:creating a custom template configuration directory`". 837 ":ref:`dev-manual/custom-template-configuration-directory:creating a custom template configuration directory`".
738 838