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