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