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 |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 51 | avoids having to produce, test, distribute and maintain separate SDK |
| 52 | installer archives, which can get very large. There is only one environment |
| 53 | for the regular Yocto build and the SDK and less code paths where things can |
| 54 | go not according to plan. It's easier to update the SDK: it simply means |
| 55 | updating the Yocto layers with git fetch or layer management tooling. The |
| 56 | SDK extensibility is better than in the second option: just run ``bitbake`` |
| 57 | again to add more things to the sysroot, or add layers if even more things |
| 58 | are required. |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 59 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 60 | #. *Setting up the Extensible SDK from a standalone installer*. This has the |
| 61 | benefit of having a single, self-contained archive that includes all the |
| 62 | needed binary artifacts. So nothing needs to be rebuilt, and there is no |
| 63 | need to provide a well-functioning binary artefact cache over the network |
| 64 | for developers with underpowered laptops. |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 65 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 66 | .. _setting_up_ext_sdk_in_build: |
| 67 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 68 | Setting up the Extensible SDK environment directly in a Yocto build |
| 69 | ------------------------------------------------------------------- |
| 70 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 71 | #. 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] | 72 | build where ``bitbake`` can be executed. |
| 73 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 74 | #. Run:: |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 75 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 76 | $ bitbake meta-ide-support |
| 77 | $ bitbake -c populate_sysroot gtk+3 |
| 78 | # or any other target or native item that the application developer would need |
| 79 | $ bitbake build-sysroots |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 80 | |
| 81 | Setting up the Extensible SDK from a standalone installer |
| 82 | --------------------------------------------------------- |
| 83 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 84 | The first thing you need to do is install the SDK on your :term:`Build |
| 85 | Host` by running the ``*.sh`` installation script. |
| 86 | |
| 87 | You can download a tarball installer, which includes the pre-built |
| 88 | toolchain, the ``runqemu`` script, the internal build system, |
| 89 | ``devtool``, and support files from the appropriate |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 90 | :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] | 91 | Releases. Toolchains are available for several 32-bit and 64-bit |
| 92 | architectures with the ``x86_64`` directories, respectively. The |
| 93 | toolchains the Yocto Project provides are based off the |
| 94 | ``core-image-sato`` and ``core-image-minimal`` images and contain |
| 95 | libraries appropriate for developing against that image. |
| 96 | |
| 97 | The names of the tarball installer scripts are such that a string |
| 98 | representing the host system appears first in the filename and then is |
| 99 | immediately followed by a string representing the target architecture. |
| 100 | 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] | 101 | is the general form:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 102 | |
| 103 | poky-glibc-host_system-image_type-arch-toolchain-ext-release_version.sh |
| 104 | |
| 105 | Where: |
| 106 | host_system is a string representing your development system: |
| 107 | |
| 108 | i686 or x86_64. |
| 109 | |
| 110 | image_type is the image for which the SDK was built: |
| 111 | |
| 112 | core-image-sato or core-image-minimal |
| 113 | |
| 114 | arch is a string representing the tuned target architecture: |
| 115 | |
| 116 | aarch64, armv5e, core2-64, i586, mips32r2, mips64, ppc7400, or cortexa8hf-neon |
| 117 | |
| 118 | release_version is a string representing the release number of the Yocto Project: |
| 119 | |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 120 | &DISTRO;, &DISTRO;+snapshot |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 121 | |
| 122 | For example, the following SDK installer is for a 64-bit |
| 123 | development host system and a i586-tuned target architecture based off |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 124 | the SDK for ``core-image-sato`` and using the current &DISTRO; snapshot:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 125 | |
Andrew Geissler | d1e8949 | 2021-02-12 15:35:20 -0600 | [diff] [blame] | 126 | poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 127 | |
| 128 | .. note:: |
| 129 | |
| 130 | As an alternative to downloading an SDK, you can build the SDK |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 131 | installer. For information on building the installer, see the |
| 132 | :ref:`sdk-manual/appendix-obtain:building an sdk installer` |
| 133 | section. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 134 | |
| 135 | The SDK and toolchains are self-contained and by default are installed |
| 136 | into the ``poky_sdk`` folder in your home directory. You can choose to |
| 137 | install the extensible SDK in any location when you run the installer. |
| 138 | However, because files need to be written under that directory during |
| 139 | the normal course of operation, the location you choose for installation |
| 140 | must be writable for whichever users need to use the SDK. |
| 141 | |
| 142 | The following command shows how to run the installer given a toolchain |
| 143 | tarball for a 64-bit x86 development host system and a 64-bit x86 target |
| 144 | architecture. The example assumes the SDK installer is located in |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 145 | ``~/Downloads/`` and has execution rights:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 146 | |
| 147 | $ ./Downloads/poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-2.5.sh |
| 148 | Poky (Yocto Project Reference Distro) Extensible SDK installer version 2.5 |
| 149 | ========================================================================== |
Andrew Geissler | 95ac1b8 | 2021-03-31 14:34:31 -0500 | [diff] [blame] | 150 | Enter target directory for SDK (default: poky_sdk): |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 151 | You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed [Y/n]? Y |
| 152 | Extracting SDK..............done |
| 153 | Setting it up... |
| 154 | Extracting buildtools... |
| 155 | Preparing build system... |
| 156 | Parsing recipes: 100% |##################################################################| Time: 0:00:52 |
| 157 | Initialising tasks: 100% |###############################################################| Time: 0:00:00 |
| 158 | Checking sstate mirror object availability: 100% |#######################################| Time: 0:00:00 |
| 159 | Loading cache: 100% |####################################################################| Time: 0:00:00 |
| 160 | Initialising tasks: 100% |###############################################################| Time: 0:00:00 |
| 161 | done |
| 162 | SDK has been successfully set up and is ready to be used. |
| 163 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. |
| 164 | $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux |
| 165 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 166 | .. note:: |
| 167 | |
| 168 | If you do not have write permissions for the directory into which you |
| 169 | are installing the SDK, the installer notifies you and exits. For |
| 170 | that case, set up the proper permissions in the directory and run the |
| 171 | installer again. |
| 172 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 173 | .. _running_the_ext_sdk_env: |
| 174 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 175 | Running the Extensible SDK Environment Setup Script |
| 176 | =================================================== |
| 177 | |
| 178 | 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] | 179 | script before you can actually use the SDK. |
| 180 | |
| 181 | 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] | 182 | ``tmp/deploy/images/qemux86-64/`` in your :term:`Build Directory`. |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 183 | |
| 184 | When using a standalone SDK installer, this setup script resides in |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 185 | the directory you chose when you installed the SDK, which is either the |
| 186 | default ``poky_sdk`` directory or the directory you chose during |
| 187 | installation. |
| 188 | |
| 189 | Before running the script, be sure it is the one that matches the |
| 190 | architecture for which you are developing. Environment setup scripts |
| 191 | begin with the string "``environment-setup``" and include as part of |
| 192 | their name the tuned target architecture. As an example, the following |
| 193 | commands set the working directory to where the SDK was installed and |
| 194 | then source the environment setup script. In this example, the setup |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 195 | script is for an IA-based target machine using i586 tuning:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 196 | |
| 197 | $ cd /home/scottrif/poky_sdk |
| 198 | $ source environment-setup-core2-64-poky-linux |
| 199 | SDK environment now set up; additionally you may now run devtool to perform development tasks. |
| 200 | Run devtool --help for further details. |
| 201 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 202 | When using the environment script directly in a Yocto build, it can |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 203 | be run similarly:: |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 204 | |
| 205 | $ source tmp/deploy/images/qemux86-64/environment-setup-core2-64-poky-linux |
| 206 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 207 | Running the setup script defines many environment variables needed in order to |
| 208 | use the SDK (e.g. ``PATH``, :term:`CC`, :term:`LD`, and so forth). If you want |
| 209 | to see all the environment variables the script exports, examine the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 210 | installation file itself. |
| 211 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 212 | .. _using_devtool: |
| 213 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 214 | Using ``devtool`` in Your SDK Workflow |
| 215 | ====================================== |
| 216 | |
| 217 | The cornerstone of the extensible SDK is a command-line tool called |
| 218 | ``devtool``. This tool provides a number of features that help you |
| 219 | build, test and package software within the extensible SDK, and |
| 220 | optionally integrate it into an image built by the OpenEmbedded build |
| 221 | system. |
| 222 | |
| 223 | .. note:: |
| 224 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 225 | The use of ``devtool`` is not limited to the extensible SDK. You can use |
| 226 | ``devtool`` to help you easily develop any project whose build output must be |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 227 | part of an image built using the build system. |
| 228 | |
| 229 | The ``devtool`` command line is organized similarly to |
Andrew Geissler | 09209ee | 2020-12-13 08:44:15 -0600 | [diff] [blame] | 230 | :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] | 231 | sub-commands for each function. You can run ``devtool --help`` to see |
| 232 | all the commands. |
| 233 | |
| 234 | .. note:: |
| 235 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 236 | See the ":doc:`/ref-manual/devtool-reference`" |
| 237 | section in the Yocto Project Reference Manual. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 238 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 239 | ``devtool`` subcommands provide entry-points into development: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 240 | |
| 241 | - *devtool add*: Assists in adding new software to be built. |
| 242 | |
| 243 | - *devtool modify*: Sets up an environment to enable you to modify |
| 244 | the source of an existing component. |
| 245 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 246 | - *devtool ide-sdk*: Generates a configuration for an IDE. |
| 247 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 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 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 318 | If required, ``devtool`` always creates a Git repository locally |
| 319 | during the extraction. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 320 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 321 | Furthermore, the first positional argument ``srctree`` in this case |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 322 | identifies where the ``devtool add`` command will locate the |
| 323 | extracted code outside of the workspace. You need to specify an |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 324 | empty directory:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 325 | |
| 326 | $ devtool add recipe srctree fetchuri |
| 327 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 328 | In summary, 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] | 329 | location defined by ``srctree`` as a local Git repository. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 330 | |
| 331 | Within workspace, ``devtool`` creates a recipe named recipe along |
| 332 | with an associated append file. |
| 333 | |
| 334 | - *Right*: The right scenario in the figure represents a situation |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 335 | where the ``srctree`` has been previously prepared outside of the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 336 | ``devtool`` workspace. |
| 337 | |
| 338 | The following command provides a new recipe name and identifies |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 339 | the existing source tree location:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 340 | |
| 341 | $ devtool add recipe srctree |
| 342 | |
| 343 | The command examines the source code and creates a recipe named |
| 344 | recipe for the code and places the recipe into the workspace. |
| 345 | |
| 346 | Because the extracted source code already exists, ``devtool`` does |
Andrew Geissler | 615f2f1 | 2022-07-15 14:00:58 -0500 | [diff] [blame] | 347 | not try to relocate the source code into the workspace --- only the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 348 | new recipe is placed in the workspace. |
| 349 | |
| 350 | Aside from a recipe folder, the command also creates an associated |
| 351 | append folder and places an initial ``*.bbappend`` file within. |
| 352 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 353 | #. *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] | 354 | editor as defined by the ``$EDITOR`` environment variable and modify |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 355 | the file:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 356 | |
| 357 | $ devtool edit-recipe recipe |
| 358 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 359 | From within the editor, you can make modifications to the recipe that |
| 360 | take effect when you build it later. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 361 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 362 | #. *Build the Recipe or Rebuild the Image*: The next step you take |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 363 | depends on what you are going to do with the new code. |
| 364 | |
| 365 | If you need to eventually move the build output to the target |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 366 | hardware, use the following ``devtool`` command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 367 | |
| 368 | $ devtool build recipe |
| 369 | |
| 370 | On the other hand, if you want an image to contain the recipe's |
| 371 | packages from the workspace for immediate deployment onto a device |
| 372 | (e.g. for testing purposes), you can use the ``devtool build-image`` |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 373 | command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 374 | |
| 375 | $ devtool build-image image |
| 376 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 377 | #. *Deploy the Build Output*: When you use the ``devtool build`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 378 | to build out your recipe, you probably want to see if the resulting |
| 379 | build output works as expected on the target hardware. |
| 380 | |
| 381 | .. note:: |
| 382 | |
| 383 | This step assumes you have a previously built image that is |
| 384 | already either running in QEMU or is running on actual hardware. |
| 385 | Also, it is assumed that for deployment of the image to the |
| 386 | target, SSH is installed in the image and, if the image is running |
| 387 | on real hardware, you have network access to and from your |
| 388 | development machine. |
| 389 | |
| 390 | You can deploy your build output to that target hardware by using the |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 391 | ``devtool deploy-target`` command:: |
| 392 | |
| 393 | $ devtool deploy-target recipe target |
| 394 | |
| 395 | The target is a live target machine running as an SSH server. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 396 | |
| 397 | You can, of course, also deploy the image you build to actual |
| 398 | hardware by using the ``devtool build-image`` command. However, |
| 399 | ``devtool`` does not provide a specific command that allows you to |
| 400 | deploy the image to actual hardware. |
| 401 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 402 | #. *Finish Your Work With the Recipe*: The ``devtool finish`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 403 | creates any patches corresponding to commits in the local Git |
| 404 | repository, moves the new recipe to a more permanent layer, and then |
| 405 | resets the recipe so that the recipe is built normally rather than |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 406 | from the workspace:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 407 | |
| 408 | $ devtool finish recipe layer |
| 409 | |
| 410 | .. note:: |
| 411 | |
| 412 | Any changes you want to turn into patches must be committed to the |
| 413 | Git repository in the source tree. |
| 414 | |
| 415 | As mentioned, the ``devtool finish`` command moves the final recipe |
| 416 | to its permanent layer. |
| 417 | |
| 418 | As a final process of the ``devtool finish`` command, the state of |
| 419 | the standard layers and the upstream source is restored so that you |
| 420 | can build the recipe from those areas rather than the workspace. |
| 421 | |
| 422 | .. note:: |
| 423 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 424 | You can use the ``devtool reset`` command to put things back should you |
| 425 | decide you do not want to proceed with your work. If you do use this |
| 426 | command, realize that the source tree is preserved. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 427 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 428 | Use ``devtool modify`` to Modify the Source of an Existing Component |
| 429 | -------------------------------------------------------------------- |
| 430 | |
| 431 | The ``devtool modify`` command prepares the way to work on existing code |
| 432 | that already has a local recipe in place that is used to build the |
| 433 | software. The command is flexible enough to allow you to extract code |
| 434 | from an upstream source, specify the existing recipe, and keep track of |
| 435 | and gather any patch files from other developers that are associated |
| 436 | with the code. |
| 437 | |
| 438 | Depending on your particular scenario, the arguments and options you use |
| 439 | with ``devtool modify`` form different combinations. The following |
| 440 | diagram shows common development flows for the ``devtool modify`` |
| 441 | command: |
| 442 | |
| 443 | .. image:: figures/sdk-devtool-modify-flow.png |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 444 | :width: 100% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 445 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 446 | #. *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] | 447 | scenarios by which you could use ``devtool modify`` to prepare to |
| 448 | work on source files. Each scenario assumes the following: |
| 449 | |
| 450 | - The recipe exists locally in a layer external to the ``devtool`` |
| 451 | workspace. |
| 452 | |
| 453 | - The source files exist either upstream in an un-extracted state or |
| 454 | locally in a previously extracted state. |
| 455 | |
| 456 | The typical situation is where another developer has created a layer |
| 457 | for use with the Yocto Project and their recipe already resides in |
| 458 | that layer. Furthermore, their source code is readily available |
| 459 | either upstream or locally. |
| 460 | |
| 461 | - *Left*: The left scenario in the figure represents a common |
| 462 | situation where the source code does not exist locally and it |
| 463 | needs to be extracted from an upstream source. In this situation, |
| 464 | the source is extracted into the default ``devtool`` workspace |
| 465 | location. The recipe, in this scenario, is in its own layer |
| 466 | outside the workspace (i.e. ``meta-``\ layername). |
| 467 | |
| 468 | The following command identifies the recipe and, by default, |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 469 | extracts the source files:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 470 | |
| 471 | $ devtool modify recipe |
| 472 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 473 | Once ``devtool`` locates the recipe, ``devtool`` uses the recipe's |
| 474 | :term:`SRC_URI` statements to locate the source code and any local |
| 475 | patch files from other developers. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 476 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 477 | With this scenario, there is no ``srctree`` argument. Consequently, the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 478 | default behavior of the ``devtool modify`` command is to extract |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 479 | 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] | 480 | local Git structure. Furthermore, the location for the extracted |
| 481 | source is the default area within the ``devtool`` workspace. The |
| 482 | result is that the command sets up both the source code and an |
| 483 | append file within the workspace while the recipe remains in its |
| 484 | original location. |
| 485 | |
| 486 | Additionally, if you have any non-patch local files (i.e. files |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 487 | referred to with ``file://`` entries in :term:`SRC_URI` statement |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 488 | excluding ``*.patch/`` or ``*.diff``), these files are copied to |
| 489 | an ``oe-local-files`` folder under the newly created source tree. |
| 490 | Copying the files here gives you a convenient area from which you |
| 491 | can modify the files. Any changes or additions you make to those |
| 492 | files are incorporated into the build the next time you build the |
| 493 | software just as are other changes you might have made to the |
| 494 | source. |
| 495 | |
| 496 | - *Middle*: The middle scenario in the figure represents a situation |
| 497 | where the source code also does not exist locally. In this case, |
| 498 | the code is again upstream and needs to be extracted to some local |
| 499 | area as a Git repository. The recipe, in this scenario, is again |
| 500 | local and in its own layer outside the workspace. |
| 501 | |
| 502 | The following command tells ``devtool`` the recipe with which to |
| 503 | work and, in this case, identifies a local area for the extracted |
| 504 | source files that exists outside of the default ``devtool`` |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 505 | workspace:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 506 | |
| 507 | $ devtool modify recipe srctree |
| 508 | |
| 509 | .. note:: |
| 510 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 511 | You cannot provide a URL for ``srctree`` using the ``devtool`` command. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 512 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 513 | 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] | 514 | statements to locate the source files and any associated patch |
| 515 | files. Non-patch files are copied to an ``oe-local-files`` folder |
| 516 | under the newly created source tree. |
| 517 | |
| 518 | 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] | 519 | into ``srctree``. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 520 | |
| 521 | Within workspace, ``devtool`` creates an append file for the |
| 522 | 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] | 523 | files are extracted to the location you provide with ``srctree``. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 524 | |
| 525 | - *Right*: The right scenario in the figure represents a situation |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 526 | where the source tree (``srctree``) already exists locally as a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 527 | previously extracted Git structure outside of the ``devtool`` |
| 528 | workspace. In this example, the recipe also exists elsewhere |
| 529 | locally in its own layer. |
| 530 | |
| 531 | The following command tells ``devtool`` the recipe with which to |
| 532 | 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] | 533 | extracted, and uses ``srctree`` to point to the previously extracted |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 534 | source files:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 535 | |
| 536 | $ devtool modify -n recipe srctree |
| 537 | |
| 538 | If an ``oe-local-files`` subdirectory happens to exist and it |
| 539 | contains non-patch files, the files are used. However, if the |
| 540 | subdirectory does not exist and you run the ``devtool finish`` |
| 541 | command, any non-patch files that might exist next to the recipe |
| 542 | are removed because it appears to ``devtool`` that you have |
| 543 | deleted those files. |
| 544 | |
| 545 | Once the ``devtool modify`` command finishes, it creates only an |
| 546 | append file for the recipe in the ``devtool`` workspace. The |
| 547 | recipe and the source code remain in their original locations. |
| 548 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 549 | #. *Edit the Source*: Once you have used the ``devtool modify`` command, |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 550 | you are free to make changes to the source files. You can use any |
| 551 | editor you like to make and save your source code modifications. |
| 552 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 553 | #. *Build the Recipe or Rebuild the Image*: The next step you take |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 554 | depends on what you are going to do with the new code. |
| 555 | |
| 556 | If you need to eventually move the build output to the target |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 557 | hardware, use the following ``devtool`` command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 558 | |
| 559 | $ devtool build recipe |
| 560 | |
| 561 | On the other hand, if you want an image to contain the recipe's |
| 562 | packages from the workspace for immediate deployment onto a device |
| 563 | (e.g. for testing purposes), you can use the ``devtool build-image`` |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 564 | command:: |
| 565 | |
| 566 | $ devtool build-image image |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 567 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 568 | #. *Deploy the Build Output*: When you use the ``devtool build`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 569 | to build out your recipe, you probably want to see if the resulting |
| 570 | build output works as expected on target hardware. |
| 571 | |
| 572 | .. note:: |
| 573 | |
| 574 | This step assumes you have a previously built image that is |
| 575 | already either running in QEMU or running on actual hardware. |
| 576 | Also, it is assumed that for deployment of the image to the |
| 577 | target, SSH is installed in the image and if the image is running |
| 578 | on real hardware that you have network access to and from your |
| 579 | development machine. |
| 580 | |
| 581 | 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] | 582 | ``devtool deploy-target`` command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 583 | |
| 584 | $ devtool deploy-target recipe target |
| 585 | |
| 586 | The target is a live target machine running as an SSH server. |
| 587 | |
| 588 | You can, of course, use other methods to deploy the image you built |
| 589 | using the ``devtool build-image`` command to actual hardware. |
| 590 | ``devtool`` does not provide a specific command to deploy the image |
| 591 | to actual hardware. |
| 592 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 593 | #. *Finish Your Work With the Recipe*: The ``devtool finish`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 594 | creates any patches corresponding to commits in the local Git |
| 595 | repository, updates the recipe to point to them (or creates a |
| 596 | ``.bbappend`` file to do so, depending on the specified destination |
| 597 | layer), and then resets the recipe so that the recipe is built |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 598 | normally rather than from the workspace:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 599 | |
| 600 | $ devtool finish recipe layer |
| 601 | |
| 602 | .. note:: |
| 603 | |
| 604 | Any changes you want to turn into patches must be staged and |
| 605 | committed within the local Git repository before you use the |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 606 | ``devtool finish`` command. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 607 | |
| 608 | Because there is no need to move the recipe, ``devtool finish`` |
| 609 | either updates the original recipe in the original layer or the |
| 610 | command creates a ``.bbappend`` file in a different layer as provided |
| 611 | by layer. Any work you did in the ``oe-local-files`` directory is |
| 612 | preserved in the original files next to the recipe during the |
| 613 | ``devtool finish`` command. |
| 614 | |
| 615 | As a final process of the ``devtool finish`` command, the state of |
| 616 | the standard layers and the upstream source is restored so that you |
| 617 | can build the recipe from those areas rather than from the workspace. |
| 618 | |
| 619 | .. note:: |
| 620 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 621 | You can use the ``devtool reset`` command to put things back should you |
| 622 | decide you do not want to proceed with your work. If you do use this |
| 623 | command, realize that the source tree is preserved. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 624 | |
Patrick Williams | 3965356 | 2024-03-01 08:54:02 -0600 | [diff] [blame] | 625 | ``devtool ide-sdk`` configures IDEs for the extensible SDK |
| 626 | ---------------------------------------------------------- |
| 627 | |
| 628 | ``devtool ide-sdk`` automatically configures IDEs to use the extensible SDK. |
| 629 | To make sure that all parts of the extensible SDK required by the generated |
| 630 | IDE configuration are available, ``devtool ide-sdk`` uses BitBake in the |
| 631 | background to bootstrap the extensible SDK. |
| 632 | |
| 633 | The extensible SDK supports two different development modes. |
| 634 | ``devtool ide-sdk`` supports both of them: |
| 635 | |
| 636 | #. *Modified mode*: |
| 637 | |
| 638 | By default ``devtool ide-sdk`` generates IDE configurations for recipes in |
| 639 | workspaces created by ``devtool modify`` or ``devtool add`` as described in |
| 640 | :ref:`using_devtool`. This mode creates IDE configurations with support for |
| 641 | advanced features, such as deploying the binaries to the remote target |
| 642 | device and performing remote debugging sessions. The generated IDE |
| 643 | configurations use the per recipe sysroots as Bitbake does internally. |
| 644 | |
| 645 | In order to use the tool, a few settings are needed. As a starting example, |
| 646 | the following lines of code can be added to the ``local.conf`` file:: |
| 647 | |
| 648 | # Build the companion debug file system |
| 649 | IMAGE_GEN_DEBUGFS = "1" |
| 650 | # Optimize build time: with devtool ide-sdk the dbg tar is not needed |
| 651 | IMAGE_FSTYPES_DEBUGFS = "" |
| 652 | # Without copying the binaries into roofs-dbg, GDB does not find all source files. |
| 653 | IMAGE_CLASSES += "image-combined-dbg" |
| 654 | |
| 655 | # SSH is mandatory, no password simplifies the usage |
| 656 | EXTRA_IMAGE_FEATURES += "\ |
| 657 | ssh-server-openssh \ |
| 658 | debug-tweaks \ |
| 659 | " |
| 660 | |
| 661 | # Remote debugging needs gdbserver on the target device |
| 662 | IMAGE_INSTALL:append = " gdbserver" |
| 663 | |
| 664 | # Add the recipes which should be modified to the image |
| 665 | # Otherwise some dependencies might be missing. |
| 666 | IMAGE_INSTALL:append = " my-recipe" |
| 667 | |
| 668 | Assuming the BitBake environment is set up correctly and a workspace has |
| 669 | been created for the recipe using ``devtool modify my-recipe``, the |
| 670 | following command can create the SDK and the configuration for VSCode in |
| 671 | the recipe workspace:: |
| 672 | |
| 673 | $ devtool ide-sdk my-recipe core-image-minimal --target root@192.168.7.2 |
| 674 | |
| 675 | The command requires an image recipe (``core-image-minimal`` for this example) |
| 676 | that is used to create the SDK. This firmware image should also be installed |
| 677 | on the target device. It is possible to pass multiple package recipes. |
| 678 | ``devtool ide-sdk`` tries to create an IDE configuration for all package |
| 679 | recipes. |
| 680 | |
| 681 | What this command does exactly depends on the recipe, more precisely on the |
| 682 | build tool used by the recipe. The basic idea is to configure the IDE so |
| 683 | that it calls the build tool exactly as ``bitbake`` does. |
| 684 | |
| 685 | For example, a CMake preset is created for a recipe that inherits |
| 686 | :ref:`ref-classes-cmake`. In the case of VSCode, CMake presets are supported |
| 687 | by the CMake Tools plugin. This is an example of how the build |
| 688 | configuration used by ``bitbake`` is exported to an IDE configuration that |
| 689 | gives exactly the same build results. |
| 690 | |
| 691 | Support for remote debugging with seamless integration into the IDE is |
| 692 | important for a cross-SDK. ``devtool ide-sdk`` automatically generates the |
| 693 | necessary helper scripts for deploying the compiled artifacts to the target |
| 694 | device as well as the necessary configuration for the debugger and the IDE. |
| 695 | |
| 696 | .. note:: |
| 697 | |
| 698 | To ensure that the debug symbols on the build machine match the binaries |
| 699 | running on the target device, it is essential that the image built by |
| 700 | ``devtool ide-sdk`` is running on the target device. |
| 701 | |
| 702 | ``devtool ide-sdk`` aims to support multiple programming languages and |
| 703 | multiple IDEs natively. "Natively" means that the IDE is configured to call |
| 704 | the build tool (e.g. CMake or Meson) directly. This has several advantages. |
| 705 | First of all, it is much faster than ``devtool build``, but it also allows |
| 706 | to use the very good integration of tools like CMake or GDB in VSCode and |
| 707 | other IDEs. However, supporting many programming languages and multiple |
| 708 | IDEs is quite an elaborate and constantly evolving thing. Support for IDEs |
| 709 | is therefore implemented as plugins. Plugins can also be provided by |
| 710 | optional layers. |
| 711 | |
| 712 | The default IDE is VSCode. Some hints about using VSCode: |
| 713 | |
| 714 | - To work on the source code of a recipe an instance of VSCode is started in |
| 715 | the recipe's workspace. Example:: |
| 716 | |
| 717 | code build/workspace/sources/my-recipe |
| 718 | |
| 719 | - To work with CMake press ``Ctrl + Shift + p``, type ``cmake``. This will |
| 720 | show some possible commands like selecting a CMake preset, compiling or |
| 721 | running CTest. |
| 722 | |
| 723 | For recipes inheriting :ref:`ref-classes-cmake-qemu` rather than |
| 724 | :ref:`ref-classes-cmake`, executing cross-compiled unit tests on the host |
| 725 | can be supported transparently with QEMU user-mode. |
| 726 | |
| 727 | - To work with Meson press ``Ctrl + Shift + p``, type ``meson``. This will |
| 728 | show some possible commands like compiling or executing the unit tests. |
| 729 | |
| 730 | A note on running cross-compiled unit tests on the host: Meson enables |
| 731 | support for QEMU user-mode by default. It is expected that the execution |
| 732 | of the unit tests from the IDE will work easily without any additional |
| 733 | steps, provided that the code is suitable for execution on the host |
| 734 | machine. |
| 735 | |
| 736 | - For the deployment to the target device, just press ``Ctrl + Shift + p``, |
| 737 | type ``task``. Select ``install && deploy-target``. |
| 738 | |
| 739 | - For remote debugging, switch to the debugging view by pressing the "play" |
| 740 | button with the ``bug icon`` on the left side. This will provide a green |
| 741 | play button with a drop-down list where a debug configuration can be |
| 742 | selected. After selecting one of the generated configurations, press the |
| 743 | "play" button. |
| 744 | |
| 745 | Starting a remote debugging session automatically initiates the deployment |
| 746 | to the target device. If this is not desired, the |
| 747 | ``"dependsOn": ["install && deploy-target...]`` parameter of the tasks |
| 748 | with ``"label": "gdbserver start...`` can be removed from the |
| 749 | ``tasks.json`` file. |
| 750 | |
| 751 | VSCode supports GDB with many different setups and configurations for many |
| 752 | different use cases. However, most of these setups have some limitations |
| 753 | when it comes to cross-development, support only a few target |
| 754 | architectures or require a high performance target device. Therefore |
| 755 | ``devtool ide-sdk`` supports the classic, generic setup with GDB on the |
| 756 | development host and gdbserver on the target device. |
| 757 | |
| 758 | Roughly summarized, this means: |
| 759 | |
| 760 | - The binaries are copied via SSH to the remote target device by a script |
| 761 | referred by ``tasks.json``. |
| 762 | |
| 763 | - gdbserver is started on the remote target device via SSH by a script |
| 764 | referred by ``tasks.json``. |
| 765 | |
| 766 | Changing the parameters that are passed to the debugging executable |
| 767 | requires modifying the generated script. The script is located at |
| 768 | ``oe-scripts/gdbserver_*``. Defining the parameters in the ``args`` |
| 769 | field in the ``launch.json`` file does not work. |
| 770 | |
| 771 | - VSCode connects to gdbserver as documented in |
| 772 | `Remote debugging or debugging with a local debugger server |
| 773 | <https://code.visualstudio.com/docs/cpp/launch-json-reference#_remote-debugging-or-debugging-with-a-local-debugger-server>`__. |
| 774 | |
| 775 | Additionally ``--ide=none`` is supported. With the ``none`` IDE parameter, |
| 776 | some generic configuration files like ``gdbinit`` files and some helper |
| 777 | scripts starting gdbserver remotely on the target device as well as the GDB |
| 778 | client on the host are generated. |
| 779 | |
| 780 | Here is a usage example for the ``cmake-example`` recipe from the |
| 781 | ``meta-selftest`` layer which inherits :ref:`ref-classes-cmake-qemu`: |
| 782 | |
| 783 | .. code-block:: sh |
| 784 | |
| 785 | # Create the SDK |
| 786 | devtool modify cmake-example |
| 787 | devtool ide-sdk cmake-example core-image-minimal -c --debug-build-config --ide=none |
| 788 | |
| 789 | # Install the firmware on a target device or start QEMU |
| 790 | runqemu |
| 791 | |
| 792 | # From exploring the workspace of cmake-example |
| 793 | cd build/workspace/sources/cmake-example |
| 794 | |
| 795 | # Find cmake-native and save the path into a variable |
| 796 | # Note: using just cmake instead of $CMAKE_NATIVE would work in many cases |
| 797 | CMAKE_NATIVE="$(jq -r '.configurePresets[0] | "\(.cmakeExecutable)"' CMakeUserPresets.json)" |
| 798 | |
| 799 | # List available CMake presets |
| 800 | "$CMAKE_NATIVE" --list-presets |
| 801 | Available configure presets: |
| 802 | |
| 803 | "cmake-example-cortexa57" - cmake-example: cortexa57 |
| 804 | |
| 805 | # Re-compile the already compiled sources |
| 806 | "$CMAKE_NATIVE" --build --preset cmake-example-cortexa57 |
| 807 | ninja: no work to do. |
| 808 | # Do a clean re-build |
| 809 | "$CMAKE_NATIVE" --build --preset cmake-example-cortexa57 --target clean |
| 810 | [1/1] Cleaning all built files... |
| 811 | Cleaning... 8 files. |
| 812 | "$CMAKE_NATIVE" --build --preset cmake-example-cortexa57 --target all |
| 813 | [7/7] Linking CXX executable cmake-example |
| 814 | |
| 815 | # Run the cross-compiled unit tests with QEMU user-mode |
| 816 | "$CMAKE_NATIVE" --build --preset cmake-example-cortexa57 --target test |
| 817 | [0/1] Running tests... |
| 818 | Test project .../build/tmp/work/cortexa57-poky-linux/cmake-example/1.0/cmake-example-1.0 |
| 819 | Start 1: test-cmake-example |
| 820 | 1/1 Test #1: test-cmake-example ............... Passed 0.03 sec |
| 821 | |
| 822 | 100% tests passed, 0 tests failed out of 1 |
| 823 | |
| 824 | Total Test time (real) = 0.03 sec |
| 825 | |
| 826 | # Using CTest directly is possible as well |
| 827 | CTEST_NATIVE="$(dirname "$CMAKE_NATIVE")/ctest" |
| 828 | |
| 829 | # List available CMake presets |
| 830 | "$CTEST_NATIVE" --list-presets |
| 831 | Available test presets: |
| 832 | |
| 833 | "cmake-example-cortexa57" - cmake-example: cortexa57 |
| 834 | |
| 835 | # Run the cross-compiled unit tests with QEMU user-mode |
| 836 | "$CTEST_NATIVE" --preset "cmake-example-cortexa57" |
| 837 | Test project ...build/tmp/work/cortexa57-poky-linux/cmake-example/1.0/cmake-example-1.0 |
| 838 | Start 1: test-cmake-example |
| 839 | 1/1 Test #1: test-cmake-example ............... Passed 0.03 sec |
| 840 | |
| 841 | 100% tests passed, 0 tests failed out of 1 |
| 842 | |
| 843 | Total Test time (real) = 0.03 sec |
| 844 | |
| 845 | # Deploying the new build to the target device (default is QEUM at 192.168.7.2) |
| 846 | oe-scripts/install_and_deploy_cmake-example-cortexa57 |
| 847 | |
| 848 | # Start a remote debugging session with gdbserver on the target and GDB on the host |
| 849 | oe-scripts/gdbserver_1234_usr-bin-cmake-example_m |
| 850 | oe-scripts/gdb_1234_usr-bin-cmake-example |
| 851 | break main |
| 852 | run |
| 853 | step |
| 854 | stepi |
| 855 | continue |
| 856 | quit |
| 857 | |
| 858 | # Stop gdbserver on the target device |
| 859 | oe-scripts/gdbserver_1234_usr-bin-cmake-example_m stop |
| 860 | |
| 861 | #. *Shared sysroots mode* |
| 862 | |
| 863 | For some recipes and use cases a per-recipe sysroot based SDK is not |
| 864 | suitable. Optionally ``devtool ide-sdk`` configures the IDE to use the |
| 865 | toolchain provided by the extensible SDK as described in |
| 866 | :ref:`running_the_ext_sdk_env`. ``devtool ide-sdk --mode=shared`` is |
| 867 | basically a wrapper for the setup of the extensible SDK as described in |
| 868 | :ref:`setting_up_ext_sdk_in_build`. The IDE gets a configuration to use the |
| 869 | shared sysroots. |
| 870 | |
| 871 | Creating a SDK with shared sysroots that contains all the dependencies needed |
| 872 | to work with ``my-recipe`` is possible with the following example command:: |
| 873 | |
| 874 | $ devtool ide-sdk --mode=shared my-recipe |
| 875 | |
| 876 | For VSCode the cross-toolchain is exposed as a CMake kit. CMake kits are |
| 877 | defined in ``~/.local/share/CMakeTools/cmake-tools-kits.json``. |
| 878 | The following example shows how the cross-toolchain can be selected in |
| 879 | VSCode. First of all we need a folder containing a CMake project. |
| 880 | For this example, let's create a CMake project and start VSCode:: |
| 881 | |
| 882 | mkdir kit-test |
| 883 | echo "project(foo VERSION 1.0)" > kit-test/CMakeLists.txt |
| 884 | code kit-test |
| 885 | |
| 886 | If there is a CMake project in the workspace, cross-compilation is supported: |
| 887 | |
| 888 | - Press ``Ctrl + Shift + P``, type ``CMake: Scan for Kits`` |
| 889 | - Press ``Ctrl + Shift + P``, type ``CMake: Select a Kit`` |
| 890 | |
| 891 | Finally most of the features provided by CMake and the IDE should be available. |
| 892 | |
| 893 | Other IDEs than VSCode are supported as well. However, |
| 894 | ``devtool ide-sdk --mode=shared --ide=none my-recipe`` is currently |
| 895 | just a simple wrapper for the setup of the extensible SDK, as described in |
| 896 | :ref:`setting_up_ext_sdk_in_build`. |
| 897 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 898 | Use ``devtool upgrade`` to Create a Version of the Recipe that Supports a Newer Version of the Software |
| 899 | ------------------------------------------------------------------------------------------------------- |
| 900 | |
| 901 | The ``devtool upgrade`` command upgrades an existing recipe to that of a |
| 902 | more up-to-date version found upstream. Throughout the life of software, |
| 903 | recipes continually undergo version upgrades by their upstream |
| 904 | publishers. You can use the ``devtool upgrade`` workflow to make sure |
| 905 | your recipes you are using for builds are up-to-date with their upstream |
| 906 | counterparts. |
| 907 | |
| 908 | .. note:: |
| 909 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 910 | Several methods exist by which you can upgrade recipes --- |
| 911 | ``devtool upgrade`` happens to be one. You can read about all the methods by |
| 912 | which you can upgrade recipes in the |
| 913 | :ref:`dev-manual/upgrading-recipes:upgrading recipes` section of the Yocto |
| 914 | Project Development Tasks Manual. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 915 | |
Andrew Geissler | fc113ea | 2023-03-31 09:59:46 -0500 | [diff] [blame] | 916 | The ``devtool upgrade`` command is flexible enough to allow you to specify |
| 917 | source code revision and versioning schemes, extract code into or out of the |
| 918 | ``devtool`` :ref:`devtool-the-workspace-layer-structure`, and work with any |
| 919 | source file forms that the |
| 920 | :ref:`bitbake-user-manual/bitbake-user-manual-fetching:fetchers` support. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 921 | |
| 922 | The following diagram shows the common development flow used with the |
| 923 | ``devtool upgrade`` command: |
| 924 | |
| 925 | .. image:: figures/sdk-devtool-upgrade-flow.png |
Andrew Geissler | d583833 | 2022-05-27 11:33:10 -0500 | [diff] [blame] | 926 | :width: 100% |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 927 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 928 | #. *Initiate the Upgrade*: The top part of the flow shows the typical |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 929 | scenario by which you use the ``devtool upgrade`` command. The |
| 930 | following conditions exist: |
| 931 | |
| 932 | - The recipe exists in a local layer external to the ``devtool`` |
| 933 | workspace. |
| 934 | |
| 935 | - The source files for the new release exist in the same location |
| 936 | pointed to by :term:`SRC_URI` |
| 937 | in the recipe (e.g. a tarball with the new version number in the |
| 938 | name, or as a different revision in the upstream Git repository). |
| 939 | |
| 940 | A common situation is where third-party software has undergone a |
| 941 | revision so that it has been upgraded. The recipe you have access to |
| 942 | 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] | 943 | use the newer version of the software:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 944 | |
| 945 | $ devtool upgrade -V version recipe |
| 946 | |
| 947 | By default, the ``devtool upgrade`` command extracts source |
| 948 | code into the ``sources`` directory in the |
| 949 | :ref:`devtool-the-workspace-layer-structure`. |
| 950 | 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] | 951 | provide the ``srctree`` positional argument with the command as follows:: |
| 952 | |
| 953 | $ devtool upgrade -V version recipe srctree |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 954 | |
| 955 | .. note:: |
| 956 | |
| 957 | In this example, the "-V" option specifies the new version. If you |
| 958 | don't use "-V", the command upgrades the recipe to the latest |
| 959 | version. |
| 960 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 961 | 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] | 962 | recipe are in a Git repository, you must provide the "-S" option and |
| 963 | specify a revision for the software. |
| 964 | |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 965 | Once ``devtool`` locates the recipe, it uses the :term:`SRC_URI` variable |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 966 | to locate the source code and any local patch files from other |
| 967 | developers. The result is that the command sets up the source code, |
| 968 | the new version of the recipe, and an append file all within the |
| 969 | workspace. |
| 970 | |
| 971 | Additionally, if you have any non-patch local files (i.e. files |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 972 | referred to with ``file://`` entries in :term:`SRC_URI` statement |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 973 | excluding ``*.patch/`` or ``*.diff``), these files are copied to an |
| 974 | ``oe-local-files`` folder under the newly created source tree. |
| 975 | Copying the files here gives you a convenient area from which you can |
| 976 | modify the files. Any changes or additions you make to those files |
| 977 | are incorporated into the build the next time you build the software |
| 978 | just as are other changes you might have made to the source. |
| 979 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 980 | #. *Resolve any Conflicts created by the Upgrade*: Conflicts could happen |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 981 | after upgrading the software to a new version. Conflicts occur |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 982 | if your recipe specifies some patch files in :term:`SRC_URI` that |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 983 | conflict with changes made in the new version of the software. For |
| 984 | such cases, you need to resolve the conflicts by editing the source |
| 985 | and following the normal ``git rebase`` conflict resolution process. |
| 986 | |
| 987 | Before moving onto the next step, be sure to resolve any such |
| 988 | conflicts created through use of a newer or different version of the |
| 989 | software. |
| 990 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 991 | #. *Build the Recipe or Rebuild the Image*: The next step you take |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 992 | depends on what you are going to do with the new code. |
| 993 | |
| 994 | If you need to eventually move the build output to the target |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 995 | hardware, use the following ``devtool`` command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 996 | |
| 997 | $ devtool build recipe |
| 998 | |
| 999 | On the other hand, if you want an image to contain the recipe's |
| 1000 | packages from the workspace for immediate deployment onto a device |
| 1001 | (e.g. for testing purposes), you can use the ``devtool build-image`` |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1002 | command:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1003 | |
| 1004 | $ devtool build-image image |
| 1005 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1006 | #. *Deploy the Build Output*: When you use the ``devtool build`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1007 | or ``bitbake`` to build your recipe, you probably want to see if the |
| 1008 | resulting build output works as expected on target hardware. |
| 1009 | |
| 1010 | .. note:: |
| 1011 | |
| 1012 | This step assumes you have a previously built image that is |
| 1013 | already either running in QEMU or running on actual hardware. |
| 1014 | Also, it is assumed that for deployment of the image to the |
| 1015 | target, SSH is installed in the image and if the image is running |
| 1016 | on real hardware that you have network access to and from your |
| 1017 | development machine. |
| 1018 | |
| 1019 | You can deploy your build output to that target hardware by using the |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1020 | ``devtool deploy-target`` command:: |
| 1021 | |
| 1022 | $ devtool deploy-target recipe target |
| 1023 | |
| 1024 | The target is a live target machine running as an SSH server. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1025 | |
| 1026 | You can, of course, also deploy the image you build using the |
| 1027 | ``devtool build-image`` command to actual hardware. However, |
| 1028 | ``devtool`` does not provide a specific command that allows you to do |
| 1029 | this. |
| 1030 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1031 | #. *Finish Your Work With the Recipe*: The ``devtool finish`` command |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1032 | creates any patches corresponding to commits in the local Git |
| 1033 | repository, moves the new recipe to a more permanent layer, and then |
| 1034 | resets the recipe so that the recipe is built normally rather than |
| 1035 | from the workspace. |
| 1036 | |
| 1037 | Any work you did in the ``oe-local-files`` directory is preserved in |
| 1038 | the original files next to the recipe during the ``devtool finish`` |
| 1039 | command. |
| 1040 | |
| 1041 | If you specify a destination layer that is the same as the original |
| 1042 | source, then the old version of the recipe and associated files are |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1043 | removed prior to adding the new version:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1044 | |
| 1045 | $ devtool finish recipe layer |
| 1046 | |
| 1047 | .. note:: |
| 1048 | |
| 1049 | Any changes you want to turn into patches must be committed to the |
| 1050 | Git repository in the source tree. |
| 1051 | |
| 1052 | As a final process of the ``devtool finish`` command, the state of |
| 1053 | the standard layers and the upstream source is restored so that you |
| 1054 | can build the recipe from those areas rather than the workspace. |
| 1055 | |
| 1056 | .. note:: |
| 1057 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1058 | You can use the ``devtool reset`` command to put things back should you |
| 1059 | decide you do not want to proceed with your work. If you do use this |
| 1060 | command, realize that the source tree is preserved. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1061 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1062 | A Closer Look at ``devtool add`` |
| 1063 | ================================ |
| 1064 | |
| 1065 | The ``devtool add`` command automatically creates a recipe based on the |
| 1066 | source tree you provide with the command. Currently, the command has |
| 1067 | support for the following: |
| 1068 | |
| 1069 | - Autotools (``autoconf`` and ``automake``) |
| 1070 | |
| 1071 | - CMake |
| 1072 | |
| 1073 | - Scons |
| 1074 | |
| 1075 | - ``qmake`` |
| 1076 | |
| 1077 | - Plain ``Makefile`` |
| 1078 | |
| 1079 | - Out-of-tree kernel module |
| 1080 | |
| 1081 | - Binary package (i.e. "-b" option) |
| 1082 | |
| 1083 | - Node.js module |
| 1084 | |
| 1085 | - Python modules that use ``setuptools`` or ``distutils`` |
| 1086 | |
| 1087 | Apart from binary packages, the determination of how a source tree |
| 1088 | should be treated is automatic based on the files present within that |
| 1089 | source tree. For example, if a ``CMakeLists.txt`` file is found, then |
| 1090 | the source tree is assumed to be using CMake and is treated accordingly. |
| 1091 | |
| 1092 | .. note:: |
| 1093 | |
| 1094 | In most cases, you need to edit the automatically generated recipe in |
| 1095 | order to make it build properly. Typically, you would go through |
| 1096 | several edit and build cycles until the recipe successfully builds. |
| 1097 | Once the recipe builds, you could use possible further iterations to |
| 1098 | test the recipe on the target device. |
| 1099 | |
| 1100 | The remainder of this section covers specifics regarding how parts of |
| 1101 | the recipe are generated. |
| 1102 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1103 | Name and Version |
| 1104 | ---------------- |
| 1105 | |
| 1106 | If you do not specify a name and version on the command line, |
| 1107 | ``devtool add`` uses various metadata within the source tree in an |
| 1108 | attempt to determine the name and version of the software being built. |
| 1109 | Based on what the tool determines, ``devtool`` sets the name of the |
| 1110 | created recipe file accordingly. |
| 1111 | |
| 1112 | If ``devtool`` cannot determine the name and version, the command prints |
| 1113 | an error. For such cases, you must re-run the command and provide the |
| 1114 | name and version, just the name, or just the version as part of the |
| 1115 | command line. |
| 1116 | |
| 1117 | Sometimes the name or version determined from the source tree might be |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1118 | incorrect. For such a case, you must reset the recipe:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1119 | |
| 1120 | $ devtool reset -n recipename |
| 1121 | |
| 1122 | After running the ``devtool reset`` command, you need to |
| 1123 | run ``devtool add`` again and provide the name or the version. |
| 1124 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1125 | Dependency Detection and Mapping |
| 1126 | -------------------------------- |
| 1127 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1128 | The ``devtool add`` command attempts to detect build-time dependencies and map |
| 1129 | them to other recipes in the system. During this mapping, the command fills in |
| 1130 | the names of those recipes as part of the :term:`DEPENDS` variable within the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1131 | recipe. If a dependency cannot be mapped, ``devtool`` places a comment |
| 1132 | in the recipe indicating such. The inability to map a dependency can |
| 1133 | result from naming not being recognized or because the dependency simply |
| 1134 | is not available. For cases where the dependency is not available, you |
| 1135 | must use the ``devtool add`` command to add an additional recipe that |
| 1136 | satisfies the dependency. Once you add that recipe, you need to update |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1137 | the :term:`DEPENDS` variable in the original recipe to include the new |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1138 | recipe. |
| 1139 | |
| 1140 | 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] | 1141 | following to your recipe:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1142 | |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 1143 | RDEPENDS:${PN} += "dependency1 dependency2 ..." |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1144 | |
| 1145 | .. note:: |
| 1146 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1147 | The ``devtool add`` command often cannot distinguish between mandatory and |
| 1148 | optional dependencies. Consequently, some of the detected dependencies might |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1149 | in fact be optional. When in doubt, consult the documentation or the |
| 1150 | configure script for the software the recipe is building for further |
| 1151 | details. In some cases, you might find you can substitute the |
| 1152 | dependency with an option that disables the associated functionality |
| 1153 | passed to the configure script. |
| 1154 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1155 | License Detection |
| 1156 | ----------------- |
| 1157 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1158 | The ``devtool add`` command attempts to determine if the software you are |
| 1159 | adding is able to be distributed under a common, open-source license. If |
| 1160 | so, the command sets the :term:`LICENSE` value accordingly. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1161 | You should double-check the value added by the command against the |
| 1162 | documentation or source files for the software you are building and, if |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1163 | necessary, update that :term:`LICENSE` value. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1164 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1165 | The ``devtool add`` command also sets the :term:`LIC_FILES_CHKSUM` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1166 | value to point to all files that appear to be license-related. Realize |
| 1167 | that license statements often appear in comments at the top of source |
| 1168 | files or within the documentation. In such cases, the command does not |
| 1169 | recognize those license statements. Consequently, you might need to |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1170 | amend the :term:`LIC_FILES_CHKSUM` variable to point to one or more of those |
| 1171 | comments if present. Setting :term:`LIC_FILES_CHKSUM` is particularly |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1172 | important for third-party software. The mechanism attempts to ensure |
| 1173 | correct licensing should you upgrade the recipe to a newer upstream |
| 1174 | version in future. Any change in licensing is detected and you receive |
| 1175 | an error prompting you to check the license text again. |
| 1176 | |
| 1177 | If the ``devtool add`` command cannot determine licensing information, |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1178 | ``devtool`` sets the :term:`LICENSE` value to "CLOSED" and leaves the |
| 1179 | :term:`LIC_FILES_CHKSUM` value unset. This behavior allows you to continue |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1180 | with development even though the settings are unlikely to be correct in |
| 1181 | all cases. You should check the documentation or source files for the |
| 1182 | software you are building to determine the actual license. |
| 1183 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1184 | Adding Makefile-Only Software |
| 1185 | ----------------------------- |
| 1186 | |
| 1187 | The use of Make by itself is very common in both proprietary and |
| 1188 | open-source software. Unfortunately, Makefiles are often not written |
| 1189 | with cross-compilation in mind. Thus, ``devtool add`` often cannot do |
| 1190 | very much to ensure that these Makefiles build correctly. It is very |
| 1191 | common, for example, to explicitly call ``gcc`` instead of using the |
| 1192 | :term:`CC` variable. Usually, in a |
| 1193 | cross-compilation environment, ``gcc`` is the compiler for the build |
| 1194 | host and the cross-compiler is named something similar to |
| 1195 | ``arm-poky-linux-gnueabi-gcc`` and might require arguments (e.g. to |
| 1196 | point to the associated sysroot for the target machine). |
| 1197 | |
| 1198 | When writing a recipe for Makefile-only software, keep the following in |
| 1199 | mind: |
| 1200 | |
| 1201 | - You probably need to patch the Makefile to use variables instead of |
| 1202 | hardcoding tools within the toolchain such as ``gcc`` and ``g++``. |
| 1203 | |
| 1204 | - The environment in which Make runs is set up with various standard |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1205 | 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] | 1206 | similar manner to the environment set up by the SDK's environment |
| 1207 | setup script. One easy way to see these variables is to run the |
| 1208 | ``devtool build`` command on the recipe and then look in |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1209 | ``oe-logs/run.do_compile``. Towards the top of this file, there is |
| 1210 | a list of environment variables that are set. You can take |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1211 | advantage of these variables within the Makefile. |
| 1212 | |
| 1213 | - If the Makefile sets a default for a variable using "=", that default |
| 1214 | overrides the value set in the environment, which is usually not |
| 1215 | desirable. For this case, you can either patch the Makefile so it |
| 1216 | sets the default using the "?=" operator, or you can alternatively |
| 1217 | force the value on the ``make`` command line. To force the value on |
| 1218 | the command line, add the variable setting to |
| 1219 | :term:`EXTRA_OEMAKE` or |
| 1220 | :term:`PACKAGECONFIG_CONFARGS` |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1221 | within the recipe. Here is an example using :term:`EXTRA_OEMAKE`:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1222 | |
| 1223 | EXTRA_OEMAKE += "'CC=${CC}' 'CXX=${CXX}'" |
| 1224 | |
| 1225 | In the above example, |
| 1226 | single quotes are used around the variable settings as the values are |
| 1227 | likely to contain spaces because required default options are passed |
| 1228 | to the compiler. |
| 1229 | |
| 1230 | - Hardcoding paths inside Makefiles is often problematic in a |
| 1231 | cross-compilation environment. This is particularly true because |
| 1232 | those hardcoded paths often point to locations on the build host and |
| 1233 | thus will either be read-only or will introduce contamination into |
| 1234 | the cross-compilation because they are specific to the build host |
| 1235 | rather than the target. Patching the Makefile to use prefix variables |
| 1236 | or other path variables is usually the way to handle this situation. |
| 1237 | |
| 1238 | - Sometimes a Makefile runs target-specific commands such as |
| 1239 | ``ldconfig``. For such cases, you might be able to apply patches that |
| 1240 | remove these commands from the Makefile. |
| 1241 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1242 | Adding Native Tools |
| 1243 | ------------------- |
| 1244 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1245 | Often, you need to build additional tools that run on the :term:`Build Host` |
| 1246 | as opposed to the target. You should indicate this requirement by using one of |
| 1247 | the following methods when you run ``devtool add``: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1248 | |
| 1249 | - Specify the name of the recipe such that it ends with "-native". |
| 1250 | Specifying the name like this produces a recipe that only builds for |
| 1251 | the build host. |
| 1252 | |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1253 | - Specify the "--also-native" option with the ``devtool add`` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1254 | command. Specifying this option creates a recipe file that still |
| 1255 | builds for the target but also creates a variant with a "-native" |
| 1256 | suffix that builds for the build host. |
| 1257 | |
| 1258 | .. note:: |
| 1259 | |
| 1260 | If you need to add a tool that is shipped as part of a source tree |
| 1261 | that builds code for the target, you can typically accomplish this by |
| 1262 | building the native and target parts separately rather than within |
| 1263 | the same compilation process. Realize though that with the |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1264 | "--also-native" option, you can add the tool using just one |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1265 | recipe file. |
| 1266 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1267 | Adding Node.js Modules |
| 1268 | ---------------------- |
| 1269 | |
| 1270 | You can use the ``devtool add`` command two different ways to add |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1271 | Node.js modules: through ``npm`` or from a repository or local source. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1272 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1273 | Use the following form to add Node.js modules through ``npm``:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1274 | |
| 1275 | $ devtool add "npm://registry.npmjs.org;name=forever;version=0.15.1" |
| 1276 | |
| 1277 | The name and |
| 1278 | version parameters are mandatory. Lockdown and shrinkwrap files are |
| 1279 | generated and pointed to by the recipe in order to freeze the version |
| 1280 | that is fetched for the dependencies according to the first time. This |
| 1281 | also saves checksums that are verified on future fetches. Together, |
| 1282 | these behaviors ensure the reproducibility and integrity of the build. |
| 1283 | |
| 1284 | .. note:: |
| 1285 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1286 | - You must use quotes around the URL. ``devtool add`` does not |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1287 | require the quotes, but the shell considers ";" as a splitter |
| 1288 | between multiple commands. Thus, without the quotes, |
| 1289 | ``devtool add`` does not receive the other parts, which results in |
| 1290 | several "command not found" errors. |
| 1291 | |
| 1292 | - In order to support adding Node.js modules, a ``nodejs`` recipe |
| 1293 | must be part of your SDK. |
| 1294 | |
| 1295 | As mentioned earlier, you can also add Node.js modules directly from a |
| 1296 | repository or local source tree. To add modules this way, use |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1297 | ``devtool add`` in the following form:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1298 | |
| 1299 | $ devtool add https://github.com/diversario/node-ssdp |
| 1300 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1301 | In this example, ``devtool`` fetches the specified Git repository, detects the |
| 1302 | code as Node.js code, fetches dependencies using ``npm``, and sets |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1303 | :term:`SRC_URI` accordingly. |
| 1304 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1305 | Working With Recipes |
| 1306 | ==================== |
| 1307 | |
| 1308 | When building a recipe using the ``devtool build`` command, the typical |
| 1309 | build progresses as follows: |
| 1310 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1311 | #. Fetch the source |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1312 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1313 | #. Unpack the source |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1314 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1315 | #. Configure the source |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1316 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1317 | #. Compile the source |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1318 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1319 | #. Install the build output |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1320 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1321 | #. Package the installed output |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1322 | |
| 1323 | For recipes in the workspace, fetching and unpacking is disabled as the |
| 1324 | source tree has already been prepared and is persistent. Each of these |
| 1325 | build steps is defined as a function (task), usually with a "do\_" prefix |
| 1326 | (e.g. :ref:`ref-tasks-fetch`, |
| 1327 | :ref:`ref-tasks-unpack`, and so |
| 1328 | forth). These functions are typically shell scripts but can instead be |
| 1329 | written in Python. |
| 1330 | |
| 1331 | If you look at the contents of a recipe, you will see that the recipe |
| 1332 | does not include complete instructions for building the software. |
| 1333 | Instead, common functionality is encapsulated in classes inherited with |
| 1334 | the ``inherit`` directive. This technique leaves the recipe to describe |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1335 | 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] | 1336 | a :ref:`ref-classes-base` class that is implicitly inherited by all recipes |
| 1337 | and provides the functionality that most recipes typically need. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1338 | |
| 1339 | The remainder of this section presents information useful when working |
| 1340 | with recipes. |
| 1341 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1342 | Finding Logs and Work Files |
| 1343 | --------------------------- |
| 1344 | |
| 1345 | After the first run of the ``devtool build`` command, recipes that were |
| 1346 | previously created using the ``devtool add`` command or whose sources |
| 1347 | were modified using the ``devtool modify`` command contain symbolic |
| 1348 | links created within the source tree: |
| 1349 | |
| 1350 | - ``oe-logs``: This link points to the directory in which log files and |
| 1351 | run scripts for each build step are created. |
| 1352 | |
| 1353 | - ``oe-workdir``: This link points to the temporary work area for the |
| 1354 | recipe. The following locations under ``oe-workdir`` are particularly |
| 1355 | useful: |
| 1356 | |
| 1357 | - ``image/``: Contains all of the files installed during the |
| 1358 | :ref:`ref-tasks-install` stage. |
| 1359 | Within a recipe, this directory is referred to by the expression |
| 1360 | ``${``\ :term:`D`\ ``}``. |
| 1361 | |
| 1362 | - ``sysroot-destdir/``: Contains a subset of files installed within |
Patrick Williams | 2194f50 | 2022-10-16 14:26:09 -0500 | [diff] [blame] | 1363 | :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] | 1364 | more information, see the |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1365 | ":ref:`dev-manual/new-recipe:sharing files between recipes`" section. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1366 | |
| 1367 | - ``packages-split/``: Contains subdirectories for each package |
| 1368 | produced by the recipe. For more information, see the |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 1369 | ":ref:`sdk-manual/extensible:packaging`" section. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1370 | |
| 1371 | You can use these links to get more information on what is happening at |
| 1372 | each build step. |
| 1373 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1374 | Setting Configure Arguments |
| 1375 | --------------------------- |
| 1376 | |
| 1377 | If the software your recipe is building uses GNU autoconf, then a fixed |
| 1378 | set of arguments is passed to it to enable cross-compilation plus any |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1379 | extras specified by :term:`EXTRA_OECONF` or :term:`PACKAGECONFIG_CONFARGS` |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1380 | 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] | 1381 | to :term:`EXTRA_OECONF` or :term:`PACKAGECONFIG_CONFARGS`. Other supported build |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1382 | tools have similar variables (e.g. :term:`EXTRA_OECMAKE` for CMake, |
| 1383 | :term:`EXTRA_OESCONS` for Scons, and so forth). If you need to pass anything on |
| 1384 | the ``make`` command line, you can use :term:`EXTRA_OEMAKE` or the |
| 1385 | :term:`PACKAGECONFIG_CONFARGS` variables to do so. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1386 | |
| 1387 | You can use the ``devtool configure-help`` command to help you set the |
| 1388 | arguments listed in the previous paragraph. The command determines the |
| 1389 | 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] | 1390 | arguments specified through :term:`EXTRA_OECONF` or |
| 1391 | :term:`PACKAGECONFIG_CONFARGS`. If applicable, the command also shows you |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1392 | the output of the configure script's "--help" option as a |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1393 | reference. |
| 1394 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1395 | Sharing Files Between Recipes |
| 1396 | ----------------------------- |
| 1397 | |
| 1398 | Recipes often need to use files provided by other recipes on the |
| 1399 | :term:`Build Host`. For example, |
| 1400 | an application linking to a common library needs access to the library |
| 1401 | 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] | 1402 | 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] | 1403 | "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] | 1404 | 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] | 1405 | the build host. |
| 1406 | |
| 1407 | Recipes should never write files directly into the sysroot. Instead, |
| 1408 | files should be installed into standard locations during the |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1409 | :ref:`ref-tasks-install` task within the ``${``\ :term:`D`\ ``}`` directory. A |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1410 | subset of these files automatically goes into the sysroot. The reason |
| 1411 | for this limitation is that almost all files that go into the sysroot |
| 1412 | are cataloged in manifests in order to ensure they can be removed later |
| 1413 | when a recipe is modified or removed. Thus, the sysroot is able to |
| 1414 | remain free from stale files. |
| 1415 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1416 | Packaging |
| 1417 | --------- |
| 1418 | |
| 1419 | Packaging is not always particularly relevant within the extensible SDK. |
| 1420 | However, if you examine how build output gets into the final image on |
| 1421 | the target device, it is important to understand packaging because the |
| 1422 | contents of the image are expressed in terms of packages and not |
| 1423 | recipes. |
| 1424 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1425 | During the :ref:`ref-tasks-package` task, files installed during the |
| 1426 | :ref:`ref-tasks-install` task are split into one main package, which is almost |
| 1427 | always named the same as the recipe, and into several other packages. This |
| 1428 | separation exists because not all of those installed files are useful in every |
| 1429 | image. For example, you probably do not need any of the documentation installed |
| 1430 | in a production image. Consequently, for each recipe the documentation |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1431 | files are separated into a ``-doc`` package. Recipes that package |
| 1432 | software containing optional modules or plugins might undergo additional |
| 1433 | package splitting as well. |
| 1434 | |
| 1435 | After building a recipe, you can see where files have gone by looking in |
| 1436 | the ``oe-workdir/packages-split`` directory, which contains a |
| 1437 | subdirectory for each package. Apart from some advanced cases, the |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1438 | :term:`PACKAGES` and :term:`FILES` variables controls |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1439 | splitting. The :term:`PACKAGES` variable lists all of the packages to be |
| 1440 | produced, while the :term:`FILES` variable specifies which files to include |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1441 | in each package by using an override to specify the package. For |
Patrick Williams | 0ca19cc | 2021-08-16 14:03:13 -0500 | [diff] [blame] | 1442 | example, ``FILES:${PN}`` specifies the files to go into the main package |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1443 | (i.e. the main package has the same name as the recipe and |
| 1444 | ``${``\ :term:`PN`\ ``}`` evaluates to the |
Andrew Geissler | 0903674 | 2021-06-25 14:25:14 -0500 | [diff] [blame] | 1445 | recipe name). The order of the :term:`PACKAGES` value is significant. For |
| 1446 | each installed file, the first package whose :term:`FILES` value matches the |
| 1447 | file is the package into which the file goes. Both the :term:`PACKAGES` and |
| 1448 | :term:`FILES` variables have default values. Consequently, you might find |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1449 | you do not even need to set these variables in your recipe unless the |
| 1450 | software the recipe is building installs files into non-standard |
| 1451 | locations. |
| 1452 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1453 | Restoring the Target Device to its Original State |
| 1454 | ================================================= |
| 1455 | |
| 1456 | If you use the ``devtool deploy-target`` command to write a recipe's |
| 1457 | build output to the target, and you are working on an existing component |
| 1458 | of the system, then you might find yourself in a situation where you |
| 1459 | need to restore the original files that existed prior to running the |
| 1460 | ``devtool deploy-target`` command. Because the ``devtool deploy-target`` |
| 1461 | command backs up any files it overwrites, you can use the |
| 1462 | ``devtool undeploy-target`` command to restore those files and remove |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1463 | any other files the recipe deployed. Consider the following example:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1464 | |
| 1465 | $ devtool undeploy-target lighttpd root@192.168.7.2 |
| 1466 | |
| 1467 | If you have deployed |
| 1468 | multiple applications, you can remove them all using the "-a" option |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1469 | thus restoring the target device to its original state:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1470 | |
| 1471 | $ devtool undeploy-target -a root@192.168.7.2 |
| 1472 | |
| 1473 | Information about files deployed to |
| 1474 | the target as well as any backed up files are stored on the target |
| 1475 | itself. This storage, of course, requires some additional space on the |
| 1476 | target machine. |
| 1477 | |
| 1478 | .. note:: |
| 1479 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1480 | The ``devtool deploy-target`` and ``devtool undeploy-target`` commands do |
| 1481 | not currently interact with any package management system on the target |
| 1482 | device (e.g. RPM or OPKG). Consequently, you should not intermingle |
| 1483 | ``devtool deploy-target`` and package manager operations on the target |
| 1484 | device. Doing so could result in a conflicting set of files. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1485 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1486 | Installing Additional Items Into the Extensible SDK |
| 1487 | =================================================== |
| 1488 | |
| 1489 | Out of the box the extensible SDK typically only comes with a small |
| 1490 | number of tools and libraries. A minimal SDK starts mostly empty and is |
| 1491 | populated on-demand. Sometimes you must explicitly install extra items |
| 1492 | into the SDK. If you need these extra items, you can first search for |
| 1493 | the items using the ``devtool search`` command. For example, suppose you |
| 1494 | 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] | 1495 | You can use the following command to find out:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1496 | |
| 1497 | $ devtool search libGL mesa |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1498 | A free implementation of the OpenGL API |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1499 | |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1500 | Once you know the recipe |
| 1501 | (i.e. ``mesa`` in this example), you can install it. |
| 1502 | |
| 1503 | When using the extensible SDK directly in a Yocto build |
| 1504 | ------------------------------------------------------- |
| 1505 | |
| 1506 | In this scenario, the Yocto build tooling, e.g. ``bitbake`` |
| 1507 | is directly accessible to build additional items, and it |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1508 | can simply be executed directly:: |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1509 | |
| 1510 | $ bitbake mesa |
Patrick Williams | 975a06f | 2022-10-21 14:42:47 -0500 | [diff] [blame] | 1511 | $ bitbake build-sysroots |
Patrick Williams | 92b42cb | 2022-09-03 06:53:57 -0500 | [diff] [blame] | 1512 | |
| 1513 | When using a standalone installer for the Extensible SDK |
| 1514 | -------------------------------------------------------- |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1515 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1516 | :: |
| 1517 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1518 | $ devtool sdk-install mesa |
| 1519 | |
| 1520 | By default, the ``devtool sdk-install`` command assumes |
| 1521 | the item is available in pre-built form from your SDK provider. If the |
| 1522 | 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] | 1523 | source, you can add the "-s" option as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1524 | |
| 1525 | $ devtool sdk-install -s mesa |
| 1526 | |
| 1527 | It is important to remember that building the item from source |
| 1528 | takes significantly longer than installing the pre-built artifact. Also, |
William A. Kennington III | ac69b48 | 2021-06-02 12:28:27 -0700 | [diff] [blame] | 1529 | 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] | 1530 | instead add the item using the ``devtool add`` command. |
| 1531 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1532 | Applying Updates to an Installed Extensible SDK |
| 1533 | =============================================== |
| 1534 | |
| 1535 | If you are working with an installed extensible SDK that gets |
| 1536 | occasionally updated (e.g. a third-party SDK), then you will need to |
| 1537 | manually "pull down" the updates into the installed SDK. |
| 1538 | |
Andrew Geissler | c926e17 | 2021-05-07 16:11:35 -0500 | [diff] [blame] | 1539 | To update your installed SDK, use ``devtool`` as follows:: |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1540 | |
| 1541 | $ devtool sdk-update |
| 1542 | |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1543 | The previous command assumes your SDK provider has set the default update URL |
| 1544 | for you through the :term:`SDK_UPDATE_URL` variable as described in the |
Andrew Geissler | 3b8a17c | 2021-04-15 15:55:55 -0500 | [diff] [blame] | 1545 | ":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] | 1546 | section. If the SDK provider has not set that default URL, you need to |
Andrew Geissler | 220dafd | 2023-10-04 10:18:08 -0500 | [diff] [blame] | 1547 | specify it yourself in the command as follows:: |
| 1548 | |
| 1549 | $ devtool sdk-update path_to_update_directory |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1550 | |
| 1551 | .. note:: |
| 1552 | |
| 1553 | The URL needs to point specifically to a published SDK and not to an |
| 1554 | SDK installer that you would download and install. |
| 1555 | |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1556 | Creating a Derivative SDK With Additional Components |
| 1557 | ==================================================== |
| 1558 | |
| 1559 | You might need to produce an SDK that contains your own custom |
| 1560 | libraries. A good example would be if you were a vendor with customers |
| 1561 | that use your SDK to build their own platform-specific software and |
| 1562 | those customers need an SDK that has custom libraries. In such a case, |
| 1563 | you can produce a derivative SDK based on the currently installed SDK |
| 1564 | fairly easily by following these steps: |
| 1565 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1566 | #. 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] | 1567 | base for your derivative SDK. |
| 1568 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1569 | #. Source the environment script for the SDK. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1570 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1571 | #. Add the extra libraries or other components you want by using the |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1572 | ``devtool add`` command. |
| 1573 | |
Andrew Geissler | 517393d | 2023-01-13 08:55:19 -0600 | [diff] [blame] | 1574 | #. Run the ``devtool build-sdk`` command. |
Andrew Geissler | c9f7865 | 2020-09-18 14:11:35 -0500 | [diff] [blame] | 1575 | |
| 1576 | The previous steps take the recipes added to the workspace and construct |
| 1577 | a new SDK installer that contains those recipes and the resulting binary |
| 1578 | artifacts. The recipes go into their own separate layer in the |
| 1579 | constructed derivative SDK, which leaves the workspace clean and ready |
| 1580 | for users to add their own recipes. |