Andrew Geissler | f034379 | 2020-11-18 10:42:21 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: CC-BY-SA-2.0-UK |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 2 | |
| 3 | ****************************** |
| 4 | Customizing the Extensible SDK |
| 5 | ****************************** |
| 6 | |
| 7 | This appendix describes customizations you can apply to the extensible |
| 8 | SDK. |
| 9 | |
| 10 | Configuring the Extensible SDK |
| 11 | ============================== |
| 12 | |
| 13 | The extensible SDK primarily consists of a pre-configured copy of the |
| 14 | OpenEmbedded build system from which it was produced. Thus, the SDK's |
| 15 | configuration is derived using that build system and the filters shown |
| 16 | in the following list. When these filters are present, the OpenEmbedded |
| 17 | build system applies them against ``local.conf`` and ``auto.conf``: |
| 18 | |
| 19 | - Variables whose values start with "/" are excluded since the |
| 20 | assumption is that those values are paths that are likely to be |
| 21 | specific to the :term:`Build Host`. |
| 22 | |
| 23 | - Variables listed in |
| 24 | :term:`SDK_LOCAL_CONF_BLACKLIST` |
| 25 | are excluded. These variables are not allowed through from the |
| 26 | OpenEmbedded build system configuration into the extensible SDK |
| 27 | configuration. Typically, these variables are specific to the machine |
| 28 | on which the build system is running and could be problematic as part |
| 29 | of the extensible SDK configuration. |
| 30 | |
| 31 | For a list of the variables excluded by default, see the |
| 32 | :term:`SDK_LOCAL_CONF_BLACKLIST` |
| 33 | in the glossary of the Yocto Project Reference Manual. |
| 34 | |
| 35 | - Variables listed in |
| 36 | :term:`SDK_LOCAL_CONF_WHITELIST` |
| 37 | are included. Including a variable in the value of |
| 38 | ``SDK_LOCAL_CONF_WHITELIST`` overrides either of the previous two |
| 39 | filters. The default value is blank. |
| 40 | |
| 41 | - Classes inherited globally with |
| 42 | :term:`INHERIT` that are listed in |
| 43 | :term:`SDK_INHERIT_BLACKLIST` |
| 44 | are disabled. Using ``SDK_INHERIT_BLACKLIST`` to disable these |
| 45 | classes is the typical method to disable classes that are problematic |
| 46 | or unnecessary in the SDK context. The default value blacklists the |
| 47 | :ref:`buildhistory <ref-classes-buildhistory>` |
| 48 | and :ref:`icecc <ref-classes-icecc>` classes. |
| 49 | |
| 50 | Additionally, the contents of ``conf/sdk-extra.conf``, when present, are |
| 51 | appended to the end of ``conf/local.conf`` within the produced SDK, |
| 52 | without any filtering. The ``sdk-extra.conf`` file is particularly |
| 53 | useful if you want to set a variable value just for the SDK and not the |
| 54 | OpenEmbedded build system used to create the SDK. |
| 55 | |
| 56 | Adjusting the Extensible SDK to Suit Your Build Host's Setup |
| 57 | ============================================================ |
| 58 | |
| 59 | In most cases, the extensible SDK defaults should work with your :term:`Build |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 60 | Host`'s setup. However, there are cases when you might consider making |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 61 | adjustments: |
| 62 | |
| 63 | - If your SDK configuration inherits additional classes using the |
| 64 | :term:`INHERIT` variable and you |
| 65 | do not need or want those classes enabled in the SDK, you can |
| 66 | blacklist them by adding them to the |
| 67 | :term:`SDK_INHERIT_BLACKLIST` |
| 68 | variable as described in the fourth bullet of the previous section. |
| 69 | |
| 70 | .. note:: |
| 71 | |
| 72 | The default value of |
| 73 | SDK_INHERIT_BLACKLIST |
| 74 | is set using the "?=" operator. Consequently, you will need to |
| 75 | either define the entire list by using the "=" operator, or you |
| 76 | will need to append a value using either "_append" or the "+=" |
| 77 | operator. You can learn more about these operators in the " |
| 78 | Basic Syntax |
| 79 | " section of the BitBake User Manual. |
| 80 | |
| 81 | . |
| 82 | |
| 83 | - If you have classes or recipes that add additional tasks to the |
| 84 | standard build flow (i.e. the tasks execute as the recipe builds as |
| 85 | opposed to being called explicitly), then you need to do one of the |
| 86 | following: |
| 87 | |
| 88 | - After ensuring the tasks are :ref:`shared |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 89 | state <overview-manual/concepts:shared state cache>` tasks (i.e. the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 90 | output of the task is saved to and can be restored from the shared |
| 91 | state cache) or ensuring the tasks are able to be produced quickly |
| 92 | from a task that is a shared state task, add the task name to the |
| 93 | value of |
| 94 | :term:`SDK_RECRDEP_TASKS`. |
| 95 | |
| 96 | - Disable the tasks if they are added by a class and you do not need |
| 97 | the functionality the class provides in the extensible SDK. To |
| 98 | disable the tasks, add the class to the ``SDK_INHERIT_BLACKLIST`` |
| 99 | variable as described in the previous section. |
| 100 | |
| 101 | - Generally, you want to have a shared state mirror set up so users of |
| 102 | the SDK can add additional items to the SDK after installation |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 103 | without needing to build the items from source. See the |
| 104 | ":ref:`sdk-manual/appendix-customizing:providing additional installable extensible sdk content`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 105 | section for information. |
| 106 | |
| 107 | - If you want users of the SDK to be able to easily update the SDK, you |
| 108 | need to set the |
| 109 | :term:`SDK_UPDATE_URL` |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 110 | variable. For more information, see the |
| 111 | ":ref:`sdk-manual/appendix-customizing:providing updates to the extensible sdk after installation`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 112 | section. |
| 113 | |
| 114 | - If you have adjusted the list of files and directories that appear in |
| 115 | :term:`COREBASE` (other than |
| 116 | layers that are enabled through ``bblayers.conf``), then you must |
| 117 | list these files in |
| 118 | :term:`COREBASE_FILES` so |
| 119 | that the files are copied into the SDK. |
| 120 | |
| 121 | - If your OpenEmbedded build system setup uses a different environment |
| 122 | setup script other than |
| 123 | :ref:`structure-core-script`, then you must |
| 124 | set |
| 125 | :term:`OE_INIT_ENV_SCRIPT` |
| 126 | to point to the environment setup script you use. |
| 127 | |
| 128 | .. note:: |
| 129 | |
| 130 | You must also reflect this change in the value used for the |
| 131 | COREBASE_FILES |
| 132 | variable as previously described. |
| 133 | |
| 134 | Changing the Extensible SDK Installer Title |
| 135 | =========================================== |
| 136 | |
| 137 | You can change the displayed title for the SDK installer by setting the |
| 138 | :term:`SDK_TITLE` variable and then |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 139 | rebuilding the SDK installer. For information on how to build an SDK |
| 140 | installer, see the ":ref:`sdk-manual/appendix-obtain:building an sdk installer`" |
| 141 | section. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 142 | |
| 143 | By default, this title is derived from |
| 144 | :term:`DISTRO_NAME` when it is |
| 145 | set. If the ``DISTRO_NAME`` variable is not set, the title is derived |
| 146 | from the :term:`DISTRO` variable. |
| 147 | |
| 148 | The |
| 149 | :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` |
| 150 | class defines the default value of the ``SDK_TITLE`` variable as |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 151 | follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 152 | |
| 153 | SDK_TITLE ??= "${@d.getVar('DISTRO_NAME') or d.getVar('DISTRO')} SDK" |
| 154 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 155 | While there are several ways of changing this variable, an efficient method is |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 156 | to set the variable in your distribution's configuration file. Doing so |
| 157 | creates an SDK installer title that applies across your distribution. As |
| 158 | an example, assume you have your own layer for your distribution named |
| 159 | "meta-mydistro" and you are using the same type of file hierarchy as |
| 160 | does the default "poky" distribution. If so, you could update the |
| 161 | ``SDK_TITLE`` variable in the |
| 162 | ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 163 | form:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 164 | |
| 165 | SDK_TITLE = "your_title" |
| 166 | |
| 167 | Providing Updates to the Extensible SDK After Installation |
| 168 | ========================================================== |
| 169 | |
| 170 | When you make changes to your configuration or to the metadata and if |
| 171 | you want those changes to be reflected in installed SDKs, you need to |
| 172 | perform additional steps. These steps make it possible for anyone using |
| 173 | the installed SDKs to update the installed SDKs by using the |
| 174 | ``devtool sdk-update`` command: |
| 175 | |
| 176 | 1. Create a directory that can be shared over HTTP or HTTPS. You can do |
| 177 | this by setting up a web server such as an `Apache HTTP |
| 178 | Server <https://en.wikipedia.org/wiki/Apache_HTTP_Server>`__ or |
| 179 | `Nginx <https://en.wikipedia.org/wiki/Nginx>`__ server in the cloud |
| 180 | to host the directory. This directory must contain the published SDK. |
| 181 | |
| 182 | 2. Set the |
| 183 | :term:`SDK_UPDATE_URL` |
| 184 | variable to point to the corresponding HTTP or HTTPS URL. Setting |
| 185 | this variable causes any SDK built to default to that URL and thus, |
| 186 | the user does not have to pass the URL to the ``devtool sdk-update`` |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 187 | command as described in the |
| 188 | ":ref:`sdk-manual/extensible:applying updates to an installed extensible sdk`" |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 189 | section. |
| 190 | |
| 191 | 3. Build the extensible SDK normally (i.e., use the |
| 192 | ``bitbake -c populate_sdk_ext`` imagename command). |
| 193 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 194 | 4. Publish the SDK using the following command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 195 | |
| 196 | $ oe-publish-sdk some_path/sdk-installer.sh path_to_shared_http_directory |
| 197 | |
| 198 | You must |
| 199 | repeat this step each time you rebuild the SDK with changes that you |
| 200 | want to make available through the update mechanism. |
| 201 | |
| 202 | Completing the above steps allows users of the existing installed SDKs |
| 203 | to simply run ``devtool sdk-update`` to retrieve and apply the latest |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 204 | updates. See the |
| 205 | ":ref:`sdk-manual/extensible:applying updates to an installed extensible sdk`" |
| 206 | section for further information. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 207 | |
| 208 | Changing the Default SDK Installation Directory |
| 209 | =============================================== |
| 210 | |
| 211 | When you build the installer for the Extensible SDK, the default |
| 212 | installation directory for the SDK is based on the |
| 213 | :term:`DISTRO` and |
| 214 | :term:`SDKEXTPATH` variables from |
| 215 | within the |
| 216 | :ref:`populate_sdk_base <ref-classes-populate-sdk-*>` |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 217 | class as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 218 | |
| 219 | SDKEXTPATH ??= "~/${@d.getVar('DISTRO')}_sdk" |
| 220 | |
| 221 | You can |
| 222 | change this default installation directory by specifically setting the |
| 223 | ``SDKEXTPATH`` variable. |
| 224 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 225 | While there are several ways of setting this variable, |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 226 | the method that makes the most sense is to set the variable in your |
| 227 | distribution's configuration file. Doing so creates an SDK installer |
| 228 | default directory that applies across your distribution. As an example, |
| 229 | assume you have your own layer for your distribution named |
| 230 | "meta-mydistro" and you are using the same type of file hierarchy as |
| 231 | does the default "poky" distribution. If so, you could update the |
| 232 | ``SDKEXTPATH`` variable in the |
| 233 | ``~/meta-mydistro/conf/distro/mydistro.conf`` file using the following |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 234 | form:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 235 | |
| 236 | SDKEXTPATH = "some_path_for_your_installed_sdk" |
| 237 | |
| 238 | After building your installer, running it prompts the user for |
| 239 | acceptance of the some_path_for_your_installed_sdk directory as the |
| 240 | default location to install the Extensible SDK. |
| 241 | |
| 242 | Providing Additional Installable Extensible SDK Content |
| 243 | ======================================================= |
| 244 | |
| 245 | If you want the users of an extensible SDK you build to be able to add |
| 246 | items to the SDK without requiring the users to build the items from |
| 247 | source, you need to do a number of things: |
| 248 | |
| 249 | 1. Ensure the additional items you want the user to be able to install |
| 250 | are already built: |
| 251 | |
| 252 | - Build the items explicitly. You could use one or more "meta" |
| 253 | recipes that depend on lists of other recipes. |
| 254 | |
| 255 | - Build the "world" target and set |
| 256 | ``EXCLUDE_FROM_WORLD_pn-``\ recipename for the recipes you do not |
| 257 | want built. See the |
| 258 | :term:`EXCLUDE_FROM_WORLD` |
| 259 | variable for additional information. |
| 260 | |
| 261 | 2. Expose the ``sstate-cache`` directory produced by the build. |
| 262 | Typically, you expose this directory by making it available through |
| 263 | an `Apache HTTP |
| 264 | Server <https://en.wikipedia.org/wiki/Apache_HTTP_Server>`__ or |
| 265 | `Nginx <https://en.wikipedia.org/wiki/Nginx>`__ server. |
| 266 | |
| 267 | 3. Set the appropriate configuration so that the produced SDK knows how |
| 268 | to find the configuration. The variable you need to set is |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 269 | :term:`SSTATE_MIRRORS`:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 270 | |
| 271 | SSTATE_MIRRORS = "file://.* http://example.com/some_path/sstate-cache/PATH" |
| 272 | |
| 273 | You can set the |
| 274 | ``SSTATE_MIRRORS`` variable in two different places: |
| 275 | |
| 276 | - If the mirror value you are setting is appropriate to be set for |
| 277 | both the OpenEmbedded build system that is actually building the |
| 278 | SDK and the SDK itself (i.e. the mirror is accessible in both |
| 279 | places or it will fail quickly on the OpenEmbedded build system |
| 280 | side, and its contents will not interfere with the build), then |
| 281 | you can set the variable in your ``local.conf`` or custom distro |
| 282 | configuration file. You can then "whitelist" the variable through |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 283 | to the SDK by adding the following:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 284 | |
| 285 | SDK_LOCAL_CONF_WHITELIST = "SSTATE_MIRRORS" |
| 286 | |
| 287 | - Alternatively, if you just want to set the ``SSTATE_MIRRORS`` |
| 288 | variable's value for the SDK alone, create a |
| 289 | ``conf/sdk-extra.conf`` file either in your |
| 290 | :term:`Build Directory` or within any |
| 291 | layer and put your ``SSTATE_MIRRORS`` setting within that file. |
| 292 | |
| 293 | .. note:: |
| 294 | |
| 295 | This second option is the safest option should you have any |
| 296 | doubts as to which method to use when setting |
| 297 | SSTATE_MIRRORS |
| 298 | . |
| 299 | |
| 300 | Minimizing the Size of the Extensible SDK Installer Download |
| 301 | ============================================================ |
| 302 | |
| 303 | By default, the extensible SDK bundles the shared state artifacts for |
| 304 | everything needed to reconstruct the image for which the SDK was built. |
| 305 | This bundling can lead to an SDK installer file that is a Gigabyte or |
| 306 | more in size. If the size of this file causes a problem, you can build |
| 307 | an SDK that has just enough in it to install and provide access to the |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 308 | ``devtool command`` by setting the following in your configuration:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 309 | |
| 310 | SDK_EXT_TYPE = "minimal" |
| 311 | |
| 312 | Setting |
| 313 | :term:`SDK_EXT_TYPE` to |
| 314 | "minimal" produces an SDK installer that is around 35 Mbytes in size, |
| 315 | which downloads and installs quickly. You need to realize, though, that |
| 316 | the minimal installer does not install any libraries or tools out of the |
| 317 | box. These libraries and tools must be installed either "on the fly" or |
| 318 | through actions you perform using ``devtool`` or explicitly with the |
| 319 | ``devtool sdk-install`` command. |
| 320 | |
| 321 | In most cases, when building a minimal SDK you need to also enable |
| 322 | bringing in the information on a wider range of packages produced by the |
| 323 | system. Requiring this wider range of information is particularly true |
| 324 | so that ``devtool add`` is able to effectively map dependencies it |
| 325 | discovers in a source tree to the appropriate recipes. Additionally, the |
| 326 | information enables the ``devtool search`` command to return useful |
| 327 | results. |
| 328 | |
| 329 | To facilitate this wider range of information, you would need to set the |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 330 | following:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 331 | |
| 332 | SDK_INCLUDE_PKGDATA = "1" |
| 333 | |
| 334 | See the :term:`SDK_INCLUDE_PKGDATA` variable for additional information. |
| 335 | |
| 336 | Setting the ``SDK_INCLUDE_PKGDATA`` variable as shown causes the "world" |
| 337 | target to be built so that information for all of the recipes included |
| 338 | within it are available. Having these recipes available increases build |
| 339 | time significantly and increases the size of the SDK installer by 30-80 |
| 340 | Mbytes depending on how many recipes are included in your configuration. |
| 341 | |
| 342 | You can use ``EXCLUDE_FROM_WORLD_pn-``\ recipename for recipes you want |
| 343 | to exclude. However, it is assumed that you would need to be building |
| 344 | the "world" target if you want to provide additional items to the SDK. |
| 345 | Consequently, building for "world" should not represent undue overhead |
| 346 | in most cases. |
| 347 | |
| 348 | .. note:: |
| 349 | |
| 350 | If you set |
| 351 | SDK_EXT_TYPE |
| 352 | to "minimal", then providing a shared state mirror is mandatory so |
| 353 | that items can be installed as needed. See the " |
| 354 | Providing Additional Installable Extensible SDK Content |
| 355 | " section for more information. |
| 356 | |
| 357 | You can explicitly control whether or not to include the toolchain when |
| 358 | you build an SDK by setting the |
| 359 | :term:`SDK_INCLUDE_TOOLCHAIN` |
| 360 | variable to "1". In particular, it is useful to include the toolchain |
| 361 | when you have set ``SDK_EXT_TYPE`` to "minimal", which by default, |
| 362 | excludes the toolchain. Also, it is helpful if you are building a small |
| 363 | SDK for use with an IDE or some other tool where you do not want to take |
| 364 | extra steps to install a toolchain. |