diff options
Diffstat (limited to 'documentation/dev-manual/creating-fragments.rst')
| -rw-r--r-- | documentation/dev-manual/creating-fragments.rst | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/documentation/dev-manual/creating-fragments.rst b/documentation/dev-manual/creating-fragments.rst deleted file mode 100644 index 7f437d7c94..0000000000 --- a/documentation/dev-manual/creating-fragments.rst +++ /dev/null | |||
| @@ -1,146 +0,0 @@ | |||
| 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK | ||
| 2 | |||
| 3 | Creating New Configuration Fragments In Your Build | ||
| 4 | ************************************************** | ||
| 5 | |||
| 6 | :term:`Configuration Fragments <Configuration Fragment>` define top level build | ||
| 7 | configuration features that can be independently enabled and disabled using | ||
| 8 | standard tooling. Such features are made of one or several build configuration | ||
| 9 | statements that are either contained in a fragment file, or are set indirectly | ||
| 10 | using the :term:`Built-in Fragment` mechanism. | ||
| 11 | |||
| 12 | This section will describe how to create new fragments for your builds. | ||
| 13 | |||
| 14 | There are two kinds of configuration fragments: | ||
| 15 | |||
| 16 | - Standard :term:`Configuration Fragments <Configuration Fragment>` which a | ||
| 17 | stored in a file. These fragments include a summary and a description, | ||
| 18 | following by configuration statements. | ||
| 19 | |||
| 20 | - :term:`Built-in Fragments <Built-in Fragment>` which can be used to assign a | ||
| 21 | value to a single variable and do not require a separate definition file. | ||
| 22 | They are especially useful when a list of possible values is very long (or | ||
| 23 | infinite). | ||
| 24 | |||
| 25 | Creating A Standard Configuration Fragment | ||
| 26 | ========================================== | ||
| 27 | |||
| 28 | By default, all configuration fragments are located within the | ||
| 29 | ``conf/fragments`` directory of a :term:`layer`. This location is defined by the | ||
| 30 | :term:`OE_FRAGMENTS_PREFIX` variable which, in turn, is used as a parameter in an | ||
| 31 | :ref:`addfragments <bitbake-user-manual/bitbake-user-manual-metadata:\`\`addfragments\`\` | ||
| 32 | directive>` directive in :oe_git:`bitbake.conf </openembedded-core/tree/meta/conf/bitbake.conf>`. | ||
| 33 | |||
| 34 | You can create one or more :term:`configuration fragment` files in your | ||
| 35 | :term:`layer` in this directory. Let's take the following example, where | ||
| 36 | ``custom-fragment.conf`` is our custom fragment file:: | ||
| 37 | |||
| 38 | meta-custom | ||
| 39 | ├── conf | ||
| 40 | │ ├── fragments | ||
| 41 | │ │ └── custom-fragment.conf | ||
| 42 | │ └── layer.conf | ||
| 43 | ... | ||
| 44 | |||
| 45 | For our ``custom-fragment.conf`` file, the following variables **must** be set | ||
| 46 | for our fragment to be considered a valid fragment by the :term:`OpenEmbedded | ||
| 47 | Build System`: | ||
| 48 | |||
| 49 | - :term:`BB_CONF_FRAGMENT_SUMMARY`: a one-line summary of this fragment. | ||
| 50 | |||
| 51 | - :term:`BB_CONF_FRAGMENT_DESCRIPTION`: a description of this fragment. | ||
| 52 | |||
| 53 | .. note:: | ||
| 54 | |||
| 55 | The :term:`BB_CONF_FRAGMENT_SUMMARY` and :term:`BB_CONF_FRAGMENT_DESCRIPTION` | ||
| 56 | variables are also passed as parameters in an :ref:`addfragments | ||
| 57 | <bitbake-user-manual/bitbake-user-manual-metadata:\`\`addfragments\`\` | ||
| 58 | directive>` directive in :oe_git:`bitbake.conf | ||
| 59 | </openembedded-core/tree/meta/conf/bitbake.conf>`. | ||
| 60 | |||
| 61 | After creating these variables, our custom fragment should look like the | ||
| 62 | following: | ||
| 63 | |||
| 64 | .. code-block:: | ||
| 65 | :caption: custom-fragment.conf | ||
| 66 | |||
| 67 | BB_CONF_FRAGMENT_SUMMARY = "This fragment sets a limit of 4 bitbake threads and 4 parsing threads" | ||
| 68 | BB_CONF_FRAGMENT_DESCRIPTION = "This fragment is useful to constrain resource consumption when the Yocto default \ | ||
| 69 | is causing an overload of host machine's memory and CPU resources." | ||
| 70 | |||
| 71 | For now, our fragment does not have any additional configuration statement. | ||
| 72 | Let's add the following assignments to our fragment: | ||
| 73 | |||
| 74 | .. code-block:: | ||
| 75 | :caption: custom-fragment.conf (continued) | ||
| 76 | |||
| 77 | BB_NUMBER_THREADS = "4" | ||
| 78 | BB_NUMBER_PARSE_THREADS = "4" | ||
| 79 | |||
| 80 | This means that our fragment can be enabled to set a limit on the number of | ||
| 81 | threads :term:`BitBake` will use with the :term:`BB_NUMBER_THREADS` and | ||
| 82 | :term:`BB_NUMBER_PARSE_THREADS` variables. | ||
| 83 | |||
| 84 | For now, our fragment exists and is listed by the | ||
| 85 | :ref:`ref-bitbake-config-build-list-fragments` command, but is not enabled. To | ||
| 86 | enable this fragment, use the :ref:`ref-bitbake-config-build-enable-fragment` | ||
| 87 | command:: | ||
| 88 | |||
| 89 | bitbake-config-build enable-fragment meta-custom/custom-fragment | ||
| 90 | |||
| 91 | .. note:: | ||
| 92 | |||
| 93 | The ``meta-custom`` prefix in the above command depends on the name of your | ||
| 94 | layer. This name is defined by the :term:`BBFILE_COLLECTIONS` variable in | ||
| 95 | the ``conf/layer.conf`` file of your layer. | ||
| 96 | |||
| 97 | Standard Configuration fragments can be organized in a more complex way. For | ||
| 98 | example, it's possible to create sub-directories to organize your fragments:: | ||
| 99 | |||
| 100 | meta-custom | ||
| 101 | ├── conf | ||
| 102 | │ ├── fragments | ||
| 103 | │ │ ├── networking | ||
| 104 | │ │ │ └── mirrors.conf | ||
| 105 | │ │ └── resources | ||
| 106 | │ │ └── numberthreads.conf | ||
| 107 | │ └── layer.conf | ||
| 108 | ... | ||
| 109 | |||
| 110 | In the above example, the ``meta-custom/networking/mirrors`` and | ||
| 111 | ``meta-custom/resources/numberthreads`` fragments will be available in your | ||
| 112 | build. | ||
| 113 | |||
| 114 | Creating A Built-in Fragment | ||
| 115 | ============================ | ||
| 116 | |||
| 117 | Within the :term:`OpenEmbedded Build System`, Built-in Fragments are defined | ||
| 118 | with the :term:`OE_FRAGMENTS_BUILTIN` variable, which is passed as a | ||
| 119 | parameter in an :ref:`addfragments <bitbake-user-manual/bitbake-user-manual-metadata:\`\`addfragments\`\` | ||
| 120 | directive>` directive in :oe_git:`bitbake.conf </openembedded-core/tree/meta/conf/bitbake.conf>`. | ||
| 121 | |||
| 122 | Adding new :term:`Built-in Fragments <Built-in Fragment>` can be done by | ||
| 123 | appending the :term:`OE_FRAGMENTS_BUILTIN` variable from your :term:`layer` | ||
| 124 | configuration file: | ||
| 125 | |||
| 126 | .. code-block:: | ||
| 127 | :caption: layer.conf | ||
| 128 | |||
| 129 | OE_FRAGMENTS_BUILTIN:append = " custom-builtin-fragment:CUSTOM_VARIABLE" | ||
| 130 | |||
| 131 | .. warning:: | ||
| 132 | |||
| 133 | Make sure to use the ``:append`` override in the above assignment, as using | ||
| 134 | ``+=`` can lead to unexpected behavior. | ||
| 135 | |||
| 136 | .. warning:: | ||
| 137 | |||
| 138 | Due to the way :term:`BitBake` parses files, it is not possible to modify | ||
| 139 | :term:`OE_FRAGMENTS_BUILTIN` from any kind of :term:`configuration file`. | ||
| 140 | Setting it from the :term:`layer` configuration file (``conf/layer.conf``) is | ||
| 141 | the retained solution to create new built-in fragments. | ||
| 142 | |||
| 143 | You can then use the :ref:`ref-bitbake-config-build-enable-fragment` command to | ||
| 144 | set a value to the ``CUSTOM_VARIABLE`` variable:: | ||
| 145 | |||
| 146 | bitbake-config-build enable-fragment custom-builtin-fragment/somevalue | ||
