Skip to contentSkip to conversation

bitbake: doc: Add section for variable context

PATCH Simone Weiß 1 participant 1 message Feb 18, 2024 1 message not in the archive

lore
Share & tools
lore
#1 lore raw
In reply to a message not in the archive
Quoted 147 lines · Simone Weiß

From: Simone Weiß <[email protected]>

This is inspired by the same section in the yocto-docs. It aims to provide
information in what contexts(recipes, .conf, bbclass,...) a variable is usually
used. For that I tried to group similar variables, so that a short overview is
given. This was inspired by [YOCTO #14072], but of course does not implement a
warning if a variable is used in an unintended context.

---
 ...bake-user-manual-ref-variables-context.rst | 89 +++++++++++++++++++ doc/index.rst                                 |  1 +

 2 files changed, 90 insertions(+)

 create mode 100644 doc/bitbake-user-manual/bitbake-user-manual-ref- variables-context.rst

(quoted diff) +0 -0

context.rst b/doc/bitbake-user-manual/bitbake-user-manual-ref-variables- context.rst
new file mode 100644
index 00000000..8252889e

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +0 -0

context.rst

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +7 -0
@@ -0,0 +1,89 @@
+.. SPDX-License-Identifier: CC-BY-SA-2.0-UK
+
+****************
+Variable Context
+****************
+
+Variables might only have an impact or can be used in certain contexts.

Some
+should only be used in global files like ``.conf``, while others are intended only
+for local files like ``.bb``. This chapter aims to describe some important variable

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +8 -0
+contexts.
+
+.. _ref-varcontext-configuration:
+
+BitBake's own configuration
+===========================
+
+Variables starting with ``BB_`` usually configure the behaviour of

BitBake itself.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +3 -0
+For example, one could configure:
+
+- System resources, like disk space to be used

(:term:BB_DISKMON_DIRS),
+  or the number of tasks to be run in parallel by BitBake (:term:BB_NUMBER_THREADS).
+
+- How the fetchers shall behave, e.g., :term:BB_FETCH_PREMIRRORONLY is used
+  by BitBake to determine if BitBake's fetcher shall search only +  :term:PREMIRRORS for files.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +9 -0
+
+Those variables are usually configured globally.
+
+BitBake configuration
+=====================
+
+There are variables:
+
+- Like :term:`B` or :term:`T`, that are used to specify directories

used by
+  BitBake during the build of a particular recipe. Those variables are +  specified in ``bitbake.conf``. Some, like :term:B, are quite often +  overwritten in recipes.
+
+- Starting with ``FAKEROOT``, to configure how the ``fakeroot`` command is
+  handled. Those are usually set by ``bitbake.conf`` and might get adapted in a
+  ``bbclass``.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +11 -0
+
+- Detailing where BitBake will store and fetch information from, for
+  data reuse between build runs like :term:`CACHE`, :term:`DL_DIR` or
+  :term:`PERSISTENT_DIR`. Those are usually global.
+
+
+Layers and files
+================
+
+Variables starting with ``LAYER`` configure how BitBake handles layers.
+Additionally, variables starting with ``BB`` configure how layers and

files are

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +3 -0
+handled. For example:
+
+- :term:`LAYERDEPENDS` is used to configure on which layers a given

layer
+  depends.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +5 -0
+
+- The configured layers are contained in :term:`BBLAYERS` and files in
+  :term:`BBFILES`.
+
+Those variables are often used in the files ``layer.conf`` and

``bblayers.conf``.

doc/bitbake-user-manual/bitbake-user-manual-ref-variables- new file +7 -0
+
+Recipes and packages
+====================
+
+Variables handling recipes and packages can be split into:
+
+- :term:`PN`, :term:`PV` or :term:`PF` for example, contain information

about
+  the name or revision of a recipe or package. Usually, the default set in
+  ``bitbake.conf`` is used, but those are from time to time overwritten in
+  recipes.
+
+- :term:SUMMARY, :term:DESCRIPTION, :term:LICENSE or :term:HOMEPAGE
+  contain the expected information and should be set specifically for every
+  recipe.
+
+- In recipes, variables are also used to control build and runtime +  dependencies between recipes/packages with other recipes/packages. The
+  most common should be: :term:PROVIDES, :term:RPROVIDES, :term:DEPENDS,
+  and :term:RDEPENDS.
+
+- There are further variables starting with ``SRC`` that specify the sources in
+  a recipe like :term:SRC_URI or :term:SRCDATE. Those are also usually set
+  in recipes.
+
+- Which version or provider of a recipe should be given preference when +  multiple recipes would provide the same item, is controlled by variables
+  starting with ``PREFERRED_``. Those are normally set in the configuration
+  files of a ``MACHINE`` or ``DISTRO``.

doc/index.rst +0 -0
index 3ff8b158..ee1660ac 100644
@@ -13,6 +13,7 @@ BitBake User Manual
Quoted 10 lines

    bitbake-user-manual/bitbake-user-manual-intro bitbake-user-manual/bitbake-user-manual-execution bitbake-user-manual/bitbake-user-manual-metadata
+   bitbake-user-manual/bitbake-user-manual-ref-variables-context bitbake-user-manual/bitbake-user-manual-fetching bitbake-user-manual/bitbake-user-manual-ref-variables bitbake-user-manual/bitbake-user-manual-hello

I forgot to mentioned it in the commit message. Once this is good and merged, I would reference it in the yocto-docs as well. A picture showcasing this further as described by Quentin in [1] is also a good idea, I just think that this might better be placed in another section, maybe as an extension after the section 4.8 (Bitbake task map) in the yocto-docs.
And thanks for the helpful reviews on v1!

[1]:https://lists.yoctoproject.org/g/docs/message/4837