| 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 | Using the Extensible SDK | 
 | 5 | ************************ | 
 | 6 |  | 
 | 7 | This chapter describes the extensible SDK and how to install it. | 
 | 8 | Information covers the pieces of the SDK, how to install it, and | 
 | 9 | presents a look at using the ``devtool`` functionality. The extensible | 
 | 10 | SDK makes it easy to add new applications and libraries to an image, | 
 | 11 | modify the source for an existing component, test changes on the target | 
 | 12 | hardware, and ease integration into the rest of the | 
 | 13 | :term:`OpenEmbedded Build System`. | 
 | 14 |  | 
 | 15 | .. note:: | 
 | 16 |  | 
 | 17 |    For a side-by-side comparison of main features supported for an | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 18 |    extensible SDK as compared to a standard SDK, see the | 
 | 19 |    :ref:`sdk-manual/intro:introduction` section. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 20 |  | 
 | 21 | In addition to the functionality available through ``devtool``, you can | 
 | 22 | alternatively make use of the toolchain directly, for example from | 
| Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 23 | Makefile and Autotools. See the | 
 | 24 | ":ref:`sdk-manual/working-projects:using the sdk toolchain directly`" chapter | 
 | 25 | for more information. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 26 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 27 | Why use the Extensible SDK and What is in It? | 
 | 28 | ============================================= | 
 | 29 |  | 
 | 30 | The extensible SDK provides a cross-development toolchain and libraries | 
 | 31 | tailored to the contents of a specific image. You would use the | 
 | 32 | Extensible SDK if you want a toolchain experience supplemented with the | 
 | 33 | powerful set of ``devtool`` commands tailored for the Yocto Project | 
 | 34 | environment. | 
 | 35 |  | 
 | 36 | The installed extensible SDK consists of several files and directories. | 
 | 37 | Basically, it contains an SDK environment setup script, some | 
 | 38 | configuration files, an internal build system, and the ``devtool`` | 
 | 39 | functionality. | 
 | 40 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 41 | Installing the Extensible SDK | 
 | 42 | ============================= | 
 | 43 |  | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 44 | Two ways to install the Extensible SDK | 
 | 45 | -------------------------------------- | 
 | 46 |  | 
 | 47 | Extensible SDK can be installed in two different ways, and both have | 
 | 48 | their own pros and cons: | 
 | 49 |  | 
 | 50 | 1. *Setting up the Extensible SDK environment directly in a Yocto build*. This | 
 | 51 | avoids having to produce, test, distribute and maintain separate SDK installer | 
 | 52 | archives, which can get very large. There is only one environment for the regular | 
 | 53 | Yocto build and the SDK and less code paths where things can go not according to plan. | 
 | 54 | It's easier to update the SDK: it simply means updating the Yocto layers with | 
 | 55 | git fetch or layer management tooling. The SDK extensibility is better than in the | 
 | 56 | second option: just run ``bitbake`` again to add more things to the sysroot, or add layers | 
 | 57 | if even more things are required. | 
 | 58 |  | 
 | 59 | 2. *Setting up the Extensible SDK from a standalone installer*. This has the benefit of | 
 | 60 | having a single, self-contained archive that includes all the needed binary artifacts. | 
 | 61 | So nothing needs to be rebuilt, and there is no need to provide a well-functioning | 
 | 62 | binary artefact cache over the network for developers with underpowered laptops. | 
 | 63 |  | 
 | 64 | Setting up the Extensible SDK environment directly in a Yocto build | 
 | 65 | ------------------------------------------------------------------- | 
 | 66 |  | 
 | 67 | 1. Set up all the needed layers and a Yocto build directory, e.g. a regular Yocto | 
 | 68 |    build where ``bitbake`` can be executed. | 
 | 69 |  | 
 | 70 | 2. Run: | 
 | 71 |     $ bitbake meta-ide-support | 
 | 72 |     $ bitbake -c populate_sysroot gtk+3 | 
 | 73 |     (or any other target or native item that the application developer would need) | 
 | 74 |     $ bitbake populate-sysroots | 
 | 75 |  | 
 | 76 |  | 
 | 77 | Setting up the Extensible SDK from a standalone installer | 
 | 78 | --------------------------------------------------------- | 
 | 79 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 80 | The first thing you need to do is install the SDK on your :term:`Build | 
 | 81 | Host` by running the ``*.sh`` installation script. | 
 | 82 |  | 
 | 83 | You can download a tarball installer, which includes the pre-built | 
 | 84 | toolchain, the ``runqemu`` script, the internal build system, | 
 | 85 | ``devtool``, and support files from the appropriate | 
| Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 86 | :yocto_dl:`toolchain </releases/yocto/yocto-&DISTRO;/toolchain/>` directory within the Index of | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 87 | Releases. Toolchains are available for several 32-bit and 64-bit | 
 | 88 | architectures with the ``x86_64`` directories, respectively. The | 
 | 89 | toolchains the Yocto Project provides are based off the | 
 | 90 | ``core-image-sato`` and ``core-image-minimal`` images and contain | 
 | 91 | libraries appropriate for developing against that image. | 
 | 92 |  | 
 | 93 | The names of the tarball installer scripts are such that a string | 
 | 94 | representing the host system appears first in the filename and then is | 
 | 95 | immediately followed by a string representing the target architecture. | 
 | 96 | An extensible SDK has the string "-ext" as part of the name. Following | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 97 | is the general form:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 98 |  | 
 | 99 |    poky-glibc-host_system-image_type-arch-toolchain-ext-release_version.sh | 
 | 100 |  | 
 | 101 |    Where: | 
 | 102 |        host_system is a string representing your development system: | 
 | 103 |  | 
 | 104 |                   i686 or x86_64. | 
 | 105 |  | 
 | 106 |        image_type is the image for which the SDK was built: | 
 | 107 |  | 
 | 108 |                   core-image-sato or core-image-minimal | 
 | 109 |  | 
 | 110 |        arch is a string representing the tuned target architecture: | 
 | 111 |  | 
 | 112 |                   aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon | 
 | 113 |  | 
 | 114 |        release_version is a string representing the release number of the Yocto Project: | 
 | 115 |  | 
| Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 116 |                   &DISTRO;, &DISTRO;+snapshot | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 117 |  | 
 | 118 | For example, the following SDK installer is for a 64-bit | 
 | 119 | development host system and a i586-tuned target architecture based off | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 120 | the SDK for ``core-image-sato`` and using the current &DISTRO; snapshot:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 121 |  | 
| Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 122 |    poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 123 |  | 
 | 124 | .. note:: | 
 | 125 |  | 
 | 126 |    As an alternative to downloading an SDK, you can build the SDK | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 127 |    installer. For information on building the installer, see the | 
 | 128 |    :ref:`sdk-manual/appendix-obtain:building an sdk installer` | 
 | 129 |    section. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 130 |  | 
 | 131 | The SDK and toolchains are self-contained and by default are installed | 
 | 132 | into the ``poky_sdk`` folder in your home directory. You can choose to | 
 | 133 | install the extensible SDK in any location when you run the installer. | 
 | 134 | However, because files need to be written under that directory during | 
 | 135 | the normal course of operation, the location you choose for installation | 
 | 136 | must be writable for whichever users need to use the SDK. | 
 | 137 |  | 
 | 138 | The following command shows how to run the installer given a toolchain | 
 | 139 | tarball for a 64-bit x86 development host system and a 64-bit x86 target | 
 | 140 | architecture. The example assumes the SDK installer is located in | 
 | 141 | ``~/Downloads/`` and has execution rights. | 
 | 142 |  | 
 | 143 | .. note:: | 
 | 144 |  | 
 | 145 |    If you do not have write permissions for the directory into which you | 
 | 146 |    are installing the SDK, the installer notifies you and exits. For | 
 | 147 |    that case, set up the proper permissions in the directory and run the | 
 | 148 |    installer again. | 
 | 149 |  | 
 | 150 | :: | 
 | 151 |  | 
 | 152 |    $ ./Downloads/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.5.sh | 
 | 153 |    Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.5 | 
 | 154 |    ========================================================================== | 
| Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 155 |    Enter target directory for SDK (default: poky_sdk): | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 156 |    You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y | 
 | 157 |    Extracting SDK..............done | 
 | 158 |    Setting it up... | 
 | 159 |    Extracting buildtools... | 
 | 160 |    Preparing build system... | 
 | 161 |    Parsing recipes: 100% |##################################################################| Time: 0:00:52 | 
 | 162 |    Initialising tasks: 100% |###############################################################| Time: 0:00:00 | 
 | 163 |    Checking sstate mirror object availability: 100% |#######################################| Time: 0:00:00 | 
 | 164 |    Loading cache: 100% |####################################################################| Time: 0:00:00 | 
 | 165 |    Initialising tasks: 100% |###############################################################| Time: 0:00:00 | 
 | 166 |    done | 
 | 167 |    SDK has been successfully set up and is ready to be used. | 
 | 168 |    Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. | 
 | 169 |     $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux | 
 | 170 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 171 | Running the Extensible SDK Environment Setup Script | 
 | 172 | =================================================== | 
 | 173 |  | 
 | 174 | Once you have the SDK installed, you must run the SDK environment setup | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 175 | script before you can actually use the SDK. | 
 | 176 |  | 
 | 177 | When using a SDK directly in a Yocto build, you will find the script in | 
 | 178 | ``tmp/deploy/images/qemux86-64/`` in your build directory. | 
 | 179 |  | 
 | 180 | When using a standalone SDK installer, this setup script resides in | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 181 | the directory you chose when you installed the SDK, which is either the | 
 | 182 | default ``poky_sdk`` directory or the directory you chose during | 
 | 183 | installation. | 
 | 184 |  | 
 | 185 | Before running the script, be sure it is the one that matches the | 
 | 186 | architecture for which you are developing. Environment setup scripts | 
 | 187 | begin with the string "``environment-setup``" and include as part of | 
 | 188 | their name the tuned target architecture. As an example, the following | 
 | 189 | commands set the working directory to where the SDK was installed and | 
 | 190 | then source the environment setup script. In this example, the setup | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 191 | script is for an IA-based target machine using i586 tuning:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 192 |  | 
 | 193 |    $ cd /home/scottrif/poky_sdk | 
 | 194 |    $ source environment-setup-core2-64-poky-linux | 
 | 195 |    SDK environment now set up; additionally you may now run devtool to perform development tasks. | 
 | 196 |    Run devtool --help for further details. | 
 | 197 |  | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 198 | When using the environment script directly in a Yocto build, it can | 
 | 199 | be run similarly: | 
 | 200 |  | 
 | 201 |    $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux | 
 | 202 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 203 | Running the setup script defines many environment variables needed in | 
 | 204 | order to use the SDK (e.g. ``PATH``, | 
 | 205 | :term:`CC`, | 
 | 206 | :term:`LD`, and so forth). If you want to | 
 | 207 | see all the environment variables the script exports, examine the | 
 | 208 | installation file itself. | 
 | 209 |  | 
 | 210 | Using ``devtool`` in Your SDK Workflow | 
 | 211 | ====================================== | 
 | 212 |  | 
 | 213 | The cornerstone of the extensible SDK is a command-line tool called | 
 | 214 | ``devtool``. This tool provides a number of features that help you | 
 | 215 | build, test and package software within the extensible SDK, and | 
 | 216 | optionally integrate it into an image built by the OpenEmbedded build | 
 | 217 | system. | 
 | 218 |  | 
 | 219 | .. note:: | 
 | 220 |  | 
 | 221 |    The use of | 
 | 222 |    devtool | 
 | 223 |    is not limited to the extensible SDK. You can use | 
 | 224 |    devtool | 
 | 225 |    to help you easily develop any project whose build output must be | 
 | 226 |    part of an image built using the build system. | 
 | 227 |  | 
 | 228 | The ``devtool`` command line is organized similarly to | 
| Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 229 | :ref:`overview-manual/development-environment:git` in that it has a number of | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 230 | sub-commands for each function. You can run ``devtool --help`` to see | 
 | 231 | all the commands. | 
 | 232 |  | 
 | 233 | .. note:: | 
 | 234 |  | 
 | 235 |    See the " | 
 | 236 |    devtool | 
 | 237 |     Quick Reference | 
 | 238 |    " in the Yocto Project Reference Manual for a | 
 | 239 |    devtool | 
 | 240 |    quick reference. | 
 | 241 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 242 | Three ``devtool`` subcommands provide entry-points into | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 243 | development: | 
 | 244 |  | 
 | 245 | -  *devtool add*: Assists in adding new software to be built. | 
 | 246 |  | 
 | 247 | -  *devtool modify*: Sets up an environment to enable you to modify | 
 | 248 |    the source of an existing component. | 
 | 249 |  | 
 | 250 | -  *devtool upgrade*: Updates an existing recipe so that you can | 
 | 251 |    build it for an updated set of source files. | 
 | 252 |  | 
 | 253 | As with the build system, "recipes" represent software packages within | 
 | 254 | ``devtool``. When you use ``devtool add``, a recipe is automatically | 
 | 255 | created. When you use ``devtool modify``, the specified existing recipe | 
 | 256 | is used in order to determine where to get the source code and how to | 
 | 257 | patch it. In both cases, an environment is set up so that when you build | 
 | 258 | the recipe a source tree that is under your control is used in order to | 
 | 259 | allow you to make changes to the source as desired. By default, new | 
 | 260 | recipes and the source go into a "workspace" directory under the SDK. | 
 | 261 |  | 
 | 262 | The remainder of this section presents the ``devtool add``, | 
 | 263 | ``devtool modify``, and ``devtool upgrade`` workflows. | 
 | 264 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 265 | Use ``devtool add`` to Add an Application | 
 | 266 | ----------------------------------------- | 
 | 267 |  | 
 | 268 | The ``devtool add`` command generates a new recipe based on existing | 
 | 269 | source code. This command takes advantage of the | 
 | 270 | :ref:`devtool-the-workspace-layer-structure` | 
 | 271 | layer that many ``devtool`` commands use. The command is flexible enough | 
 | 272 | to allow you to extract source code into both the workspace or a | 
 | 273 | separate local Git repository and to use existing code that does not | 
 | 274 | need to be extracted. | 
 | 275 |  | 
 | 276 | Depending on your particular scenario, the arguments and options you use | 
 | 277 | with ``devtool add`` form different combinations. The following diagram | 
 | 278 | shows common development flows you would use with the ``devtool add`` | 
 | 279 | command: | 
 | 280 |  | 
 | 281 | .. image:: figures/sdk-devtool-add-flow.png | 
| Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 282 |    :width: 100% | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 283 |  | 
 | 284 | 1. *Generating the New Recipe*: The top part of the flow shows three | 
 | 285 |    scenarios by which you could use ``devtool add`` to generate a recipe | 
 | 286 |    based on existing source code. | 
 | 287 |  | 
 | 288 |    In a shared development environment, it is typical for other | 
 | 289 |    developers to be responsible for various areas of source code. As a | 
 | 290 |    developer, you are probably interested in using that source code as | 
 | 291 |    part of your development within the Yocto Project. All you need is | 
 | 292 |    access to the code, a recipe, and a controlled area in which to do | 
 | 293 |    your work. | 
 | 294 |  | 
 | 295 |    Within the diagram, three possible scenarios feed into the | 
 | 296 |    ``devtool add`` workflow: | 
 | 297 |  | 
 | 298 |    -  *Left*: The left scenario in the figure represents a common | 
 | 299 |       situation where the source code does not exist locally and needs | 
 | 300 |       to be extracted. In this situation, the source code is extracted | 
| Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 301 |       to the default workspace --- you do not want the files in some | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 302 |       specific location outside of the workspace. Thus, everything you | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 303 |       need will be located in the workspace:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 304 |  | 
 | 305 |          $ devtool add recipe fetchuri | 
 | 306 |  | 
 | 307 |       With this command, ``devtool`` extracts the upstream | 
 | 308 |       source files into a local Git repository within the ``sources`` | 
 | 309 |       folder. The command then creates a recipe named recipe and a | 
 | 310 |       corresponding append file in the workspace. If you do not provide | 
 | 311 |       recipe, the command makes an attempt to determine the recipe name. | 
 | 312 |  | 
 | 313 |    -  *Middle*: The middle scenario in the figure also represents a | 
 | 314 |       situation where the source code does not exist locally. In this | 
 | 315 |       case, the code is again upstream and needs to be extracted to some | 
| Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 316 |       local area --- this time outside of the default workspace. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 317 |  | 
 | 318 |       .. note:: | 
 | 319 |  | 
 | 320 |          If required, | 
 | 321 |          devtool | 
 | 322 |          always creates a Git repository locally during the extraction. | 
 | 323 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 324 |       Furthermore, the first positional argument ``srctree`` in this case | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 325 |       identifies where the ``devtool add`` command will locate the | 
 | 326 |       extracted code outside of the workspace. You need to specify an | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 327 |       empty directory:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 328 |  | 
 | 329 |          $ devtool add recipe srctree fetchuri | 
 | 330 |  | 
 | 331 |       In summary, | 
 | 332 |       the source code is pulled from fetchuri and extracted into the | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 333 |       location defined by ``srctree`` as a local Git repository. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 334 |  | 
 | 335 |       Within workspace, ``devtool`` creates a recipe named recipe along | 
 | 336 |       with an associated append file. | 
 | 337 |  | 
 | 338 |    -  *Right*: The right scenario in the figure represents a situation | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 339 |       where the ``srctree`` has been previously prepared outside of the | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 340 |       ``devtool`` workspace. | 
 | 341 |  | 
 | 342 |       The following command provides a new recipe name and identifies | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 343 |       the existing source tree location:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 344 |  | 
 | 345 |          $ devtool add recipe srctree | 
 | 346 |  | 
 | 347 |       The command examines the source code and creates a recipe named | 
 | 348 |       recipe for the code and places the recipe into the workspace. | 
 | 349 |  | 
 | 350 |       Because the extracted source code already exists, ``devtool`` does | 
| Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 351 |       not try to relocate the source code into the workspace --- only the | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 352 |       new recipe is placed in the workspace. | 
 | 353 |  | 
 | 354 |       Aside from a recipe folder, the command also creates an associated | 
 | 355 |       append folder and places an initial ``*.bbappend`` file within. | 
 | 356 |  | 
 | 357 | 2. *Edit the Recipe*: You can use ``devtool edit-recipe`` to open up the | 
 | 358 |    editor as defined by the ``$EDITOR`` environment variable and modify | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 359 |    the file:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 360 |  | 
 | 361 |       $ devtool edit-recipe recipe | 
 | 362 |  | 
 | 363 |    From within the editor, you | 
| Andrew Geissler | 595f630 | 2022-01-24 19:11:47 +0000 | [diff] [blame] | 364 |    can make modifications to the recipe that take effect when you build | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 365 |    it later. | 
 | 366 |  | 
 | 367 | 3. *Build the Recipe or Rebuild the Image*: The next step you take | 
 | 368 |    depends on what you are going to do with the new code. | 
 | 369 |  | 
 | 370 |    If you need to eventually move the build output to the target | 
 | 371 |    hardware, use the following ``devtool`` command: | 
 | 372 |    :; | 
 | 373 |  | 
 | 374 |       $ devtool build recipe | 
 | 375 |  | 
 | 376 |    On the other hand, if you want an image to contain the recipe's | 
 | 377 |    packages from the workspace for immediate deployment onto a device | 
 | 378 |    (e.g. for testing purposes), you can use the ``devtool build-image`` | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 379 |    command:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 380 |  | 
 | 381 |       $ devtool build-image image | 
 | 382 |  | 
 | 383 | 4. *Deploy the Build Output*: When you use the ``devtool build`` command | 
 | 384 |    to build out your recipe, you probably want to see if the resulting | 
 | 385 |    build output works as expected on the target hardware. | 
 | 386 |  | 
 | 387 |    .. note:: | 
 | 388 |  | 
 | 389 |       This step assumes you have a previously built image that is | 
 | 390 |       already either running in QEMU or is running on actual hardware. | 
 | 391 |       Also, it is assumed that for deployment of the image to the | 
 | 392 |       target, SSH is installed in the image and, if the image is running | 
 | 393 |       on real hardware, you have network access to and from your | 
 | 394 |       development machine. | 
 | 395 |  | 
 | 396 |    You can deploy your build output to that target hardware by using the | 
 | 397 |    ``devtool deploy-target`` command: $ devtool deploy-target recipe | 
 | 398 |    target The target is a live target machine running as an SSH server. | 
 | 399 |  | 
 | 400 |    You can, of course, also deploy the image you build to actual | 
 | 401 |    hardware by using the ``devtool build-image`` command. However, | 
 | 402 |    ``devtool`` does not provide a specific command that allows you to | 
 | 403 |    deploy the image to actual hardware. | 
 | 404 |  | 
 | 405 | 5. *Finish Your Work With the Recipe*: The ``devtool finish`` command | 
 | 406 |    creates any patches corresponding to commits in the local Git | 
 | 407 |    repository, moves the new recipe to a more permanent layer, and then | 
 | 408 |    resets the recipe so that the recipe is built normally rather than | 
 | 409 |    from the workspace. | 
 | 410 |    :: | 
 | 411 |  | 
 | 412 |       $ devtool finish recipe layer | 
 | 413 |  | 
 | 414 |    .. note:: | 
 | 415 |  | 
 | 416 |       Any changes you want to turn into patches must be committed to the | 
 | 417 |       Git repository in the source tree. | 
 | 418 |  | 
 | 419 |    As mentioned, the ``devtool finish`` command moves the final recipe | 
 | 420 |    to its permanent layer. | 
 | 421 |  | 
 | 422 |    As a final process of the ``devtool finish`` command, the state of | 
 | 423 |    the standard layers and the upstream source is restored so that you | 
 | 424 |    can build the recipe from those areas rather than the workspace. | 
 | 425 |  | 
 | 426 |    .. note:: | 
 | 427 |  | 
 | 428 |       You can use the | 
 | 429 |       devtool reset | 
 | 430 |       command to put things back should you decide you do not want to | 
 | 431 |       proceed with your work. If you do use this command, realize that | 
 | 432 |       the source tree is preserved. | 
 | 433 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 434 | Use ``devtool modify`` to Modify the Source of an Existing Component | 
 | 435 | -------------------------------------------------------------------- | 
 | 436 |  | 
 | 437 | The ``devtool modify`` command prepares the way to work on existing code | 
 | 438 | that already has a local recipe in place that is used to build the | 
 | 439 | software. The command is flexible enough to allow you to extract code | 
 | 440 | from an upstream source, specify the existing recipe, and keep track of | 
 | 441 | and gather any patch files from other developers that are associated | 
 | 442 | with the code. | 
 | 443 |  | 
 | 444 | Depending on your particular scenario, the arguments and options you use | 
 | 445 | with ``devtool modify`` form different combinations. The following | 
 | 446 | diagram shows common development flows for the ``devtool modify`` | 
 | 447 | command: | 
 | 448 |  | 
 | 449 | .. image:: figures/sdk-devtool-modify-flow.png | 
| Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 450 |    :width: 100% | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 451 |  | 
 | 452 | 1. *Preparing to Modify the Code*: The top part of the flow shows three | 
 | 453 |    scenarios by which you could use ``devtool modify`` to prepare to | 
 | 454 |    work on source files. Each scenario assumes the following: | 
 | 455 |  | 
 | 456 |    -  The recipe exists locally in a layer external to the ``devtool`` | 
 | 457 |       workspace. | 
 | 458 |  | 
 | 459 |    -  The source files exist either upstream in an un-extracted state or | 
 | 460 |       locally in a previously extracted state. | 
 | 461 |  | 
 | 462 |    The typical situation is where another developer has created a layer | 
 | 463 |    for use with the Yocto Project and their recipe already resides in | 
 | 464 |    that layer. Furthermore, their source code is readily available | 
 | 465 |    either upstream or locally. | 
 | 466 |  | 
 | 467 |    -  *Left*: The left scenario in the figure represents a common | 
 | 468 |       situation where the source code does not exist locally and it | 
 | 469 |       needs to be extracted from an upstream source. In this situation, | 
 | 470 |       the source is extracted into the default ``devtool`` workspace | 
 | 471 |       location. The recipe, in this scenario, is in its own layer | 
 | 472 |       outside the workspace (i.e. ``meta-``\ layername). | 
 | 473 |  | 
 | 474 |       The following command identifies the recipe and, by default, | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 475 |       extracts the source files:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 476 |  | 
 | 477 |          $ devtool modify recipe | 
 | 478 |  | 
 | 479 |       Once | 
 | 480 |       ``devtool``\ locates the recipe, ``devtool`` uses the recipe's | 
 | 481 |       :term:`SRC_URI` statements to | 
 | 482 |       locate the source code and any local patch files from other | 
 | 483 |       developers. | 
 | 484 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 485 |       With this scenario, there is no ``srctree`` argument. Consequently, the | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 486 |       default behavior of the ``devtool modify`` command is to extract | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 487 |       the source files pointed to by the :term:`SRC_URI` statements into a | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 488 |       local Git structure. Furthermore, the location for the extracted | 
 | 489 |       source is the default area within the ``devtool`` workspace. The | 
 | 490 |       result is that the command sets up both the source code and an | 
 | 491 |       append file within the workspace while the recipe remains in its | 
 | 492 |       original location. | 
 | 493 |  | 
 | 494 |       Additionally, if you have any non-patch local files (i.e. files | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 495 |       referred to with ``file://`` entries in :term:`SRC_URI` statement | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 496 |       excluding ``*.patch/`` or ``*.diff``), these files are copied to | 
 | 497 |       an ``oe-local-files`` folder under the newly created source tree. | 
 | 498 |       Copying the files here gives you a convenient area from which you | 
 | 499 |       can modify the files. Any changes or additions you make to those | 
 | 500 |       files are incorporated into the build the next time you build the | 
 | 501 |       software just as are other changes you might have made to the | 
 | 502 |       source. | 
 | 503 |  | 
 | 504 |    -  *Middle*: The middle scenario in the figure represents a situation | 
 | 505 |       where the source code also does not exist locally. In this case, | 
 | 506 |       the code is again upstream and needs to be extracted to some local | 
 | 507 |       area as a Git repository. The recipe, in this scenario, is again | 
 | 508 |       local and in its own layer outside the workspace. | 
 | 509 |  | 
 | 510 |       The following command tells ``devtool`` the recipe with which to | 
 | 511 |       work and, in this case, identifies a local area for the extracted | 
 | 512 |       source files that exists outside of the default ``devtool`` | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 513 |       workspace:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 514 |  | 
 | 515 |          $ devtool modify recipe srctree | 
 | 516 |  | 
 | 517 |       .. note:: | 
 | 518 |  | 
 | 519 |          You cannot provide a URL for | 
 | 520 |          srctree | 
 | 521 |          using the | 
 | 522 |          devtool | 
 | 523 |          command. | 
 | 524 |  | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 525 |       As with all extractions, the command uses the recipe's :term:`SRC_URI` | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 526 |       statements to locate the source files and any associated patch | 
 | 527 |       files. Non-patch files are copied to an ``oe-local-files`` folder | 
 | 528 |       under the newly created source tree. | 
 | 529 |  | 
 | 530 |       Once the files are located, the command by default extracts them | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 531 |       into ``srctree``. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 532 |  | 
 | 533 |       Within workspace, ``devtool`` creates an append file for the | 
 | 534 |       recipe. The recipe remains in its original location but the source | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 535 |       files are extracted to the location you provide with ``srctree``. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 536 |  | 
 | 537 |    -  *Right*: The right scenario in the figure represents a situation | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 538 |       where the source tree (``srctree``) already exists locally as a | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 539 |       previously extracted Git structure outside of the ``devtool`` | 
 | 540 |       workspace. In this example, the recipe also exists elsewhere | 
 | 541 |       locally in its own layer. | 
 | 542 |  | 
 | 543 |       The following command tells ``devtool`` the recipe with which to | 
 | 544 |       work, uses the "-n" option to indicate source does not need to be | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 545 |       extracted, and uses ``srctree`` to point to the previously extracted | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 546 |       source files:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 547 |  | 
 | 548 |          $ devtool modify -n recipe srctree | 
 | 549 |  | 
 | 550 |       If an ``oe-local-files`` subdirectory happens to exist and it | 
 | 551 |       contains non-patch files, the files are used. However, if the | 
 | 552 |       subdirectory does not exist and you run the ``devtool finish`` | 
 | 553 |       command, any non-patch files that might exist next to the recipe | 
 | 554 |       are removed because it appears to ``devtool`` that you have | 
 | 555 |       deleted those files. | 
 | 556 |  | 
 | 557 |       Once the ``devtool modify`` command finishes, it creates only an | 
 | 558 |       append file for the recipe in the ``devtool`` workspace. The | 
 | 559 |       recipe and the source code remain in their original locations. | 
 | 560 |  | 
 | 561 | 2. *Edit the Source*: Once you have used the ``devtool modify`` command, | 
 | 562 |    you are free to make changes to the source files. You can use any | 
 | 563 |    editor you like to make and save your source code modifications. | 
 | 564 |  | 
 | 565 | 3. *Build the Recipe or Rebuild the Image*: The next step you take | 
 | 566 |    depends on what you are going to do with the new code. | 
 | 567 |  | 
 | 568 |    If you need to eventually move the build output to the target | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 569 |    hardware, use the following ``devtool`` command:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 570 |  | 
 | 571 |       $ devtool build recipe | 
 | 572 |  | 
 | 573 |    On the other hand, if you want an image to contain the recipe's | 
 | 574 |    packages from the workspace for immediate deployment onto a device | 
 | 575 |    (e.g. for testing purposes), you can use the ``devtool build-image`` | 
 | 576 |    command: $ devtool build-image image | 
 | 577 |  | 
 | 578 | 4. *Deploy the Build Output*: When you use the ``devtool build`` command | 
 | 579 |    to build out your recipe, you probably want to see if the resulting | 
 | 580 |    build output works as expected on target hardware. | 
 | 581 |  | 
 | 582 |    .. note:: | 
 | 583 |  | 
 | 584 |       This step assumes you have a previously built image that is | 
 | 585 |       already either running in QEMU or running on actual hardware. | 
 | 586 |       Also, it is assumed that for deployment of the image to the | 
 | 587 |       target, SSH is installed in the image and if the image is running | 
 | 588 |       on real hardware that you have network access to and from your | 
 | 589 |       development machine. | 
 | 590 |  | 
 | 591 |    You can deploy your build output to that target hardware by using the | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 592 |    ``devtool deploy-target`` command:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 593 |  | 
 | 594 |       $ devtool deploy-target recipe target | 
 | 595 |  | 
 | 596 |    The target is a live target machine running as an SSH server. | 
 | 597 |  | 
 | 598 |    You can, of course, use other methods to deploy the image you built | 
 | 599 |    using the ``devtool build-image`` command to actual hardware. | 
 | 600 |    ``devtool`` does not provide a specific command to deploy the image | 
 | 601 |    to actual hardware. | 
 | 602 |  | 
 | 603 | 5. *Finish Your Work With the Recipe*: The ``devtool finish`` command | 
 | 604 |    creates any patches corresponding to commits in the local Git | 
 | 605 |    repository, updates the recipe to point to them (or creates a | 
 | 606 |    ``.bbappend`` file to do so, depending on the specified destination | 
 | 607 |    layer), and then resets the recipe so that the recipe is built | 
 | 608 |    normally rather than from the workspace. | 
 | 609 |    :: | 
 | 610 |  | 
 | 611 |       $ devtool finish recipe layer | 
 | 612 |  | 
 | 613 |    .. note:: | 
 | 614 |  | 
 | 615 |       Any changes you want to turn into patches must be staged and | 
 | 616 |       committed within the local Git repository before you use the | 
 | 617 |       devtool finish | 
 | 618 |       command. | 
 | 619 |  | 
 | 620 |    Because there is no need to move the recipe, ``devtool finish`` | 
 | 621 |    either updates the original recipe in the original layer or the | 
 | 622 |    command creates a ``.bbappend`` file in a different layer as provided | 
 | 623 |    by layer. Any work you did in the ``oe-local-files`` directory is | 
 | 624 |    preserved in the original files next to the recipe during the | 
 | 625 |    ``devtool finish`` command. | 
 | 626 |  | 
 | 627 |    As a final process of the ``devtool finish`` command, the state of | 
 | 628 |    the standard layers and the upstream source is restored so that you | 
 | 629 |    can build the recipe from those areas rather than from the workspace. | 
 | 630 |  | 
 | 631 |    .. note:: | 
 | 632 |  | 
 | 633 |       You can use the | 
 | 634 |       devtool reset | 
 | 635 |       command to put things back should you decide you do not want to | 
 | 636 |       proceed with your work. If you do use this command, realize that | 
 | 637 |       the source tree is preserved. | 
 | 638 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 639 | Use ``devtool upgrade`` to Create a Version of the Recipe that Supports a Newer Version of the Software | 
 | 640 | ------------------------------------------------------------------------------------------------------- | 
 | 641 |  | 
 | 642 | The ``devtool upgrade`` command upgrades an existing recipe to that of a | 
 | 643 | more up-to-date version found upstream. Throughout the life of software, | 
 | 644 | recipes continually undergo version upgrades by their upstream | 
 | 645 | publishers. You can use the ``devtool upgrade`` workflow to make sure | 
 | 646 | your recipes you are using for builds are up-to-date with their upstream | 
 | 647 | counterparts. | 
 | 648 |  | 
 | 649 | .. note:: | 
 | 650 |  | 
 | 651 |    Several methods exist by which you can upgrade recipes - | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 652 |    ``devtool upgrade`` | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 653 |    happens to be one. You can read about all the methods by which you | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 654 |    can upgrade recipes in the | 
 | 655 |    :ref:`dev-manual/common-tasks:upgrading recipes` section | 
 | 656 |    of the Yocto Project Development Tasks Manual. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 657 |  | 
 | 658 | The ``devtool upgrade`` command is flexible enough to allow you to | 
 | 659 | specify source code revision and versioning schemes, extract code into | 
 | 660 | or out of the ``devtool`` | 
 | 661 | :ref:`devtool-the-workspace-layer-structure`, | 
 | 662 | and work with any source file forms that the | 
| Patrick Williams | 213cb26 | 2021-08-07 19:21:33 -0500 | [diff] [blame] | 663 | :ref:`bitbake:bitbake-user-manual/bitbake-user-manual-fetching:fetchers` support. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 664 |  | 
 | 665 | The following diagram shows the common development flow used with the | 
 | 666 | ``devtool upgrade`` command: | 
 | 667 |  | 
 | 668 | .. image:: figures/sdk-devtool-upgrade-flow.png | 
| Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 669 |    :width: 100% | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 670 |  | 
 | 671 | 1. *Initiate the Upgrade*: The top part of the flow shows the typical | 
 | 672 |    scenario by which you use the ``devtool upgrade`` command. The | 
 | 673 |    following conditions exist: | 
 | 674 |  | 
 | 675 |    -  The recipe exists in a local layer external to the ``devtool`` | 
 | 676 |       workspace. | 
 | 677 |  | 
 | 678 |    -  The source files for the new release exist in the same location | 
 | 679 |       pointed to by :term:`SRC_URI` | 
 | 680 |       in the recipe (e.g. a tarball with the new version number in the | 
 | 681 |       name, or as a different revision in the upstream Git repository). | 
 | 682 |  | 
 | 683 |    A common situation is where third-party software has undergone a | 
 | 684 |    revision so that it has been upgraded. The recipe you have access to | 
 | 685 |    is likely in your own layer. Thus, you need to upgrade the recipe to | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 686 |    use the newer version of the software:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 687 |  | 
 | 688 |       $ devtool upgrade -V version recipe | 
 | 689 |  | 
 | 690 |    By default, the ``devtool upgrade`` command extracts source | 
 | 691 |    code into the ``sources`` directory in the | 
 | 692 |    :ref:`devtool-the-workspace-layer-structure`. | 
 | 693 |    If you want the code extracted to any other location, you need to | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 694 |    provide the ``srctree`` positional argument with the command as follows:: | 
 | 695 |  | 
 | 696 |       $ devtool upgrade -V version recipe srctree | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 697 |  | 
 | 698 |    .. note:: | 
 | 699 |  | 
 | 700 |       In this example, the "-V" option specifies the new version. If you | 
 | 701 |       don't use "-V", the command upgrades the recipe to the latest | 
 | 702 |       version. | 
 | 703 |  | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 704 |    If the source files pointed to by the :term:`SRC_URI` statement in the | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 705 |    recipe are in a Git repository, you must provide the "-S" option and | 
 | 706 |    specify a revision for the software. | 
 | 707 |  | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 708 |    Once ``devtool`` locates the recipe, it uses the :term:`SRC_URI` variable | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 709 |    to locate the source code and any local patch files from other | 
 | 710 |    developers. The result is that the command sets up the source code, | 
 | 711 |    the new version of the recipe, and an append file all within the | 
 | 712 |    workspace. | 
 | 713 |  | 
 | 714 |    Additionally, if you have any non-patch local files (i.e. files | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 715 |    referred to with ``file://`` entries in :term:`SRC_URI` statement | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 716 |    excluding ``*.patch/`` or ``*.diff``), these files are copied to an | 
 | 717 |    ``oe-local-files`` folder under the newly created source tree. | 
 | 718 |    Copying the files here gives you a convenient area from which you can | 
 | 719 |    modify the files. Any changes or additions you make to those files | 
 | 720 |    are incorporated into the build the next time you build the software | 
 | 721 |    just as are other changes you might have made to the source. | 
 | 722 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 723 | 2. *Resolve any Conflicts created by the Upgrade*: Conflicts could happen | 
 | 724 |    after upgrading the software to a new version. Conflicts occur | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 725 |    if your recipe specifies some patch files in :term:`SRC_URI` that | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 726 |    conflict with changes made in the new version of the software. For | 
 | 727 |    such cases, you need to resolve the conflicts by editing the source | 
 | 728 |    and following the normal ``git rebase`` conflict resolution process. | 
 | 729 |  | 
 | 730 |    Before moving onto the next step, be sure to resolve any such | 
 | 731 |    conflicts created through use of a newer or different version of the | 
 | 732 |    software. | 
 | 733 |  | 
 | 734 | 3. *Build the Recipe or Rebuild the Image*: The next step you take | 
 | 735 |    depends on what you are going to do with the new code. | 
 | 736 |  | 
 | 737 |    If you need to eventually move the build output to the target | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 738 |    hardware, use the following ``devtool`` command:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 739 |  | 
 | 740 |       $ devtool build recipe | 
 | 741 |  | 
 | 742 |    On the other hand, if you want an image to contain the recipe's | 
 | 743 |    packages from the workspace for immediate deployment onto a device | 
 | 744 |    (e.g. for testing purposes), you can use the ``devtool build-image`` | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 745 |    command:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 746 |  | 
 | 747 |       $ devtool build-image image | 
 | 748 |  | 
 | 749 | 4. *Deploy the Build Output*: When you use the ``devtool build`` command | 
 | 750 |    or ``bitbake`` to build your recipe, you probably want to see if the | 
 | 751 |    resulting build output works as expected on target hardware. | 
 | 752 |  | 
 | 753 |    .. note:: | 
 | 754 |  | 
 | 755 |       This step assumes you have a previously built image that is | 
 | 756 |       already either running in QEMU or running on actual hardware. | 
 | 757 |       Also, it is assumed that for deployment of the image to the | 
 | 758 |       target, SSH is installed in the image and if the image is running | 
 | 759 |       on real hardware that you have network access to and from your | 
 | 760 |       development machine. | 
 | 761 |  | 
 | 762 |    You can deploy your build output to that target hardware by using the | 
 | 763 |    ``devtool deploy-target`` command: $ devtool deploy-target recipe | 
 | 764 |    target The target is a live target machine running as an SSH server. | 
 | 765 |  | 
 | 766 |    You can, of course, also deploy the image you build using the | 
 | 767 |    ``devtool build-image`` command to actual hardware. However, | 
 | 768 |    ``devtool`` does not provide a specific command that allows you to do | 
 | 769 |    this. | 
 | 770 |  | 
 | 771 | 5. *Finish Your Work With the Recipe*: The ``devtool finish`` command | 
 | 772 |    creates any patches corresponding to commits in the local Git | 
 | 773 |    repository, moves the new recipe to a more permanent layer, and then | 
 | 774 |    resets the recipe so that the recipe is built normally rather than | 
 | 775 |    from the workspace. | 
 | 776 |  | 
 | 777 |    Any work you did in the ``oe-local-files`` directory is preserved in | 
 | 778 |    the original files next to the recipe during the ``devtool finish`` | 
 | 779 |    command. | 
 | 780 |  | 
 | 781 |    If you specify a destination layer that is the same as the original | 
 | 782 |    source, then the old version of the recipe and associated files are | 
 | 783 |    removed prior to adding the new version. | 
 | 784 |    :: | 
 | 785 |  | 
 | 786 |       $ devtool finish recipe layer | 
 | 787 |  | 
 | 788 |    .. note:: | 
 | 789 |  | 
 | 790 |       Any changes you want to turn into patches must be committed to the | 
 | 791 |       Git repository in the source tree. | 
 | 792 |  | 
 | 793 |    As a final process of the ``devtool finish`` command, the state of | 
 | 794 |    the standard layers and the upstream source is restored so that you | 
 | 795 |    can build the recipe from those areas rather than the workspace. | 
 | 796 |  | 
 | 797 |    .. note:: | 
 | 798 |  | 
 | 799 |       You can use the | 
 | 800 |       devtool reset | 
 | 801 |       command to put things back should you decide you do not want to | 
 | 802 |       proceed with your work. If you do use this command, realize that | 
 | 803 |       the source tree is preserved. | 
 | 804 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 805 | A Closer Look at ``devtool add`` | 
 | 806 | ================================ | 
 | 807 |  | 
 | 808 | The ``devtool add`` command automatically creates a recipe based on the | 
 | 809 | source tree you provide with the command. Currently, the command has | 
 | 810 | support for the following: | 
 | 811 |  | 
 | 812 | -  Autotools (``autoconf`` and ``automake``) | 
 | 813 |  | 
 | 814 | -  CMake | 
 | 815 |  | 
 | 816 | -  Scons | 
 | 817 |  | 
 | 818 | -  ``qmake`` | 
 | 819 |  | 
 | 820 | -  Plain ``Makefile`` | 
 | 821 |  | 
 | 822 | -  Out-of-tree kernel module | 
 | 823 |  | 
 | 824 | -  Binary package (i.e. "-b" option) | 
 | 825 |  | 
 | 826 | -  Node.js module | 
 | 827 |  | 
 | 828 | -  Python modules that use ``setuptools`` or ``distutils`` | 
 | 829 |  | 
 | 830 | Apart from binary packages, the determination of how a source tree | 
 | 831 | should be treated is automatic based on the files present within that | 
 | 832 | source tree. For example, if a ``CMakeLists.txt`` file is found, then | 
 | 833 | the source tree is assumed to be using CMake and is treated accordingly. | 
 | 834 |  | 
 | 835 | .. note:: | 
 | 836 |  | 
 | 837 |    In most cases, you need to edit the automatically generated recipe in | 
 | 838 |    order to make it build properly. Typically, you would go through | 
 | 839 |    several edit and build cycles until the recipe successfully builds. | 
 | 840 |    Once the recipe builds, you could use possible further iterations to | 
 | 841 |    test the recipe on the target device. | 
 | 842 |  | 
 | 843 | The remainder of this section covers specifics regarding how parts of | 
 | 844 | the recipe are generated. | 
 | 845 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 846 | Name and Version | 
 | 847 | ---------------- | 
 | 848 |  | 
 | 849 | If you do not specify a name and version on the command line, | 
 | 850 | ``devtool add`` uses various metadata within the source tree in an | 
 | 851 | attempt to determine the name and version of the software being built. | 
 | 852 | Based on what the tool determines, ``devtool`` sets the name of the | 
 | 853 | created recipe file accordingly. | 
 | 854 |  | 
 | 855 | If ``devtool`` cannot determine the name and version, the command prints | 
 | 856 | an error. For such cases, you must re-run the command and provide the | 
 | 857 | name and version, just the name, or just the version as part of the | 
 | 858 | command line. | 
 | 859 |  | 
 | 860 | Sometimes the name or version determined from the source tree might be | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 861 | incorrect. For such a case, you must reset the recipe:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 862 |  | 
 | 863 |    $ devtool reset -n recipename | 
 | 864 |  | 
 | 865 | After running the ``devtool reset`` command, you need to | 
 | 866 | run ``devtool add`` again and provide the name or the version. | 
 | 867 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 868 | Dependency Detection and Mapping | 
 | 869 | -------------------------------- | 
 | 870 |  | 
 | 871 | The ``devtool add`` command attempts to detect build-time dependencies | 
 | 872 | and map them to other recipes in the system. During this mapping, the | 
 | 873 | command fills in the names of those recipes as part of the | 
 | 874 | :term:`DEPENDS` variable within the | 
 | 875 | recipe. If a dependency cannot be mapped, ``devtool`` places a comment | 
 | 876 | in the recipe indicating such. The inability to map a dependency can | 
 | 877 | result from naming not being recognized or because the dependency simply | 
 | 878 | is not available. For cases where the dependency is not available, you | 
 | 879 | must use the ``devtool add`` command to add an additional recipe that | 
 | 880 | satisfies the dependency. Once you add that recipe, you need to update | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 881 | the :term:`DEPENDS` variable in the original recipe to include the new | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 882 | recipe. | 
 | 883 |  | 
 | 884 | If you need to add runtime dependencies, you can do so by adding the | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 885 | following to your recipe:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 886 |  | 
| Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 887 |    RDEPENDS:${PN} += "dependency1 dependency2 ..." | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 888 |  | 
 | 889 | .. note:: | 
 | 890 |  | 
 | 891 |    The | 
 | 892 |    devtool add | 
 | 893 |    command often cannot distinguish between mandatory and optional | 
 | 894 |    dependencies. Consequently, some of the detected dependencies might | 
 | 895 |    in fact be optional. When in doubt, consult the documentation or the | 
 | 896 |    configure script for the software the recipe is building for further | 
 | 897 |    details. In some cases, you might find you can substitute the | 
 | 898 |    dependency with an option that disables the associated functionality | 
 | 899 |    passed to the configure script. | 
 | 900 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 901 | License Detection | 
 | 902 | ----------------- | 
 | 903 |  | 
 | 904 | The ``devtool add`` command attempts to determine if the software you | 
 | 905 | are adding is able to be distributed under a common, open-source | 
 | 906 | license. If so, the command sets the | 
 | 907 | :term:`LICENSE` value accordingly. | 
 | 908 | You should double-check the value added by the command against the | 
 | 909 | documentation or source files for the software you are building and, if | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 910 | necessary, update that :term:`LICENSE` value. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 911 |  | 
 | 912 | The ``devtool add`` command also sets the | 
 | 913 | :term:`LIC_FILES_CHKSUM` | 
 | 914 | value to point to all files that appear to be license-related. Realize | 
 | 915 | that license statements often appear in comments at the top of source | 
 | 916 | files or within the documentation. In such cases, the command does not | 
 | 917 | recognize those license statements. Consequently, you might need to | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 918 | amend the :term:`LIC_FILES_CHKSUM` variable to point to one or more of those | 
 | 919 | comments if present. Setting :term:`LIC_FILES_CHKSUM` is particularly | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 920 | important for third-party software. The mechanism attempts to ensure | 
 | 921 | correct licensing should you upgrade the recipe to a newer upstream | 
 | 922 | version in future. Any change in licensing is detected and you receive | 
 | 923 | an error prompting you to check the license text again. | 
 | 924 |  | 
 | 925 | If the ``devtool add`` command cannot determine licensing information, | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 926 | ``devtool`` sets the :term:`LICENSE` value to "CLOSED" and leaves the | 
 | 927 | :term:`LIC_FILES_CHKSUM` value unset. This behavior allows you to continue | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 928 | with development even though the settings are unlikely to be correct in | 
 | 929 | all cases. You should check the documentation or source files for the | 
 | 930 | software you are building to determine the actual license. | 
 | 931 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 932 | Adding Makefile-Only Software | 
 | 933 | ----------------------------- | 
 | 934 |  | 
 | 935 | The use of Make by itself is very common in both proprietary and | 
 | 936 | open-source software. Unfortunately, Makefiles are often not written | 
 | 937 | with cross-compilation in mind. Thus, ``devtool add`` often cannot do | 
 | 938 | very much to ensure that these Makefiles build correctly. It is very | 
 | 939 | common, for example, to explicitly call ``gcc`` instead of using the | 
 | 940 | :term:`CC` variable. Usually, in a | 
 | 941 | cross-compilation environment, ``gcc`` is the compiler for the build | 
 | 942 | host and the cross-compiler is named something similar to | 
 | 943 | ``arm-poky-linux-gnueabi-gcc`` and might require arguments (e.g. to | 
 | 944 | point to the associated sysroot for the target machine). | 
 | 945 |  | 
 | 946 | When writing a recipe for Makefile-only software, keep the following in | 
 | 947 | mind: | 
 | 948 |  | 
 | 949 | -  You probably need to patch the Makefile to use variables instead of | 
 | 950 |    hardcoding tools within the toolchain such as ``gcc`` and ``g++``. | 
 | 951 |  | 
 | 952 | -  The environment in which Make runs is set up with various standard | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 953 |    variables for compilation (e.g. :term:`CC`, :term:`CXX`, and so forth) in a | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 954 |    similar manner to the environment set up by the SDK's environment | 
 | 955 |    setup script. One easy way to see these variables is to run the | 
 | 956 |    ``devtool build`` command on the recipe and then look in | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 957 |    ``oe-logs/run.do_compile``. Towards the top of this file, there is | 
 | 958 |    a list of environment variables that are set. You can take | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 959 |    advantage of these variables within the Makefile. | 
 | 960 |  | 
 | 961 | -  If the Makefile sets a default for a variable using "=", that default | 
 | 962 |    overrides the value set in the environment, which is usually not | 
 | 963 |    desirable. For this case, you can either patch the Makefile so it | 
 | 964 |    sets the default using the "?=" operator, or you can alternatively | 
 | 965 |    force the value on the ``make`` command line. To force the value on | 
 | 966 |    the command line, add the variable setting to | 
 | 967 |    :term:`EXTRA_OEMAKE` or | 
 | 968 |    :term:`PACKAGECONFIG_CONFARGS` | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 969 |    within the recipe. Here is an example using :term:`EXTRA_OEMAKE`:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 970 |  | 
 | 971 |       EXTRA_OEMAKE += "'CC=${CC}' 'CXX=${CXX}'" | 
 | 972 |  | 
 | 973 |    In the above example, | 
 | 974 |    single quotes are used around the variable settings as the values are | 
 | 975 |    likely to contain spaces because required default options are passed | 
 | 976 |    to the compiler. | 
 | 977 |  | 
 | 978 | -  Hardcoding paths inside Makefiles is often problematic in a | 
 | 979 |    cross-compilation environment. This is particularly true because | 
 | 980 |    those hardcoded paths often point to locations on the build host and | 
 | 981 |    thus will either be read-only or will introduce contamination into | 
 | 982 |    the cross-compilation because they are specific to the build host | 
 | 983 |    rather than the target. Patching the Makefile to use prefix variables | 
 | 984 |    or other path variables is usually the way to handle this situation. | 
 | 985 |  | 
 | 986 | -  Sometimes a Makefile runs target-specific commands such as | 
 | 987 |    ``ldconfig``. For such cases, you might be able to apply patches that | 
 | 988 |    remove these commands from the Makefile. | 
 | 989 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 990 | Adding Native Tools | 
 | 991 | ------------------- | 
 | 992 |  | 
 | 993 | Often, you need to build additional tools that run on the :term:`Build | 
 | 994 | Host` as opposed to | 
 | 995 | the target. You should indicate this requirement by using one of the | 
 | 996 | following methods when you run ``devtool add``: | 
 | 997 |  | 
 | 998 | -  Specify the name of the recipe such that it ends with "-native". | 
 | 999 |    Specifying the name like this produces a recipe that only builds for | 
 | 1000 |    the build host. | 
 | 1001 |  | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1002 | -  Specify the "--also-native" option with the ``devtool add`` | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1003 |    command. Specifying this option creates a recipe file that still | 
 | 1004 |    builds for the target but also creates a variant with a "-native" | 
 | 1005 |    suffix that builds for the build host. | 
 | 1006 |  | 
 | 1007 | .. note:: | 
 | 1008 |  | 
 | 1009 |    If you need to add a tool that is shipped as part of a source tree | 
 | 1010 |    that builds code for the target, you can typically accomplish this by | 
 | 1011 |    building the native and target parts separately rather than within | 
 | 1012 |    the same compilation process. Realize though that with the | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1013 |    "--also-native" option, you can add the tool using just one | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1014 |    recipe file. | 
 | 1015 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1016 | Adding Node.js Modules | 
 | 1017 | ---------------------- | 
 | 1018 |  | 
 | 1019 | You can use the ``devtool add`` command two different ways to add | 
 | 1020 | Node.js modules: 1) Through ``npm`` and, 2) from a repository or local | 
 | 1021 | source. | 
 | 1022 |  | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1023 | Use the following form to add Node.js modules through ``npm``:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1024 |  | 
 | 1025 |    $ devtool add "npm://registry.npmjs.org;name=forever;version=0.15.1" | 
 | 1026 |  | 
 | 1027 | The name and | 
 | 1028 | version parameters are mandatory. Lockdown and shrinkwrap files are | 
 | 1029 | generated and pointed to by the recipe in order to freeze the version | 
 | 1030 | that is fetched for the dependencies according to the first time. This | 
 | 1031 | also saves checksums that are verified on future fetches. Together, | 
 | 1032 | these behaviors ensure the reproducibility and integrity of the build. | 
 | 1033 |  | 
 | 1034 | .. note:: | 
 | 1035 |  | 
 | 1036 |    -  You must use quotes around the URL. The ``devtool add`` does not | 
 | 1037 |       require the quotes, but the shell considers ";" as a splitter | 
 | 1038 |       between multiple commands. Thus, without the quotes, | 
 | 1039 |       ``devtool add`` does not receive the other parts, which results in | 
 | 1040 |       several "command not found" errors. | 
 | 1041 |  | 
 | 1042 |    -  In order to support adding Node.js modules, a ``nodejs`` recipe | 
 | 1043 |       must be part of your SDK. | 
 | 1044 |  | 
 | 1045 | As mentioned earlier, you can also add Node.js modules directly from a | 
 | 1046 | repository or local source tree. To add modules this way, use | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1047 | ``devtool add`` in the following form:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1048 |  | 
 | 1049 |    $ devtool add https://github.com/diversario/node-ssdp | 
 | 1050 |  | 
 | 1051 | In this example, ``devtool`` | 
 | 1052 | fetches the specified Git repository, detects the code as Node.js code, | 
 | 1053 | fetches dependencies using ``npm``, and sets | 
 | 1054 | :term:`SRC_URI` accordingly. | 
 | 1055 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1056 | Working With Recipes | 
 | 1057 | ==================== | 
 | 1058 |  | 
 | 1059 | When building a recipe using the ``devtool build`` command, the typical | 
 | 1060 | build progresses as follows: | 
 | 1061 |  | 
 | 1062 | 1. Fetch the source | 
 | 1063 |  | 
 | 1064 | 2. Unpack the source | 
 | 1065 |  | 
 | 1066 | 3. Configure the source | 
 | 1067 |  | 
 | 1068 | 4. Compile the source | 
 | 1069 |  | 
 | 1070 | 5. Install the build output | 
 | 1071 |  | 
 | 1072 | 6. Package the installed output | 
 | 1073 |  | 
 | 1074 | For recipes in the workspace, fetching and unpacking is disabled as the | 
 | 1075 | source tree has already been prepared and is persistent. Each of these | 
 | 1076 | build steps is defined as a function (task), usually with a "do\_" prefix | 
 | 1077 | (e.g. :ref:`ref-tasks-fetch`, | 
 | 1078 | :ref:`ref-tasks-unpack`, and so | 
 | 1079 | forth). These functions are typically shell scripts but can instead be | 
 | 1080 | written in Python. | 
 | 1081 |  | 
 | 1082 | If you look at the contents of a recipe, you will see that the recipe | 
 | 1083 | does not include complete instructions for building the software. | 
 | 1084 | Instead, common functionality is encapsulated in classes inherited with | 
 | 1085 | the ``inherit`` directive. This technique leaves the recipe to describe | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1086 | just the things that are specific to the software being built. There is | 
 | 1087 | a :ref:`base <ref-classes-base>` class that | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1088 | is implicitly inherited by all recipes and provides the functionality | 
 | 1089 | that most recipes typically need. | 
 | 1090 |  | 
 | 1091 | The remainder of this section presents information useful when working | 
 | 1092 | with recipes. | 
 | 1093 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1094 | Finding Logs and Work Files | 
 | 1095 | --------------------------- | 
 | 1096 |  | 
 | 1097 | After the first run of the ``devtool build`` command, recipes that were | 
 | 1098 | previously created using the ``devtool add`` command or whose sources | 
 | 1099 | were modified using the ``devtool modify`` command contain symbolic | 
 | 1100 | links created within the source tree: | 
 | 1101 |  | 
 | 1102 | -  ``oe-logs``: This link points to the directory in which log files and | 
 | 1103 |    run scripts for each build step are created. | 
 | 1104 |  | 
 | 1105 | -  ``oe-workdir``: This link points to the temporary work area for the | 
 | 1106 |    recipe. The following locations under ``oe-workdir`` are particularly | 
 | 1107 |    useful: | 
 | 1108 |  | 
 | 1109 |    -  ``image/``: Contains all of the files installed during the | 
 | 1110 |       :ref:`ref-tasks-install` stage. | 
 | 1111 |       Within a recipe, this directory is referred to by the expression | 
 | 1112 |       ``${``\ :term:`D`\ ``}``. | 
 | 1113 |  | 
 | 1114 |    -  ``sysroot-destdir/``: Contains a subset of files installed within | 
 | 1115 |       ``do_install`` that have been put into the shared sysroot. For | 
| Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 1116 |       more information, see the | 
 | 1117 |       ":ref:`dev-manual/common-tasks:sharing files between recipes`" section. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1118 |  | 
 | 1119 |    -  ``packages-split/``: Contains subdirectories for each package | 
 | 1120 |       produced by the recipe. For more information, see the | 
| Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 1121 |       ":ref:`sdk-manual/extensible:packaging`" section. | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1122 |  | 
 | 1123 | You can use these links to get more information on what is happening at | 
 | 1124 | each build step. | 
 | 1125 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1126 | Setting Configure Arguments | 
 | 1127 | --------------------------- | 
 | 1128 |  | 
 | 1129 | If the software your recipe is building uses GNU autoconf, then a fixed | 
 | 1130 | set of arguments is passed to it to enable cross-compilation plus any | 
 | 1131 | extras specified by | 
 | 1132 | :term:`EXTRA_OECONF` or | 
 | 1133 | :term:`PACKAGECONFIG_CONFARGS` | 
 | 1134 | set within the recipe. If you wish to pass additional options, add them | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1135 | to :term:`EXTRA_OECONF` or :term:`PACKAGECONFIG_CONFARGS`. Other supported build | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1136 | tools have similar variables (e.g. | 
 | 1137 | :term:`EXTRA_OECMAKE` for | 
 | 1138 | CMake, :term:`EXTRA_OESCONS` | 
 | 1139 | for Scons, and so forth). If you need to pass anything on the ``make`` | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1140 | command line, you can use :term:`EXTRA_OEMAKE` or the | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1141 | :term:`PACKAGECONFIG_CONFARGS` | 
 | 1142 | variables to do so. | 
 | 1143 |  | 
 | 1144 | You can use the ``devtool configure-help`` command to help you set the | 
 | 1145 | arguments listed in the previous paragraph. The command determines the | 
 | 1146 | exact options being passed, and shows them to you along with any custom | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1147 | arguments specified through :term:`EXTRA_OECONF` or | 
 | 1148 | :term:`PACKAGECONFIG_CONFARGS`. If applicable, the command also shows you | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1149 | the output of the configure script's "--help" option as a | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1150 | reference. | 
 | 1151 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1152 | Sharing Files Between Recipes | 
 | 1153 | ----------------------------- | 
 | 1154 |  | 
 | 1155 | Recipes often need to use files provided by other recipes on the | 
 | 1156 | :term:`Build Host`. For example, | 
 | 1157 | an application linking to a common library needs access to the library | 
 | 1158 | itself and its associated headers. The way this access is accomplished | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1159 | within the extensible SDK is through the sysroot. There is one sysroot per | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1160 | "machine" for which the SDK is being built. In practical terms, this | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1161 | means there is a sysroot for the target machine, and a sysroot for | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1162 | the build host. | 
 | 1163 |  | 
 | 1164 | Recipes should never write files directly into the sysroot. Instead, | 
 | 1165 | files should be installed into standard locations during the | 
 | 1166 | :ref:`ref-tasks-install` task within | 
 | 1167 | the ``${``\ :term:`D`\ ``}`` directory. A | 
 | 1168 | subset of these files automatically goes into the sysroot. The reason | 
 | 1169 | for this limitation is that almost all files that go into the sysroot | 
 | 1170 | are cataloged in manifests in order to ensure they can be removed later | 
 | 1171 | when a recipe is modified or removed. Thus, the sysroot is able to | 
 | 1172 | remain free from stale files. | 
 | 1173 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1174 | Packaging | 
 | 1175 | --------- | 
 | 1176 |  | 
 | 1177 | Packaging is not always particularly relevant within the extensible SDK. | 
 | 1178 | However, if you examine how build output gets into the final image on | 
 | 1179 | the target device, it is important to understand packaging because the | 
 | 1180 | contents of the image are expressed in terms of packages and not | 
 | 1181 | recipes. | 
 | 1182 |  | 
 | 1183 | During the :ref:`ref-tasks-package` | 
 | 1184 | task, files installed during the | 
 | 1185 | :ref:`ref-tasks-install` task are | 
 | 1186 | split into one main package, which is almost always named the same as | 
 | 1187 | the recipe, and into several other packages. This separation exists | 
 | 1188 | because not all of those installed files are useful in every image. For | 
 | 1189 | example, you probably do not need any of the documentation installed in | 
 | 1190 | a production image. Consequently, for each recipe the documentation | 
 | 1191 | files are separated into a ``-doc`` package. Recipes that package | 
 | 1192 | software containing optional modules or plugins might undergo additional | 
 | 1193 | package splitting as well. | 
 | 1194 |  | 
 | 1195 | After building a recipe, you can see where files have gone by looking in | 
 | 1196 | the ``oe-workdir/packages-split`` directory, which contains a | 
 | 1197 | subdirectory for each package. Apart from some advanced cases, the | 
 | 1198 | :term:`PACKAGES` and | 
 | 1199 | :term:`FILES` variables controls | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1200 | splitting. The :term:`PACKAGES` variable lists all of the packages to be | 
 | 1201 | produced, while the :term:`FILES` variable specifies which files to include | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1202 | in each package by using an override to specify the package. For | 
| Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 1203 | example, ``FILES:${PN}`` specifies the files to go into the main package | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1204 | (i.e. the main package has the same name as the recipe and | 
 | 1205 | ``${``\ :term:`PN`\ ``}`` evaluates to the | 
| Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1206 | recipe name). The order of the :term:`PACKAGES` value is significant. For | 
 | 1207 | each installed file, the first package whose :term:`FILES` value matches the | 
 | 1208 | file is the package into which the file goes. Both the :term:`PACKAGES` and | 
 | 1209 | :term:`FILES` variables have default values. Consequently, you might find | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1210 | you do not even need to set these variables in your recipe unless the | 
 | 1211 | software the recipe is building installs files into non-standard | 
 | 1212 | locations. | 
 | 1213 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1214 | Restoring the Target Device to its Original State | 
 | 1215 | ================================================= | 
 | 1216 |  | 
 | 1217 | If you use the ``devtool deploy-target`` command to write a recipe's | 
 | 1218 | build output to the target, and you are working on an existing component | 
 | 1219 | of the system, then you might find yourself in a situation where you | 
 | 1220 | need to restore the original files that existed prior to running the | 
 | 1221 | ``devtool deploy-target`` command. Because the ``devtool deploy-target`` | 
 | 1222 | command backs up any files it overwrites, you can use the | 
 | 1223 | ``devtool undeploy-target`` command to restore those files and remove | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1224 | any other files the recipe deployed. Consider the following example:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1225 |  | 
 | 1226 |    $ devtool undeploy-target lighttpd root@192.168.7.2 | 
 | 1227 |  | 
 | 1228 | If you have deployed | 
 | 1229 | multiple applications, you can remove them all using the "-a" option | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1230 | thus restoring the target device to its original state:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1231 |  | 
 | 1232 |    $ devtool undeploy-target -a root@192.168.7.2 | 
 | 1233 |  | 
 | 1234 | Information about files deployed to | 
 | 1235 | the target as well as any backed up files are stored on the target | 
 | 1236 | itself. This storage, of course, requires some additional space on the | 
 | 1237 | target machine. | 
 | 1238 |  | 
 | 1239 | .. note:: | 
 | 1240 |  | 
 | 1241 |    The | 
 | 1242 |    devtool deploy-target | 
 | 1243 |    and | 
 | 1244 |    devtool undeploy-target | 
 | 1245 |    commands do not currently interact with any package management system | 
 | 1246 |    on the target device (e.g. RPM or OPKG). Consequently, you should not | 
 | 1247 |    intermingle | 
 | 1248 |    devtool deploy-target | 
 | 1249 |    and package manager operations on the target device. Doing so could | 
 | 1250 |    result in a conflicting set of files. | 
 | 1251 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1252 | Installing Additional Items Into the Extensible SDK | 
 | 1253 | =================================================== | 
 | 1254 |  | 
 | 1255 | Out of the box the extensible SDK typically only comes with a small | 
 | 1256 | number of tools and libraries. A minimal SDK starts mostly empty and is | 
 | 1257 | populated on-demand. Sometimes you must explicitly install extra items | 
 | 1258 | into the SDK. If you need these extra items, you can first search for | 
 | 1259 | the items using the ``devtool search`` command. For example, suppose you | 
 | 1260 | need to link to libGL but you are not sure which recipe provides libGL. | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1261 | You can use the following command to find out:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1262 |  | 
 | 1263 |    $ devtool search libGL mesa | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1264 |    A free implementation of the OpenGL API | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1265 |  | 
| Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1266 | Once you know the recipe | 
 | 1267 | (i.e. ``mesa`` in this example), you can install it. | 
 | 1268 |  | 
 | 1269 | When using the extensible SDK directly in a Yocto build | 
 | 1270 | ------------------------------------------------------- | 
 | 1271 |  | 
 | 1272 | In this scenario, the Yocto build tooling, e.g. ``bitbake`` | 
 | 1273 | is directly accessible to build additional items, and it | 
 | 1274 | can simply be executed directly: | 
 | 1275 |  | 
 | 1276 |    $ bitbake mesa | 
 | 1277 |    $ bitbake populate-sysroots | 
 | 1278 |  | 
 | 1279 | When using a standalone installer for the Extensible SDK | 
 | 1280 | -------------------------------------------------------- | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1281 |  | 
 | 1282 |    $ devtool sdk-install mesa | 
 | 1283 |  | 
 | 1284 | By default, the ``devtool sdk-install`` command assumes | 
 | 1285 | the item is available in pre-built form from your SDK provider. If the | 
 | 1286 | item is not available and it is acceptable to build the item from | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1287 | source, you can add the "-s" option as follows:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1288 |  | 
 | 1289 |    $ devtool sdk-install -s mesa | 
 | 1290 |  | 
 | 1291 | It is important to remember that building the item from source | 
 | 1292 | takes significantly longer than installing the pre-built artifact. Also, | 
| William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1293 | if there is no recipe for the item you want to add to the SDK, you must | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1294 | instead add the item using the ``devtool add`` command. | 
 | 1295 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1296 | Applying Updates to an Installed Extensible SDK | 
 | 1297 | =============================================== | 
 | 1298 |  | 
 | 1299 | If you are working with an installed extensible SDK that gets | 
 | 1300 | occasionally updated (e.g. a third-party SDK), then you will need to | 
 | 1301 | manually "pull down" the updates into the installed SDK. | 
 | 1302 |  | 
| Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1303 | To update your installed SDK, use ``devtool`` as follows:: | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1304 |  | 
 | 1305 |    $ devtool sdk-update | 
 | 1306 |  | 
 | 1307 | The previous command assumes your SDK provider has set the | 
| Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 1308 | default update URL for you through the :term:`SDK_UPDATE_URL` | 
 | 1309 | variable as described in the | 
 | 1310 | ":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] | 1311 | section. If the SDK provider has not set that default URL, you need to | 
 | 1312 | specify it yourself in the command as follows: $ devtool sdk-update | 
 | 1313 | path_to_update_directory | 
 | 1314 |  | 
 | 1315 | .. note:: | 
 | 1316 |  | 
 | 1317 |    The URL needs to point specifically to a published SDK and not to an | 
 | 1318 |    SDK installer that you would download and install. | 
 | 1319 |  | 
| Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1320 | Creating a Derivative SDK With Additional Components | 
 | 1321 | ==================================================== | 
 | 1322 |  | 
 | 1323 | You might need to produce an SDK that contains your own custom | 
 | 1324 | libraries. A good example would be if you were a vendor with customers | 
 | 1325 | that use your SDK to build their own platform-specific software and | 
 | 1326 | those customers need an SDK that has custom libraries. In such a case, | 
 | 1327 | you can produce a derivative SDK based on the currently installed SDK | 
 | 1328 | fairly easily by following these steps: | 
 | 1329 |  | 
 | 1330 | 1. If necessary, install an extensible SDK that you want to use as a | 
 | 1331 |    base for your derivative SDK. | 
 | 1332 |  | 
 | 1333 | 2. Source the environment script for the SDK. | 
 | 1334 |  | 
 | 1335 | 3. Add the extra libraries or other components you want by using the | 
 | 1336 |    ``devtool add`` command. | 
 | 1337 |  | 
 | 1338 | 4. Run the ``devtool build-sdk`` command. | 
 | 1339 |  | 
 | 1340 | The previous steps take the recipes added to the workspace and construct | 
 | 1341 | a new SDK installer that contains those recipes and the resulting binary | 
 | 1342 | artifacts. The recipes go into their own separate layer in the | 
 | 1343 | constructed derivative SDK, which leaves the workspace clean and ready | 
 | 1344 | for users to add their own recipes. |