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