Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1 | <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" |
| 2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" |
| 3 | [<!ENTITY % poky SYSTEM "../poky.ent"> %poky; ] > |
| 4 | |
| 5 | <chapter id='sdk-extensible'> |
| 6 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 7 | <title>Using the Extensible SDK</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 8 | |
| 9 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 10 | This chapter describes the extensible SDK and how to install it. |
| 11 | Information covers the pieces of the SDK, how to install it, and |
| 12 | presents a look at using the <filename>devtool</filename> |
| 13 | functionality. |
| 14 | The extensible SDK makes it easy to add new applications and libraries |
| 15 | to an image, modify the source for an existing component, test |
| 16 | changes on the target hardware, and ease integration into the rest of |
| 17 | the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 18 | <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 19 | <note> |
| 20 | For a side-by-side comparison of main features supported for an |
| 21 | extensible SDK as compared to a standard SDK, see the |
| 22 | "<link linkend='sdk-manual-intro'>Introduction</link>" |
| 23 | section. |
| 24 | </note> |
| 25 | </para> |
| 26 | |
| 27 | <para> |
| 28 | In addition to the functionality available through |
| 29 | <filename>devtool</filename>, you can alternatively make use of the |
| 30 | toolchain directly, for example from Makefile, Autotools, and |
| 31 | Eclipse-based projects. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 32 | See the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 33 | "<link linkend='sdk-working-projects'>Using the SDK Toolchain Directly</link>" |
| 34 | chapter for more information. |
| 35 | </para> |
| 36 | |
| 37 | <section id='sdk-extensible-sdk-intro'> |
| 38 | <title>Why use the Extensible SDK and What is in It?</title> |
| 39 | |
| 40 | <para> |
| 41 | The extensible SDK provides a cross-development toolchain and |
| 42 | libraries tailored to the contents of a specific image. |
| 43 | You would use the Extensible SDK if you want a toolchain experience |
| 44 | supplemented with the powerful set of <filename>devtool</filename> |
| 45 | commands tailored for the Yocto Project environment. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | The installed extensible SDK consists of several files and |
| 50 | directories. |
| 51 | Basically, it contains an SDK environment setup script, some |
| 52 | configuration files, an internal build system, and the |
| 53 | <filename>devtool</filename> functionality. |
| 54 | </para> |
| 55 | </section> |
| 56 | |
| 57 | <section id='sdk-setting-up-to-use-the-extensible-sdk'> |
| 58 | <title>Setting Up to Use the Extensible SDK</title> |
| 59 | |
| 60 | <para> |
| 61 | The first thing you need to do is install the SDK on your host |
| 62 | development machine by running the <filename>*.sh</filename> |
| 63 | installation script. |
| 64 | </para> |
| 65 | |
| 66 | <para> |
| 67 | You can download a tarball installer, which includes the |
| 68 | pre-built toolchain, the <filename>runqemu</filename> |
| 69 | script, the internal build system, <filename>devtool</filename>, |
| 70 | and support files from the appropriate directory under |
| 71 | <ulink url='&YOCTO_TOOLCHAIN_DL_URL;'></ulink>. |
| 72 | Toolchains are available for 32-bit and 64-bit x86 development |
| 73 | systems from the <filename>i686</filename> and |
| 74 | <filename>x86_64</filename> directories, respectively. |
| 75 | The toolchains the Yocto Project provides are based off the |
| 76 | <filename>core-image-sato</filename> image and contain |
| 77 | libraries appropriate for developing against that image. |
| 78 | Each type of development system supports five or more target |
| 79 | architectures. |
| 80 | </para> |
| 81 | |
| 82 | <para> |
| 83 | The names of the tarball installer scripts are such that a |
| 84 | string representing the host system appears first in the |
| 85 | filename and then is immediately followed by a string |
| 86 | representing the target architecture. |
| 87 | An extensible SDK has the string "-ext" as part of the name. |
| 88 | <literallayout class='monospaced'> |
| 89 | poky-glibc-<replaceable>host_system</replaceable>-<replaceable>image_type</replaceable>-<replaceable>arch</replaceable>-toolchain-ext-<replaceable>release_version</replaceable>.sh |
| 90 | |
| 91 | Where: |
| 92 | <replaceable>host_system</replaceable> is a string representing your development system: |
| 93 | |
| 94 | i686 or x86_64. |
| 95 | |
| 96 | <replaceable>image_type</replaceable> is the image for which the SDK was built. |
| 97 | |
| 98 | <replaceable>arch</replaceable> is a string representing the tuned target architecture: |
| 99 | |
| 100 | i586, x86_64, powerpc, mips, armv7a or armv5te |
| 101 | |
| 102 | <replaceable>release_version</replaceable> is a string representing the release number of the |
| 103 | Yocto Project: |
| 104 | |
| 105 | &DISTRO;, &DISTRO;+snapshot |
| 106 | </literallayout> |
| 107 | For example, the following SDK installer is for a 64-bit |
| 108 | development host system and a i586-tuned target architecture |
| 109 | based off the SDK for <filename>core-image-sato</filename> and |
| 110 | using the current &DISTRO; snapshot: |
| 111 | <literallayout class='monospaced'> |
| 112 | poky-glibc-x86_64-core-image-sato-i586-toolchain-ext-&DISTRO;.sh |
| 113 | </literallayout> |
| 114 | <note> |
| 115 | As an alternative to downloading an SDK, you can build the |
| 116 | SDK installer. |
| 117 | For information on building the installer, see the |
| 118 | "<link linkend='sdk-building-an-sdk-installer'>Building an SDK Installer</link>" |
| 119 | section. |
| 120 | Another helpful resource for building an installer is the |
| 121 | <ulink url='https://wiki.yoctoproject.org/wiki/TipsAndTricks/RunningEclipseAgainstBuiltImage'>Cookbook guide to Making an Eclipse Debug Capable Image</ulink> |
| 122 | wiki page. |
| 123 | This wiki page focuses on development when using the Eclipse |
| 124 | IDE. |
| 125 | </note> |
| 126 | </para> |
| 127 | |
| 128 | <para> |
| 129 | The SDK and toolchains are self-contained and by default are |
| 130 | installed into the <filename>poky_sdk</filename> folder in your |
| 131 | home directory. |
| 132 | You can choose to install the extensible SDK in any location when |
| 133 | you run the installer. |
| 134 | However, the location you choose needs to be writable for whichever |
| 135 | users need to use the SDK, since files will need to be written |
| 136 | under that directory during the normal course of operation. |
| 137 | </para> |
| 138 | |
| 139 | <para> |
| 140 | The following command shows how to run the installer given a |
| 141 | toolchain tarball for a 64-bit x86 development host system and |
| 142 | a 64-bit x86 target architecture. |
| 143 | The example assumes the SDK installer is located in |
| 144 | <filename>~/Downloads/</filename>. |
| 145 | <note> |
| 146 | If you do not have write permissions for the directory |
| 147 | into which you are installing the SDK, the installer |
| 148 | notifies you and exits. |
| 149 | Be sure you have write permissions in the directory and |
| 150 | run the installer again. |
| 151 | </note> |
| 152 | <literallayout class='monospaced'> |
| 153 | $ ./poky-glibc-x86_64-core-image-minimal-core2-64-toolchain-ext-&DISTRO;.sh |
| 154 | Poky (Yocto Project Reference Distro) Extensible SDK installer version &DISTRO; |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 155 | =================================================================================== |
| 156 | Enter target directory for SDK (default: ~/poky_sdk): |
| 157 | You are about to install the SDK to "/home/scottrif/poky_sdk". Proceed[Y/n]? Y |
| 158 | Extracting SDK......................................................................done |
| 159 | Setting it up... |
| 160 | Extracting buildtools... |
| 161 | Preparing build system... |
| 162 | done |
| 163 | SDK has been successfully set up and is ready to be used. |
| 164 | Each time you wish to use the SDK in a new shell session, you need to source the environment setup script e.g. |
| 165 | $ . /home/scottrif/poky_sdk/environment-setup-core2-64-poky-linux |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 166 | </literallayout> |
| 167 | </para> |
| 168 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 169 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 170 | <section id='sdk-running-the-extensible-sdk-environment-setup-script'> |
| 171 | <title>Running the Extensible SDK Environment Setup Script</title> |
| 172 | |
| 173 | <para> |
| 174 | Once you have the SDK installed, you must run the SDK environment |
| 175 | setup script before you can actually use it. |
| 176 | This setup script resides in the directory you chose when you |
| 177 | installed the SDK, which is either the default |
| 178 | <filename>poky_sdk</filename> directory or the directory you |
| 179 | chose during installation. |
| 180 | </para> |
| 181 | |
| 182 | <para> |
| 183 | Before running the script, be sure it is the one that matches the |
| 184 | architecture for which you are developing. |
| 185 | Environment setup scripts begin with the string |
| 186 | "<filename>environment-setup</filename>" and include as part of |
| 187 | their name the tuned target architecture. |
| 188 | As an example, the following commands set the working directory |
| 189 | to where the SDK was installed and then source the environment |
| 190 | setup script. |
| 191 | In this example, the setup script is for an IA-based |
| 192 | target machine using i586 tuning: |
| 193 | <literallayout class='monospaced'> |
| 194 | $ cd /home/scottrif/poky_sdk |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 195 | $ source environment-setup-core2-64-poky-linux |
| 196 | SDK environment now set up; additionally you may now run devtool to perform development tasks. |
| 197 | Run devtool --help for further details. |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 198 | </literallayout> |
| 199 | When you run the setup script, many environment variables are |
| 200 | defined: |
| 201 | <literallayout class='monospaced'> |
| 202 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKTARGETSYSROOT'><filename>SDKTARGETSYSROOT</filename></ulink> - The path to the sysroot used for cross-compilation |
| 203 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PKG_CONFIG_PATH'><filename>PKG_CONFIG_PATH</filename></ulink> - The path to the target pkg-config files |
| 204 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIG_SITE'><filename>CONFIG_SITE</filename></ulink> - A GNU autoconf site file preconfigured for the target |
| 205 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink> - The minimal command and arguments to run the C compiler |
| 206 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CXX'><filename>CXX</filename></ulink> - The minimal command and arguments to run the C++ compiler |
| 207 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CPP'><filename>CPP</filename></ulink> - The minimal command and arguments to run the C preprocessor |
| 208 | <ulink url='&YOCTO_DOCS_REF_URL;#var-AS'><filename>AS</filename></ulink> - The minimal command and arguments to run the assembler |
| 209 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LD'><filename>LD</filename></ulink> - The minimal command and arguments to run the linker |
| 210 | <ulink url='&YOCTO_DOCS_REF_URL;#var-GDB'><filename>GDB</filename></ulink> - The minimal command and arguments to run the GNU Debugger |
| 211 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STRIP'><filename>STRIP</filename></ulink> - The minimal command and arguments to run 'strip', which strips symbols |
| 212 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RANLIB'><filename>RANLIB</filename></ulink> - The minimal command and arguments to run 'ranlib' |
| 213 | <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJCOPY'><filename>OBJCOPY</filename></ulink> - The minimal command and arguments to run 'objcopy' |
| 214 | <ulink url='&YOCTO_DOCS_REF_URL;#var-OBJDUMP'><filename>OBJDUMP</filename></ulink> - The minimal command and arguments to run 'objdump' |
| 215 | <ulink url='&YOCTO_DOCS_REF_URL;#var-AR'><filename>AR</filename></ulink> - The minimal command and arguments to run 'ar' |
| 216 | <ulink url='&YOCTO_DOCS_REF_URL;#var-NM'><filename>NM</filename></ulink> - The minimal command and arguments to run 'nm' |
| 217 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_PREFIX'><filename>TARGET_PREFIX</filename></ulink> - The toolchain binary prefix for the target tools |
| 218 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CROSS_COMPILE'><filename>CROSS_COMPILE</filename></ulink> - The toolchain binary prefix for the target tools |
| 219 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CONFIGURE_FLAGS'><filename>CONFIGURE_FLAGS</filename></ulink> - The minimal arguments for GNU configure |
| 220 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CFLAGS'><filename>CFLAGS</filename></ulink> - Suggested C flags |
| 221 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CXXFLAGS'><filename>CXXFLAGS</filename></ulink> - Suggested C++ flags |
| 222 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LDFLAGS'><filename>LDFLAGS</filename></ulink> - Suggested linker flags when you use CC to link |
| 223 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CPPFLAGS'><filename>CPPFLAGS</filename></ulink> - Suggested preprocessor flags |
| 224 | </literallayout> |
| 225 | </para> |
| 226 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 227 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 228 | <section id='using-devtool-in-your-sdk-workflow'> |
| 229 | <title>Using <filename>devtool</filename> in Your SDK Workflow</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 230 | |
| 231 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 232 | The cornerstone of the extensible SDK is a command-line tool |
| 233 | called <filename>devtool</filename>. |
| 234 | This tool provides a number of features that help |
| 235 | you build, test and package software within the extensible SDK, and |
| 236 | optionally integrate it into an image built by the OpenEmbedded |
| 237 | build system. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 238 | <note><title>Tip</title> |
| 239 | The use of <filename>devtool</filename> is not limited to |
| 240 | the extensible SDK. |
| 241 | You can use <filename>devtool</filename> to help you easily |
| 242 | develop any project whose build output must be part of an |
| 243 | image built using the OpenEmbedded build system. |
| 244 | </note> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 245 | </para> |
| 246 | |
| 247 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 248 | The <filename>devtool</filename> command line is organized |
| 249 | similarly to |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 250 | <ulink url='&YOCTO_DOCS_REF_URL;#git'>Git</ulink> in that it has a |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 251 | number of sub-commands for each function. |
| 252 | You can run <filename>devtool --help</filename> to see all the |
| 253 | commands. |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 254 | <note> |
| 255 | See the |
| 256 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-devtool-reference'><filename>devtool</filename> Quick Reference</ulink>" |
| 257 | in the Yocto Project Reference Manual for a |
| 258 | <filename>devtool</filename> quick reference. |
| 259 | </note> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 260 | </para> |
| 261 | |
| 262 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 263 | Three <filename>devtool</filename> subcommands that provide |
| 264 | entry-points into development are: |
| 265 | <itemizedlist> |
| 266 | <listitem><para> |
| 267 | <emphasis><filename>devtool add</filename></emphasis>: |
| 268 | Assists in adding new software to be built. |
| 269 | </para></listitem> |
| 270 | <listitem><para> |
| 271 | <emphasis><filename>devtool modify</filename></emphasis>: |
| 272 | Sets up an environment to enable you to modify the source of |
| 273 | an existing component. |
| 274 | </para></listitem> |
| 275 | <listitem><para> |
| 276 | <emphasis><filename>devtool upgrade</filename></emphasis>: |
| 277 | Updates an existing recipe so that you can build it for |
| 278 | an updated set of source files. |
| 279 | </para></listitem> |
| 280 | </itemizedlist> |
| 281 | As with the OpenEmbedded build system, "recipes" represent software |
| 282 | packages within <filename>devtool</filename>. |
| 283 | When you use <filename>devtool add</filename>, a recipe is |
| 284 | automatically created. |
| 285 | When you use <filename>devtool modify</filename>, the specified |
| 286 | existing recipe is used in order to determine where to get the source |
| 287 | code and how to patch it. |
| 288 | In both cases, an environment is set up so that when you build the |
| 289 | recipe a source tree that is under your control is used in order to |
| 290 | allow you to make changes to the source as desired. |
| 291 | By default, both new recipes and the source go into a "workspace" |
| 292 | directory under the SDK. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 293 | </para> |
| 294 | |
| 295 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 296 | The remainder of this section presents the |
| 297 | <filename>devtool add</filename>, |
| 298 | <filename>devtool modify</filename>, and |
| 299 | <filename>devtool upgrade</filename> workflows. |
| 300 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 301 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 302 | <section id='sdk-use-devtool-to-add-an-application'> |
| 303 | <title>Use <filename>devtool add</filename> to Add an Application</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 304 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 305 | <para> |
| 306 | The <filename>devtool add</filename> command generates |
| 307 | a new recipe based on existing source code. |
| 308 | This command takes advantage of the |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 309 | <ulink url='&YOCTO_DOCS_REF_URL;#devtool-the-workspace-layer-structure'>workspace</ulink> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 310 | layer that many <filename>devtool</filename> commands |
| 311 | use. |
| 312 | The command is flexible enough to allow you to extract source |
| 313 | code into both the workspace or a separate local Git repository |
| 314 | and to use existing code that does not need to be extracted. |
| 315 | </para> |
| 316 | |
| 317 | <para> |
| 318 | Depending on your particular scenario, the arguments and options |
| 319 | you use with <filename>devtool add</filename> form different |
| 320 | combinations. |
| 321 | The following diagram shows common development flows |
| 322 | you would use with the <filename>devtool add</filename> |
| 323 | command: |
| 324 | </para> |
| 325 | |
| 326 | <para> |
| 327 | <imagedata fileref="figures/sdk-devtool-add-flow.png" align="center" /> |
| 328 | </para> |
| 329 | |
| 330 | <para> |
| 331 | <orderedlist> |
| 332 | <listitem><para><emphasis>Generating the New Recipe</emphasis>: |
| 333 | The top part of the flow shows three scenarios by which |
| 334 | you could use <filename>devtool add</filename> to |
| 335 | generate a recipe based on existing source code.</para> |
| 336 | |
| 337 | <para>In a shared development environment, it is |
| 338 | typical where other developers are responsible for |
| 339 | various areas of source code. |
| 340 | As a developer, you are probably interested in using |
| 341 | that source code as part of your development using |
| 342 | the Yocto Project. |
| 343 | All you need is access to the code, a recipe, and a |
| 344 | controlled area in which to do your work.</para> |
| 345 | |
| 346 | <para>Within the diagram, three possible scenarios |
| 347 | feed into the <filename>devtool add</filename> workflow: |
| 348 | <itemizedlist> |
| 349 | <listitem><para><emphasis>Left</emphasis>: |
| 350 | The left scenario represents a common situation |
| 351 | where the source code does not exist locally |
| 352 | and needs to be extracted. |
| 353 | In this situation, you just let it get |
| 354 | extracted to the default workspace - you do not |
| 355 | want it in some specific location outside of the |
| 356 | workspace. |
| 357 | Thus, everything you need will be located in the |
| 358 | workspace: |
| 359 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 360 | $ devtool add <replaceable>recipe fetchuri</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 361 | </literallayout> |
| 362 | With this command, <filename>devtool</filename> |
| 363 | creates a recipe and an append file in the |
| 364 | workspace as well as extracts the upstream |
| 365 | source files into a local Git repository also |
| 366 | within the <filename>sources</filename> folder. |
| 367 | </para></listitem> |
| 368 | <listitem><para><emphasis>Middle</emphasis>: |
| 369 | The middle scenario also represents a situation where |
| 370 | the source code does not exist locally. |
| 371 | In this case, the code is again upstream |
| 372 | and needs to be extracted to some |
| 373 | local area - this time outside of the default |
| 374 | workspace. |
| 375 | If required, <filename>devtool</filename> |
| 376 | always creates |
| 377 | a Git repository locally during the extraction. |
| 378 | Furthermore, the first positional argument |
| 379 | <replaceable>srctree</replaceable> in this case |
| 380 | identifies where the |
| 381 | <filename>devtool add</filename> command |
| 382 | will locate the extracted code outside of the |
| 383 | workspace: |
| 384 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 385 | $ devtool add <replaceable>recipe srctree fetchuri</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 386 | </literallayout> |
| 387 | In summary, the source code is pulled from |
| 388 | <replaceable>fetchuri</replaceable> and extracted |
| 389 | into the location defined by |
| 390 | <replaceable>srctree</replaceable> as a local |
| 391 | Git repository.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 392 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 393 | <para>Within workspace, <filename>devtool</filename> |
| 394 | creates both the recipe and an append file |
| 395 | for the recipe. |
| 396 | </para></listitem> |
| 397 | <listitem><para><emphasis>Right</emphasis>: |
| 398 | The right scenario represents a situation |
| 399 | where the source tree (srctree) has been |
| 400 | previously prepared outside of the |
| 401 | <filename>devtool</filename> workspace. |
| 402 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 403 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 404 | <para>The following command names the recipe |
| 405 | and identifies where the existing source tree |
| 406 | is located: |
| 407 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 408 | $ devtool add <replaceable>recipe srctree</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 409 | </literallayout> |
| 410 | The command examines the source code and creates |
| 411 | a recipe for it placing the recipe into the |
| 412 | workspace.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 413 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 414 | <para>Because the extracted source code already exists, |
| 415 | <filename>devtool</filename> does not try to |
| 416 | relocate it into the workspace - just the new |
| 417 | the recipe is placed in the workspace.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 418 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 419 | <para>Aside from a recipe folder, the command |
| 420 | also creates an append folder and places an initial |
| 421 | <filename>*.bbappend</filename> within. |
| 422 | </para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 423 | </itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 424 | </para></listitem> |
| 425 | <listitem><para><emphasis>Edit the Recipe</emphasis>: |
| 426 | At this point, you can use <filename>devtool edit-recipe</filename> |
| 427 | to open up the editor as defined by the |
| 428 | <filename>$EDITOR</filename> environment variable |
| 429 | and modify the file: |
| 430 | <literallayout class='monospaced'> |
| 431 | $ devtool edit-recipe <replaceable>recipe</replaceable> |
| 432 | </literallayout> |
| 433 | From within the editor, you can make modifications to the |
| 434 | recipe that take affect when you build it later. |
| 435 | </para></listitem> |
| 436 | <listitem><para><emphasis>Build the Recipe or Rebuild the Image</emphasis>: |
| 437 | At this point in the flow, the next step you |
| 438 | take depends on what you are going to do with |
| 439 | the new code.</para> |
| 440 | <para>If you need to take the build output and eventually |
| 441 | move it to the target hardware, you would use |
| 442 | <filename>devtool build</filename>: |
| 443 | <literallayout class='monospaced'> |
| 444 | $ devtool build <replaceable>recipe</replaceable> |
| 445 | </literallayout></para> |
| 446 | <para>On the other hand, if you want an image to |
| 447 | contain the recipe's packages for immediate deployment |
| 448 | onto a device (e.g. for testing purposes), you can use |
| 449 | the <filename>devtool build-image</filename> command: |
| 450 | <literallayout class='monospaced'> |
| 451 | $ devtool build-image <replaceable>image</replaceable> |
| 452 | </literallayout> |
| 453 | </para></listitem> |
| 454 | <listitem><para><emphasis>Deploy the Build Output</emphasis>: |
| 455 | When you use the <filename>devtool build</filename> |
| 456 | command to build out your recipe, you probably want to |
| 457 | see if the resulting build output works as expected on target |
| 458 | hardware. |
| 459 | <note> |
| 460 | This step assumes you have a previously built |
| 461 | image that is already either running in QEMU or |
| 462 | running on actual hardware. |
| 463 | Also, it is assumed that for deployment of the image |
| 464 | to the target, SSH is installed in the image and if |
| 465 | the image is running on real hardware that you have |
| 466 | network access to and from your development machine. |
| 467 | </note> |
| 468 | You can deploy your build output to that target hardware by |
| 469 | using the <filename>devtool deploy-target</filename> command: |
| 470 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 471 | $ devtool deploy-target <replaceable>recipe target</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 472 | </literallayout> |
| 473 | The <replaceable>target</replaceable> is a live target machine |
| 474 | running as an SSH server.</para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 475 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 476 | <para>You can, of course, also deploy the image you build |
| 477 | using the <filename>devtool build-image</filename> command |
| 478 | to actual hardware. |
| 479 | However, <filename>devtool</filename> does not provide a |
| 480 | specific command that allows you to do this. |
| 481 | </para></listitem> |
| 482 | <listitem><para> |
| 483 | <emphasis>Finish Your Work With the Recipe</emphasis>: |
| 484 | The <filename>devtool finish</filename> command creates |
| 485 | any patches corresponding to commits in the local |
| 486 | Git repository, moves the new recipe to a more permanent |
| 487 | layer, and then resets the recipe so that the recipe is |
| 488 | built normally rather than from the workspace. |
| 489 | <literallayout class='monospaced'> |
| 490 | $ devtool finish <replaceable>recipe layer</replaceable> |
| 491 | </literallayout> |
| 492 | <note> |
| 493 | Any changes you want to turn into patches must be |
| 494 | committed to the Git repository in the source tree. |
| 495 | </note></para> |
| 496 | |
| 497 | <para>As mentioned, the <filename>devtool finish</filename> |
| 498 | command moves the final recipe to its permanent layer. |
| 499 | </para> |
| 500 | |
| 501 | <para>As a final process of the |
| 502 | <filename>devtool finish</filename> command, the state |
| 503 | of the standard layers and the upstream source is |
| 504 | restored so that you can build the recipe from those |
| 505 | areas rather than the workspace. |
| 506 | <note> |
| 507 | You can use the <filename>devtool reset</filename> |
| 508 | command to put things back should you decide you |
| 509 | do not want to proceed with your work. |
| 510 | If you do use this command, realize that the source |
| 511 | tree is preserved. |
| 512 | </note> |
| 513 | </para></listitem> |
| 514 | </orderedlist> |
| 515 | </para> |
| 516 | </section> |
| 517 | |
| 518 | <section id='sdk-devtool-use-devtool-modify-to-modify-the-source-of-an-existing-component'> |
| 519 | <title>Use <filename>devtool modify</filename> to Modify the Source of an Existing Component</title> |
| 520 | |
| 521 | <para> |
| 522 | The <filename>devtool modify</filename> command prepares the |
| 523 | way to work on existing code that already has a recipe in |
| 524 | place. |
| 525 | The command is flexible enough to allow you to extract code, |
| 526 | specify the existing recipe, and keep track of and gather any |
| 527 | patch files from other developers that are |
| 528 | associated with the code. |
| 529 | </para> |
| 530 | |
| 531 | <para> |
| 532 | Depending on your particular scenario, the arguments and options |
| 533 | you use with <filename>devtool modify</filename> form different |
| 534 | combinations. |
| 535 | The following diagram shows common development flows |
| 536 | you would use with the <filename>devtool modify</filename> |
| 537 | command: |
| 538 | </para> |
| 539 | |
| 540 | <para> |
| 541 | <imagedata fileref="figures/sdk-devtool-modify-flow.png" align="center" /> |
| 542 | </para> |
| 543 | |
| 544 | <para> |
| 545 | <orderedlist> |
| 546 | <listitem><para><emphasis>Preparing to Modify the Code</emphasis>: |
| 547 | The top part of the flow shows three scenarios by which |
| 548 | you could use <filename>devtool modify</filename> to |
| 549 | prepare to work on source files. |
| 550 | Each scenario assumes the following: |
| 551 | <itemizedlist> |
| 552 | <listitem><para>The recipe exists in some layer external |
| 553 | to the <filename>devtool</filename> workspace. |
| 554 | </para></listitem> |
| 555 | <listitem><para>The source files exist upstream in an |
| 556 | un-extracted state or locally in a previously |
| 557 | extracted state. |
| 558 | </para></listitem> |
| 559 | </itemizedlist> |
| 560 | The typical situation is where another developer has |
| 561 | created some layer for use with the Yocto Project and |
| 562 | their recipe already resides in that layer. |
| 563 | Furthermore, their source code is readily available |
| 564 | either upstream or locally. |
| 565 | <itemizedlist> |
| 566 | <listitem><para><emphasis>Left</emphasis>: |
| 567 | The left scenario represents a common situation |
| 568 | where the source code does not exist locally |
| 569 | and needs to be extracted. |
| 570 | In this situation, the source is extracted |
| 571 | into the default workspace location. |
| 572 | The recipe, in this scenario, is in its own |
| 573 | layer outside the workspace |
| 574 | (i.e. |
| 575 | <filename>meta-</filename><replaceable>layername</replaceable>). |
| 576 | </para> |
| 577 | |
| 578 | <para>The following command identifies the recipe |
| 579 | and by default extracts the source files: |
| 580 | <literallayout class='monospaced'> |
| 581 | $ devtool modify <replaceable>recipe</replaceable> |
| 582 | </literallayout> |
| 583 | Once <filename>devtool</filename>locates the recipe, |
| 584 | it uses the |
| 585 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 586 | variable to locate the source code and |
| 587 | any local patch files from other developers are |
| 588 | located. |
| 589 | <note> |
| 590 | You cannot provide an URL for |
| 591 | <replaceable>srctree</replaceable> when using the |
| 592 | <filename>devtool modify</filename> command. |
| 593 | </note> |
| 594 | With this scenario, however, since no |
| 595 | <replaceable>srctree</replaceable> argument exists, the |
| 596 | <filename>devtool modify</filename> command by default |
| 597 | extracts the source files to a Git structure. |
| 598 | Furthermore, the location for the extracted source is the |
| 599 | default area within the workspace. |
| 600 | The result is that the command sets up both the source |
| 601 | code and an append file within the workspace with the |
| 602 | recipe remaining in its original location. |
| 603 | </para></listitem> |
| 604 | <listitem><para><emphasis>Middle</emphasis>: |
| 605 | The middle scenario represents a situation where |
| 606 | the source code also does not exist locally. |
| 607 | In this case, the code is again upstream |
| 608 | and needs to be extracted to some |
| 609 | local area as a Git repository. |
| 610 | The recipe, in this scenario, is again in its own |
| 611 | layer outside the workspace.</para> |
| 612 | |
| 613 | <para>The following command tells |
| 614 | <filename>devtool</filename> what recipe with |
| 615 | which to work and, in this case, identifies a local |
| 616 | area for the extracted source files that is outside |
| 617 | of the default workspace: |
| 618 | <literallayout class='monospaced'> |
| 619 | $ devtool modify <replaceable>recipe srctree</replaceable> |
| 620 | </literallayout> |
| 621 | As with all extractions, the command uses |
| 622 | the recipe's <filename>SRC_URI</filename> to locate the |
| 623 | source files. |
| 624 | Once the files are located, the command by default |
| 625 | extracts them. |
| 626 | Providing the <replaceable>srctree</replaceable> |
| 627 | argument instructs <filename>devtool</filename> where |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 628 | to place the extracted source.</para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 629 | |
| 630 | <para>Within workspace, <filename>devtool</filename> |
| 631 | creates an append file for the recipe. |
| 632 | The recipe remains in its original location but |
| 633 | the source files are extracted to the location you |
| 634 | provided with <replaceable>srctree</replaceable>. |
| 635 | </para></listitem> |
| 636 | <listitem><para><emphasis>Right</emphasis>: |
| 637 | The right scenario represents a situation |
| 638 | where the source tree |
| 639 | (<replaceable>srctree</replaceable>) exists as a |
| 640 | previously extracted Git structure outside of |
| 641 | the <filename>devtool</filename> workspace. |
| 642 | In this example, the recipe also exists |
| 643 | elsewhere in its own layer. |
| 644 | </para> |
| 645 | |
| 646 | <para>The following command tells |
| 647 | <filename>devtool</filename> the recipe |
| 648 | with which to work, uses the "-n" option to indicate |
| 649 | source does not need to be extracted, and uses |
| 650 | <replaceable>srctree</replaceable> to point to the |
| 651 | previously extracted source files: |
| 652 | <literallayout class='monospaced'> |
| 653 | $ devtool modify -n <replaceable>recipe srctree</replaceable> |
| 654 | </literallayout> |
| 655 | </para> |
| 656 | |
| 657 | <para>Once the command finishes, it creates only |
| 658 | an append file for the recipe in the workspace. |
| 659 | The recipe and the source code remain in their |
| 660 | original locations. |
| 661 | </para></listitem> |
| 662 | </itemizedlist> |
| 663 | </para></listitem> |
| 664 | <listitem><para><emphasis>Edit the Source</emphasis>: |
| 665 | Once you have used the <filename>devtool modify</filename> |
| 666 | command, you are free to make changes to the source |
| 667 | files. |
| 668 | You can use any editor you like to make and save |
| 669 | your source code modifications. |
| 670 | </para></listitem> |
| 671 | <listitem><para><emphasis>Build the Recipe</emphasis>: |
| 672 | Once you have updated the source files, you can build |
| 673 | the recipe. |
| 674 | </para></listitem> |
| 675 | <listitem><para><emphasis>Deploy the Build Output</emphasis>: |
| 676 | When you use the <filename>devtool build</filename> |
| 677 | command to build out your recipe, you probably want to see |
| 678 | if the resulting build output works as expected on target |
| 679 | hardware. |
| 680 | <note> |
| 681 | This step assumes you have a previously built |
| 682 | image that is already either running in QEMU or |
| 683 | running on actual hardware. |
| 684 | Also, it is assumed that for deployment of the image |
| 685 | to the target, SSH is installed in the image and if |
| 686 | the image is running on real hardware that you have |
| 687 | network access to and from your development machine. |
| 688 | </note> |
| 689 | You can deploy your build output to that target hardware by |
| 690 | using the <filename>devtool deploy-target</filename> command: |
| 691 | <literallayout class='monospaced'> |
| 692 | $ devtool deploy-target <replaceable>recipe target</replaceable> |
| 693 | </literallayout> |
| 694 | The <replaceable>target</replaceable> is a live target machine |
| 695 | running as an SSH server.</para> |
| 696 | |
| 697 | <para>You can, of course, also deploy the image you build |
| 698 | using the <filename>devtool build-image</filename> command |
| 699 | to actual hardware. |
| 700 | However, <filename>devtool</filename> does not provide a |
| 701 | specific command that allows you to do this. |
| 702 | </para></listitem> |
| 703 | <listitem><para> |
| 704 | <emphasis>Finish Your Work With the Recipe</emphasis>: |
| 705 | The <filename>devtool finish</filename> command creates |
| 706 | any patches corresponding to commits in the local |
| 707 | Git repository, updates the recipe to point to them |
| 708 | (or creates a <filename>.bbappend</filename> file to do |
| 709 | so, depending on the specified destination layer), and |
| 710 | then resets the recipe so that the recipe is built normally |
| 711 | rather than from the workspace. |
| 712 | <literallayout class='monospaced'> |
| 713 | $ devtool finish <replaceable>recipe layer</replaceable> |
| 714 | </literallayout> |
| 715 | <note> |
| 716 | Any changes you want to turn into patches must be |
| 717 | committed to the Git repository in the source tree. |
| 718 | </note></para> |
| 719 | |
| 720 | <para>Because there is no need to move the recipe, |
| 721 | <filename>devtool finish</filename> either updates the |
| 722 | original recipe in the original layer or the command |
| 723 | creates a <filename>.bbappend</filename> in a different |
| 724 | layer as provided by <replaceable>layer</replaceable>. |
| 725 | </para> |
| 726 | |
| 727 | <para>As a final process of the |
| 728 | <filename>devtool finish</filename> command, the state |
| 729 | of the standard layers and the upstream source is |
| 730 | restored so that you can build the recipe from those |
| 731 | areas rather than the workspace. |
| 732 | <note> |
| 733 | You can use the <filename>devtool reset</filename> |
| 734 | command to put things back should you decide you |
| 735 | do not want to proceed with your work. |
| 736 | If you do use this command, realize that the source |
| 737 | tree is preserved. |
| 738 | </note> |
| 739 | </para></listitem> |
| 740 | </orderedlist> |
| 741 | </para> |
| 742 | </section> |
| 743 | |
| 744 | <section id='sdk-devtool-use-devtool-upgrade-to-create-a-version-of-the-recipe-that-supports-a-newer-version-of-the-software'> |
| 745 | <title>Use <filename>devtool upgrade</filename> to Create a Version of the Recipe that Supports a Newer Version of the Software</title> |
| 746 | |
| 747 | <para> |
| 748 | The <filename>devtool upgrade</filename> command updates |
| 749 | an existing recipe so that you can build it for an updated |
| 750 | set of source files. |
| 751 | The command is flexible enough to allow you to specify |
| 752 | source code revision and versioning schemes, extract code into |
| 753 | or out of the <filename>devtool</filename> workspace, and |
| 754 | work with any source file forms that the fetchers support. |
| 755 | </para> |
| 756 | |
| 757 | <para> |
| 758 | Depending on your particular scenario, the arguments and options |
| 759 | you use with <filename>devtool upgrade</filename> form different |
| 760 | combinations. |
| 761 | The following diagram shows a common development flow |
| 762 | you would use with the <filename>devtool modify</filename> |
| 763 | command: |
| 764 | </para> |
| 765 | |
| 766 | <para> |
| 767 | <imagedata fileref="figures/sdk-devtool-upgrade-flow.png" align="center" /> |
| 768 | </para> |
| 769 | |
| 770 | <para> |
| 771 | <orderedlist> |
| 772 | <listitem><para><emphasis>Initiate the Upgrade</emphasis>: |
| 773 | The top part of the flow shows a typical scenario by which |
| 774 | you could use <filename>devtool upgrade</filename>. |
| 775 | The following conditions exist: |
| 776 | <itemizedlist> |
| 777 | <listitem><para>The recipe exists in some layer external |
| 778 | to the <filename>devtool</filename> workspace. |
| 779 | </para></listitem> |
| 780 | <listitem><para>The source files for the new release |
| 781 | exist adjacent to the same location pointed to by |
| 782 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 783 | in the recipe (e.g. a tarball with the new version |
| 784 | number in the name, or as a different revision in |
| 785 | the upstream Git repository). |
| 786 | </para></listitem> |
| 787 | </itemizedlist> |
| 788 | A common situation is where third-party software has |
| 789 | undergone a revision so that it has been upgraded. |
| 790 | The recipe you have access to is likely in your own layer. |
| 791 | Thus, you need to upgrade the recipe to use the |
| 792 | newer version of the software: |
| 793 | <literallayout class='monospaced'> |
| 794 | $ devtool upgrade -V <replaceable>version recipe</replaceable> |
| 795 | </literallayout> |
| 796 | By default, the <filename>devtool upgrade</filename> command |
| 797 | extracts source code into the <filename>sources</filename> |
| 798 | directory in the workspace. |
| 799 | If you want the code extracted to any other location, you |
| 800 | need to provide the <replaceable>srctree</replaceable> |
| 801 | positional argument with the command as follows: |
| 802 | <literallayout class='monospaced'> |
| 803 | $ devtool upgrade -V <replaceable>version recipe srctree</replaceable> |
| 804 | </literallayout> |
| 805 | Also, in this example, the "-V" option is used to specify |
| 806 | the new version. |
| 807 | If the source files pointed to by the |
| 808 | <filename>SRC_URI</filename> statement in the recipe are |
| 809 | in a Git repository, you must provide the "-S" option and |
| 810 | specify a revision for the software.</para> |
| 811 | |
| 812 | <para>Once <filename>devtool</filename> locates the recipe, |
| 813 | it uses the <filename>SRC_URI</filename> variable to locate |
| 814 | the source code and any local patch files from other |
| 815 | developers are located. |
| 816 | The result is that the command sets up the source |
| 817 | code, the new version of the recipe, and an append file |
| 818 | all within the workspace. |
| 819 | </para></listitem> |
| 820 | <listitem><para><emphasis>Resolve any Conflicts created by the Upgrade</emphasis>: |
| 821 | At this point, there could be some conflicts due to the |
| 822 | software being upgraded to a new version. |
| 823 | This would occur if your recipe specifies some patch files in |
| 824 | <filename>SRC_URI</filename> that conflict with changes |
| 825 | made in the new version of the software. |
| 826 | If this is the case, you need to resolve the conflicts |
| 827 | by editing the source and following the normal |
| 828 | <filename>git rebase</filename> conflict resolution |
| 829 | process.</para> |
| 830 | <para>Before moving onto the next step, be sure to resolve any |
| 831 | such conflicts created through use of a newer or different |
| 832 | version of the software. |
| 833 | </para></listitem> |
| 834 | <listitem><para><emphasis>Build the Recipe</emphasis>: |
| 835 | Once you have your recipe in order, you can build it. |
| 836 | You can either use <filename>devtool build</filename> or |
| 837 | <filename>bitbake</filename>. |
| 838 | Either method produces build output that is stored |
| 839 | in |
| 840 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink>. |
| 841 | </para></listitem> |
| 842 | <listitem><para><emphasis>Deploy the Build Output</emphasis>: |
| 843 | When you use the <filename>devtool build</filename> |
| 844 | command or <filename>bitbake</filename> to build out your |
| 845 | recipe, you probably want to see if the resulting build |
| 846 | output works as expected on target hardware. |
| 847 | <note> |
| 848 | This step assumes you have a previously built |
| 849 | image that is already either running in QEMU or |
| 850 | running on actual hardware. |
| 851 | Also, it is assumed that for deployment of the image |
| 852 | to the target, SSH is installed in the image and if |
| 853 | the image is running on real hardware that you have |
| 854 | network access to and from your development machine. |
| 855 | </note> |
| 856 | You can deploy your build output to that target hardware by |
| 857 | using the <filename>devtool deploy-target</filename> command: |
| 858 | <literallayout class='monospaced'> |
| 859 | $ devtool deploy-target <replaceable>recipe target</replaceable> |
| 860 | </literallayout> |
| 861 | The <replaceable>target</replaceable> is a live target machine |
| 862 | running as an SSH server.</para> |
| 863 | <para>You can, of course, also deploy the image you build |
| 864 | using the <filename>devtool build-image</filename> command |
| 865 | to actual hardware. |
| 866 | However, <filename>devtool</filename> does not provide a |
| 867 | specific command that allows you to do this. |
| 868 | </para></listitem> |
| 869 | <listitem><para> |
| 870 | <emphasis>Finish Your Work With the Recipe</emphasis>: |
| 871 | The <filename>devtool finish</filename> command creates |
| 872 | any patches corresponding to commits in the local |
| 873 | Git repository, moves the new recipe to a more permanent |
| 874 | layer, and then resets the recipe so that the recipe is |
| 875 | built normally rather than from the workspace. |
| 876 | If you specify a destination layer that is the same as |
| 877 | the original source, then the old version of the |
| 878 | recipe and associated files will be removed prior to |
| 879 | adding the new version. |
| 880 | <literallayout class='monospaced'> |
| 881 | $ devtool finish <replaceable>recipe layer</replaceable> |
| 882 | </literallayout> |
| 883 | <note> |
| 884 | Any changes you want to turn into patches must be |
| 885 | committed to the Git repository in the source tree. |
| 886 | </note></para> |
| 887 | <para>As a final process of the |
| 888 | <filename>devtool finish</filename> command, the state |
| 889 | of the standard layers and the upstream source is |
| 890 | restored so that you can build the recipe from those |
| 891 | areas rather than the workspace. |
| 892 | <note> |
| 893 | You can use the <filename>devtool reset</filename> |
| 894 | command to put things back should you decide you |
| 895 | do not want to proceed with your work. |
| 896 | If you do use this command, realize that the source |
| 897 | tree is preserved. |
| 898 | </note> |
| 899 | </para></listitem> |
| 900 | </orderedlist> |
| 901 | </para> |
| 902 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 903 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 904 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 905 | <section id='sdk-a-closer-look-at-devtool-add'> |
| 906 | <title>A Closer Look at <filename>devtool add</filename></title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 907 | |
| 908 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 909 | The <filename>devtool add</filename> command automatically creates a |
| 910 | recipe based on the source tree with which you provide it. |
| 911 | Currently, the command has support for the following: |
| 912 | <itemizedlist> |
| 913 | <listitem><para> |
| 914 | Autotools (<filename>autoconf</filename> and |
| 915 | <filename>automake</filename>) |
| 916 | </para></listitem> |
| 917 | <listitem><para> |
| 918 | CMake |
| 919 | </para></listitem> |
| 920 | <listitem><para> |
| 921 | Scons |
| 922 | </para></listitem> |
| 923 | <listitem><para> |
| 924 | <filename>qmake</filename> |
| 925 | </para></listitem> |
| 926 | <listitem><para> |
| 927 | Plain <filename>Makefile</filename> |
| 928 | </para></listitem> |
| 929 | <listitem><para> |
| 930 | Out-of-tree kernel module |
| 931 | </para></listitem> |
| 932 | <listitem><para> |
| 933 | Binary package (i.e. "-b" option) |
| 934 | </para></listitem> |
| 935 | <listitem><para> |
| 936 | Node.js module |
| 937 | </para></listitem> |
| 938 | <listitem><para> |
| 939 | Python modules that use <filename>setuptools</filename> |
| 940 | or <filename>distutils</filename> |
| 941 | </para></listitem> |
| 942 | </itemizedlist> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 943 | </para> |
| 944 | |
| 945 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 946 | Apart from binary packages, the determination of how a source tree |
| 947 | should be treated is automatic based on the files present within |
| 948 | that source tree. |
| 949 | For example, if a <filename>CMakeLists.txt</filename> file is found, |
| 950 | then the source tree is assumed to be using |
| 951 | CMake and is treated accordingly. |
| 952 | <note> |
| 953 | In most cases, you need to edit the automatically generated |
| 954 | recipe in order to make it build properly. |
| 955 | Typically, you would go through several edit and build cycles |
| 956 | until you can build the recipe. |
| 957 | Once the recipe can be built, you could use possible further |
| 958 | iterations to test the recipe on the target device. |
| 959 | </note> |
| 960 | </para> |
| 961 | |
| 962 | <para> |
| 963 | The remainder of this section covers specifics regarding how parts |
| 964 | of the recipe are generated. |
| 965 | </para> |
| 966 | |
| 967 | <section id='sdk-name-and-version'> |
| 968 | <title>Name and Version</title> |
| 969 | |
| 970 | <para> |
| 971 | If you do not specify a name and version on the command |
| 972 | line, <filename>devtool add</filename> attempts to determine |
| 973 | the name and version of the software being built from |
| 974 | various metadata within the source tree. |
| 975 | Furthermore, the command sets the name of the created recipe |
| 976 | file accordingly. |
| 977 | If the name or version cannot be determined, the |
| 978 | <filename>devtool add</filename> command prints an error and |
| 979 | you must re-run the command with both the name and version |
| 980 | or just the name or version specified. |
| 981 | </para> |
| 982 | |
| 983 | <para> |
| 984 | Sometimes the name or version determined from the source tree |
| 985 | might be incorrect. |
| 986 | For such a case, you must reset the recipe: |
| 987 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 988 | $ devtool reset -n <replaceable>recipename</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 989 | </literallayout> |
| 990 | After running the <filename>devtool reset</filename> command, |
| 991 | you need to run <filename>devtool add</filename> again and |
| 992 | provide the name or the version. |
| 993 | </para> |
| 994 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 995 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 996 | <section id='sdk-dependency-detection-and-mapping'> |
| 997 | <title>Dependency Detection and Mapping</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 998 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 999 | <para> |
| 1000 | The <filename>devtool add</filename> command attempts to |
| 1001 | detect build-time dependencies and map them to other recipes |
| 1002 | in the system. |
| 1003 | During this mapping, the command fills in the names of those |
| 1004 | recipes in the |
| 1005 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPENDS'><filename>DEPENDS</filename></ulink> |
| 1006 | value within the recipe. |
| 1007 | If a dependency cannot be mapped, then a comment is placed in |
| 1008 | the recipe indicating such. |
| 1009 | The inability to map a dependency might be caused because the |
| 1010 | naming is not recognized or because the dependency simply is |
| 1011 | not available. |
| 1012 | For cases where the dependency is not available, you must use |
| 1013 | the <filename>devtool add</filename> command to add an |
| 1014 | additional recipe to satisfy the dependency and then come |
| 1015 | back to the first recipe and add its name to |
| 1016 | <filename>DEPENDS</filename>. |
| 1017 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1018 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1019 | <para> |
| 1020 | If you need to add runtime dependencies, you can do so by |
| 1021 | adding the following to your recipe: |
| 1022 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1023 | RDEPENDS_${PN} += "dependency1 dependency2 ..." |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1024 | </literallayout> |
| 1025 | <note> |
| 1026 | The <filename>devtool add</filename> command often cannot |
| 1027 | distinguish between mandatory and optional dependencies. |
| 1028 | Consequently, some of the detected dependencies might |
| 1029 | in fact be optional. |
| 1030 | When in doubt, consult the documentation or the configure |
| 1031 | script for the software the recipe is building for further |
| 1032 | details. |
| 1033 | In some cases, you might find you can substitute the |
| 1034 | dependency for an option to disable the associated |
| 1035 | functionality passed to the configure script. |
| 1036 | </note> |
| 1037 | </para> |
| 1038 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1039 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1040 | <section id='sdk-license-detection'> |
| 1041 | <title>License Detection</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1042 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1043 | <para> |
| 1044 | The <filename>devtool add</filename> command attempts to |
| 1045 | determine if the software you are adding is able to be |
| 1046 | distributed under a common open-source license and sets the |
| 1047 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LICENSE'><filename>LICENSE</filename></ulink> |
| 1048 | value accordingly. |
| 1049 | You should double-check this value against the documentation |
| 1050 | or source files for the software you are building and update |
| 1051 | that <filename>LICENSE</filename> value if necessary. |
| 1052 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1053 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1054 | <para> |
| 1055 | The <filename>devtool add</filename> command also sets the |
| 1056 | <ulink url='&YOCTO_DOCS_REF_URL;#var-LIC_FILES_CHKSUM'><filename>LIC_FILES_CHKSUM</filename></ulink> |
| 1057 | value to point to all files that appear to be license-related. |
| 1058 | However, license statements often appear in comments at the top |
| 1059 | of source files or within documentation. |
| 1060 | Consequently, you might need to amend the |
| 1061 | <filename>LIC_FILES_CHKSUM</filename> variable to point to one |
| 1062 | or more of those comments if present. |
| 1063 | Setting <filename>LIC_FILES_CHKSUM</filename> is particularly |
| 1064 | important for third-party software. |
| 1065 | The mechanism attempts to ensure correct licensing should you |
| 1066 | upgrade the recipe to a newer upstream version in future. |
| 1067 | Any change in licensing is detected and you receive an error |
| 1068 | prompting you to check the license text again. |
| 1069 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1070 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1071 | <para> |
| 1072 | If the <filename>devtool add</filename> command cannot |
| 1073 | determine licensing information, the |
| 1074 | <filename>LICENSE</filename> value is set to "CLOSED" and the |
| 1075 | <filename>LIC_FILES_CHKSUM</filename> value remains unset. |
| 1076 | This behavior allows you to continue with development but is |
| 1077 | unlikely to be correct in all cases. |
| 1078 | Consequently, you should check the documentation or source |
| 1079 | files for the software you are building to determine the actual |
| 1080 | license. |
| 1081 | </para> |
| 1082 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1083 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1084 | <section id='sdk-adding-makefile-only-software'> |
| 1085 | <title>Adding Makefile-Only Software</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1086 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1087 | <para> |
| 1088 | The use of <filename>make</filename> by itself is very common |
| 1089 | in both proprietary and open source software. |
| 1090 | Unfortunately, Makefiles are often not written with |
| 1091 | cross-compilation in mind. |
| 1092 | Thus, <filename>devtool add</filename> often cannot do very |
| 1093 | much to ensure that these Makefiles build correctly. |
| 1094 | It is very common, for example, to explicitly call |
| 1095 | <filename>gcc</filename> instead of using the |
| 1096 | <ulink url='&YOCTO_DOCS_REF_URL;#var-CC'><filename>CC</filename></ulink> |
| 1097 | variable. |
| 1098 | Usually, in a cross-compilation environment, |
| 1099 | <filename>gcc</filename> is the compiler for the build host |
| 1100 | and the cross-compiler is named something similar to |
| 1101 | <filename>arm-poky-linux-gnueabi-gcc</filename> and might |
| 1102 | require some arguments (e.g. to point to the associated sysroot |
| 1103 | for the target machine). |
| 1104 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1105 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1106 | <para> |
| 1107 | When writing a recipe for Makefile-only software, keep the |
| 1108 | following in mind: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1109 | <itemizedlist> |
| 1110 | <listitem><para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1111 | You probably need to patch the Makefile to use |
| 1112 | variables instead of hardcoding tools within the |
| 1113 | toolchain such as <filename>gcc</filename> and |
| 1114 | <filename>g++</filename>. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1115 | </para></listitem> |
| 1116 | <listitem><para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1117 | The environment in which <filename>make</filename> runs |
| 1118 | is set up with various standard variables for |
| 1119 | compilation (e.g. <filename>CC</filename>, |
| 1120 | <filename>CXX</filename>, and so forth) in a similar |
| 1121 | manner to the environment set up by the SDK's |
| 1122 | environment setup script. |
| 1123 | One easy way to see these variables is to run the |
| 1124 | <filename>devtool build</filename> command on the |
| 1125 | recipe and then look in |
| 1126 | <filename>oe-logs/run.do_compile</filename>. |
| 1127 | Towards the top of this file you will see a list of |
| 1128 | environment variables that are being set. |
| 1129 | You can take advantage of these variables within the |
| 1130 | Makefile. |
| 1131 | </para></listitem> |
| 1132 | <listitem><para> |
| 1133 | If the Makefile sets a default for a variable using "=", |
| 1134 | that default overrides the value set in the environment, |
| 1135 | which is usually not desirable. |
| 1136 | In this situation, you can either patch the Makefile |
| 1137 | so it sets the default using the "?=" operator, or |
| 1138 | you can alternatively force the value on the |
| 1139 | <filename>make</filename> command line. |
| 1140 | To force the value on the command line, add the |
| 1141 | variable setting to |
| 1142 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OEMAKE'><filename>EXTRA_OEMAKE</filename></ulink> |
| 1143 | or |
| 1144 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 1145 | within the recipe. |
| 1146 | Here is an example using <filename>EXTRA_OEMAKE</filename>: |
| 1147 | <literallayout class='monospaced'> |
| 1148 | EXTRA_OEMAKE += "'CC=${CC}' 'CXX=${CXX}'" |
| 1149 | </literallayout> |
| 1150 | In the above example, single quotes are used around the |
| 1151 | variable settings as the values are likely to contain |
| 1152 | spaces because required default options are passed to |
| 1153 | the compiler. |
| 1154 | </para></listitem> |
| 1155 | <listitem><para> |
| 1156 | Hardcoding paths inside Makefiles is often problematic |
| 1157 | in a cross-compilation environment. |
| 1158 | This is particularly true because those hardcoded paths |
| 1159 | often point to locations on the build host and thus |
| 1160 | will either be read-only or will introduce |
| 1161 | contamination into the cross-compilation by virtue of |
| 1162 | being specific to the build host rather than the target. |
| 1163 | Patching the Makefile to use prefix variables or other |
| 1164 | path variables is usually the way to handle this. |
| 1165 | </para></listitem> |
| 1166 | <listitem><para> |
| 1167 | Sometimes a Makefile runs target-specific commands such |
| 1168 | as <filename>ldconfig</filename>. |
| 1169 | For such cases, you might be able to simply apply |
| 1170 | patches that remove these commands from the Makefile. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1171 | </para></listitem> |
| 1172 | </itemizedlist> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1173 | </para> |
| 1174 | </section> |
| 1175 | |
| 1176 | <section id='sdk-adding-native-tools'> |
| 1177 | <title>Adding Native Tools</title> |
| 1178 | |
| 1179 | <para> |
| 1180 | Often, you need to build additional tools that run on the |
| 1181 | build host system as opposed to the target. |
| 1182 | You should indicate this using one of the following methods |
| 1183 | when you run <filename>devtool add</filename>: |
| 1184 | <itemizedlist> |
| 1185 | <listitem><para> |
| 1186 | Specify the name of the recipe such that it ends |
| 1187 | with "-native". |
| 1188 | Specifying the name like this produces a recipe that |
| 1189 | only builds for the build host. |
| 1190 | </para></listitem> |
| 1191 | <listitem><para> |
| 1192 | Specify the "‐‐also-native" option with the |
| 1193 | <filename>devtool add</filename> command. |
| 1194 | Specifying this option creates a recipe file that still |
| 1195 | builds for the target but also creates a variant with |
| 1196 | a "-native" suffix that builds for the build host. |
| 1197 | </para></listitem> |
| 1198 | </itemizedlist> |
| 1199 | <note> |
| 1200 | If you need to add a tool that is shipped as part of a |
| 1201 | source tree that builds code for the target, you can |
| 1202 | typically accomplish this by building the native and target |
| 1203 | parts separately rather than within the same compilation |
| 1204 | process. |
| 1205 | Realize though that with the "‐‐also-native" option, you |
| 1206 | can add the tool using just one recipe file. |
| 1207 | </note> |
| 1208 | </para> |
| 1209 | </section> |
| 1210 | |
| 1211 | <section id='sdk-adding-node-js-modules'> |
| 1212 | <title>Adding Node.js Modules</title> |
| 1213 | |
| 1214 | <para> |
| 1215 | You can use the <filename>devtool add</filename> command two |
| 1216 | different ways to add Node.js modules: 1) Through |
| 1217 | <filename>npm</filename> and, 2) from a repository or local |
| 1218 | source. |
| 1219 | </para> |
| 1220 | |
| 1221 | <para> |
| 1222 | Use the following form to add Node.js modules through |
| 1223 | <filename>npm</filename>: |
| 1224 | <literallayout class='monospaced'> |
| 1225 | $ devtool add "npm://registry.npmjs.org;name=forever;version=0.15.1" |
| 1226 | </literallayout> |
| 1227 | The name and version parameters are mandatory. |
| 1228 | Lockdown and shrinkwrap files are generated and pointed to by |
| 1229 | the recipe in order to freeze the version that is fetched for |
| 1230 | the dependencies according to the first time. |
| 1231 | This also saves checksums that are verified on future fetches. |
| 1232 | Together, these behaviors ensure the reproducibility and |
| 1233 | integrity of the build. |
| 1234 | <note><title>Notes</title> |
| 1235 | <itemizedlist> |
| 1236 | <listitem><para> |
| 1237 | You must use quotes around the URL. |
| 1238 | The <filename>devtool add</filename> does not require |
| 1239 | the quotes, but the shell considers ";" as a splitter |
| 1240 | between multiple commands. |
| 1241 | Thus, without the quotes, |
| 1242 | <filename>devtool add</filename> does not receive the |
| 1243 | other parts, which results in several "command not |
| 1244 | found" errors. |
| 1245 | </para></listitem> |
| 1246 | <listitem><para> |
| 1247 | In order to support adding |
| 1248 | Node.js modules, a |
| 1249 | <filename>nodejs</filename> recipe must be part of your |
| 1250 | SDK in order to provide Node.js |
| 1251 | itself. |
| 1252 | </para></listitem> |
| 1253 | </itemizedlist> |
| 1254 | </note> |
| 1255 | </para> |
| 1256 | |
| 1257 | <para> |
| 1258 | As mentioned earlier, you can also add Node.js modules |
| 1259 | directly from a repository or local source tree. |
| 1260 | To add modules this way, use <filename>devtool add</filename> in |
| 1261 | the following form: |
| 1262 | <literallayout class='monospaced'> |
| 1263 | $ devtool add https://github.com/diversario/node-ssdp |
| 1264 | </literallayout> |
| 1265 | In this example, <filename>devtool</filename> fetches the specified |
| 1266 | Git repository, detects that the code is Node.js code, fetches |
| 1267 | dependencies using <filename>npm</filename>, and sets |
| 1268 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> |
| 1269 | accordingly. |
| 1270 | </para> |
| 1271 | </section> |
| 1272 | </section> |
| 1273 | |
| 1274 | <section id='sdk-working-with-recipes'> |
| 1275 | <title>Working With Recipes</title> |
| 1276 | |
| 1277 | <para> |
Brad Bishop | d7bf8c1 | 2018-02-25 22:55:05 -0500 | [diff] [blame^] | 1278 | When building a recipe with <filename>devtool build</filename>, the |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1279 | typical build progression is as follows: |
| 1280 | <orderedlist> |
| 1281 | <listitem><para> |
| 1282 | Fetch the source |
| 1283 | </para></listitem> |
| 1284 | <listitem><para> |
| 1285 | Unpack the source |
| 1286 | </para></listitem> |
| 1287 | <listitem><para> |
| 1288 | Configure the source |
| 1289 | </para></listitem> |
| 1290 | <listitem><para> |
| 1291 | Compiling the source |
| 1292 | </para></listitem> |
| 1293 | <listitem><para> |
| 1294 | Install the build output |
| 1295 | </para></listitem> |
| 1296 | <listitem><para> |
| 1297 | Package the installed output |
| 1298 | </para></listitem> |
| 1299 | </orderedlist> |
| 1300 | For recipes in the workspace, fetching and unpacking is disabled |
| 1301 | as the source tree has already been prepared and is persistent. |
| 1302 | Each of these build steps is defined as a function, usually with a |
| 1303 | "do_" prefix. |
| 1304 | These functions are typically shell scripts but can instead be written |
| 1305 | in Python. |
| 1306 | </para> |
| 1307 | |
| 1308 | <para> |
| 1309 | If you look at the contents of a recipe, you will see that the |
| 1310 | recipe does not include complete instructions for building the |
| 1311 | software. |
| 1312 | Instead, common functionality is encapsulated in classes inherited |
| 1313 | with the <filename>inherit</filename> directive, leaving the recipe |
| 1314 | to describe just the things that are specific to the software to be |
| 1315 | built. |
| 1316 | A <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-base'><filename>base</filename></ulink> |
| 1317 | class exists that is implicitly inherited by all recipes and provides |
| 1318 | the functionality that most typical recipes need. |
| 1319 | </para> |
| 1320 | |
| 1321 | <para> |
| 1322 | The remainder of this section presents information useful when |
| 1323 | working with recipes. |
| 1324 | </para> |
| 1325 | |
| 1326 | <section id='sdk-finding-logs-and-work-files'> |
| 1327 | <title>Finding Logs and Work Files</title> |
| 1328 | |
| 1329 | <para> |
| 1330 | When you are debugging a recipe that you previously created using |
| 1331 | <filename>devtool add</filename> or whose source you are modifying |
| 1332 | by using the <filename>devtool modify</filename> command, after |
| 1333 | the first run of <filename>devtool build</filename>, you will |
| 1334 | find some symbolic links created within the source tree: |
| 1335 | <filename>oe-logs</filename>, which points to the directory in |
| 1336 | which log files and run scripts for each build step are created |
| 1337 | and <filename>oe-workdir</filename>, which points to the temporary |
| 1338 | work area for the recipe. |
| 1339 | You can use these links to get more information on what is |
| 1340 | happening at each build step. |
| 1341 | </para> |
| 1342 | |
| 1343 | <para> |
| 1344 | These locations under <filename>oe-workdir</filename> are |
| 1345 | particularly useful: |
| 1346 | <itemizedlist> |
| 1347 | <listitem><para><filename>image/</filename>: |
| 1348 | Contains all of the files installed at the |
| 1349 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 1350 | stage. |
| 1351 | Within a recipe, this directory is referred to by the |
| 1352 | expression |
| 1353 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename>. |
| 1354 | </para></listitem> |
| 1355 | <listitem><para><filename>sysroot-destdir/</filename>: |
| 1356 | Contains a subset of files installed within |
| 1357 | <filename>do_install</filename> that have been put into the |
| 1358 | shared sysroot. |
| 1359 | For more information, see the |
| 1360 | "<link linkend='sdk-sharing-files-between-recipes'>Sharing Files Between Recipes</link>" |
| 1361 | section. |
| 1362 | </para></listitem> |
| 1363 | <listitem><para><filename>packages-split/</filename>: |
| 1364 | Contains subdirectories for each package produced by the |
| 1365 | recipe. |
| 1366 | For more information, see the |
| 1367 | "<link linkend='sdk-packaging'>Packaging</link>" section. |
| 1368 | </para></listitem> |
| 1369 | </itemizedlist> |
| 1370 | </para> |
| 1371 | </section> |
| 1372 | |
| 1373 | <section id='sdk-setting-configure-arguments'> |
| 1374 | <title>Setting Configure Arguments</title> |
| 1375 | |
| 1376 | <para> |
| 1377 | If the software your recipe is building uses GNU autoconf, |
| 1378 | then a fixed set of arguments is passed to it to enable |
| 1379 | cross-compilation plus any extras specified by |
| 1380 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink> |
| 1381 | or |
| 1382 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 1383 | set within the recipe. |
| 1384 | If you wish to pass additional options, add them to |
| 1385 | <filename>EXTRA_OECONF</filename> or |
| 1386 | <filename>PACKAGECONFIG_CONFARGS</filename>. |
| 1387 | Other supported build tools have similar variables |
| 1388 | (e.g. |
| 1389 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECMAKE'><filename>EXTRA_OECMAKE</filename></ulink> |
| 1390 | for CMake, |
| 1391 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OESCONS'><filename>EXTRA_OESCONS</filename></ulink> |
| 1392 | for Scons, and so forth). |
| 1393 | If you need to pass anything on the <filename>make</filename> |
| 1394 | command line, you can use <filename>EXTRA_OEMAKE</filename> or the |
| 1395 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> |
| 1396 | variables to do so. |
| 1397 | </para> |
| 1398 | |
| 1399 | <para> |
| 1400 | You can use the <filename>devtool configure-help</filename> command |
| 1401 | to help you set the arguments listed in the previous paragraph. |
| 1402 | The command determines the exact options being passed, and shows |
| 1403 | them to you along with any custom arguments specified through |
| 1404 | <filename>EXTRA_OECONF</filename> or |
| 1405 | <filename>PACKAGECONFIG_CONFARGS</filename>. |
| 1406 | If applicable, the command also shows you the output of the |
| 1407 | configure script's "‐‐help" option as a reference. |
| 1408 | </para> |
| 1409 | </section> |
| 1410 | |
| 1411 | <section id='sdk-sharing-files-between-recipes'> |
| 1412 | <title>Sharing Files Between Recipes</title> |
| 1413 | |
| 1414 | <para> |
| 1415 | Recipes often need to use files provided by other recipes on |
| 1416 | the build host. |
| 1417 | For example, an application linking to a common library needs |
| 1418 | access to the library itself and its associated headers. |
| 1419 | The way this access is accomplished within the extensible SDK is |
| 1420 | through the sysroot. |
| 1421 | One sysroot exists per "machine" for which the SDK is being built. |
| 1422 | In practical terms, this means a sysroot exists for the target |
| 1423 | machine, and a sysroot exists for the build host. |
| 1424 | </para> |
| 1425 | |
| 1426 | <para> |
| 1427 | Recipes should never write files directly into the sysroot. |
| 1428 | Instead, files should be installed into standard locations |
| 1429 | during the |
| 1430 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 1431 | task within the |
| 1432 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink><filename>}</filename> |
| 1433 | directory. |
| 1434 | A subset of these files automatically go into the sysroot. |
| 1435 | The reason for this limitation is that almost all files that go |
| 1436 | into the sysroot are cataloged in manifests in order to ensure |
| 1437 | they can be removed later when a recipe is modified or removed. |
| 1438 | Thus, the sysroot is able to remain free from stale files. |
| 1439 | </para> |
| 1440 | </section> |
| 1441 | |
| 1442 | <section id='sdk-packaging'> |
| 1443 | <title>Packaging</title> |
| 1444 | |
| 1445 | <para> |
| 1446 | Packaging is not always particularly relevant within the |
| 1447 | extensible SDK. |
| 1448 | However, if you examine how build output gets into the final image |
| 1449 | on the target device, it is important to understand packaging |
| 1450 | because the contents of the image are expressed in terms of |
| 1451 | packages and not recipes. |
| 1452 | </para> |
| 1453 | |
| 1454 | <para> |
| 1455 | During the |
| 1456 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> |
| 1457 | task, files installed during the |
| 1458 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> |
| 1459 | task are split into one main package, which is almost always named |
| 1460 | the same as the recipe, and several other packages. |
| 1461 | This separation is done because not all of those installed files |
| 1462 | are always useful in every image. |
| 1463 | For example, you probably do not need any of the documentation |
| 1464 | installed in a production image. |
| 1465 | Consequently, for each recipe the documentation files are separated |
| 1466 | into a <filename>-doc</filename> package. |
| 1467 | Recipes that package software that has optional modules or |
| 1468 | plugins might do additional package splitting as well. |
| 1469 | </para> |
| 1470 | |
| 1471 | <para> |
| 1472 | After building a recipe you can see where files have gone by |
| 1473 | looking in the <filename>oe-workdir/packages-split</filename> |
| 1474 | directory, which contains a subdirectory for each package. |
| 1475 | Apart from some advanced cases, the |
| 1476 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink> |
| 1477 | and |
| 1478 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> |
| 1479 | variables controls splitting. |
| 1480 | The <filename>PACKAGES</filename> variable lists all of the |
| 1481 | packages to be produced, while the <filename>FILES</filename> |
| 1482 | variable specifies which files to include in each package, |
| 1483 | using an override to specify the package. |
| 1484 | For example, <filename>FILES_${PN}</filename> specifies the files |
| 1485 | to go into the main package (i.e. the main package is named the |
| 1486 | same as the recipe and |
| 1487 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink><filename>}</filename> |
| 1488 | evaluates to the recipe name). |
| 1489 | The order of the <filename>PACKAGES</filename> value is significant. |
| 1490 | For each installed file, the first package whose |
| 1491 | <filename>FILES</filename> value matches the file is the package |
| 1492 | into which the file goes. |
| 1493 | Defaults exist for both the <filename>PACKAGES</filename> and |
| 1494 | <filename>FILES</filename> variables. |
| 1495 | Consequently, you might find you do not even need to set these |
| 1496 | variables in your recipe unless the software the recipe is |
| 1497 | building installs files into non-standard locations. |
| 1498 | </para> |
| 1499 | </section> |
| 1500 | </section> |
| 1501 | |
| 1502 | <section id='sdk-restoring-the-target-device-to-its-original-state'> |
| 1503 | <title>Restoring the Target Device to its Original State</title> |
| 1504 | |
| 1505 | <para> |
| 1506 | If you use the <filename>devtool deploy-target</filename> |
| 1507 | command to write a recipe's build output to the target, and |
| 1508 | you are working on an existing component of the system, then you |
| 1509 | might find yourself in a situation where you need to restore the |
| 1510 | original files that existed prior to running the |
| 1511 | <filename>devtool deploy-target</filename> command. |
| 1512 | Because the <filename>devtool deploy-target</filename> command |
| 1513 | backs up any files it overwrites, you can use the |
| 1514 | <filename>devtool undeploy-target</filename> to restore those files |
| 1515 | and remove any other files the recipe deployed. |
| 1516 | Consider the following example: |
| 1517 | <literallayout class='monospaced'> |
| 1518 | $ devtool undeploy-target lighttpd root@192.168.7.2 |
| 1519 | </literallayout> |
| 1520 | If you have deployed multiple applications, you can remove them |
| 1521 | all at once thus restoring the target device back to its |
| 1522 | original state: |
| 1523 | <literallayout class='monospaced'> |
| 1524 | $ devtool undeploy-target -a root@192.168.7.2 |
| 1525 | </literallayout> |
| 1526 | Information about files deployed to the target as well as any |
| 1527 | backed up files are stored on the target itself. |
| 1528 | This storage of course requires some additional space |
| 1529 | on the target machine. |
| 1530 | <note> |
| 1531 | The <filename>devtool deploy-target</filename> and |
| 1532 | <filename>devtool undeploy-target</filename> command do not |
| 1533 | currently interact with any package management system on the |
| 1534 | target device (e.g. RPM or OPKG). |
| 1535 | Consequently, you should not intermingle operations |
| 1536 | <filename>devtool deploy-target</filename> and the package |
| 1537 | manager operations on the target device. |
| 1538 | Doing so could result in a conflicting set of files. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1539 | </note> |
| 1540 | </para> |
| 1541 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1542 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1543 | <section id='sdk-installing-additional-items-into-the-extensible-sdk'> |
| 1544 | <title>Installing Additional Items Into the Extensible SDK</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1545 | |
| 1546 | <para> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1547 | The extensible SDK typically only comes with a small number of tools |
| 1548 | and libraries out of the box. |
| 1549 | If you have a minimal SDK, then it starts mostly empty and is |
| 1550 | populated on-demand. |
| 1551 | However, sometimes you will need to explicitly install extra items |
| 1552 | into the SDK. |
| 1553 | If you need these extra items, you can first search for the items |
| 1554 | using the <filename>devtool search</filename> command. |
| 1555 | For example, suppose you need to link to libGL but you are not sure |
| 1556 | which recipe provides it. |
| 1557 | You can use the following command to find out: |
| 1558 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1559 | $ devtool search libGL |
| 1560 | mesa A free implementation of the OpenGL API |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1561 | </literallayout> |
| 1562 | Once you know the recipe (i.e. <filename>mesa</filename> in this |
| 1563 | example), you can install it: |
| 1564 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1565 | $ devtool sdk-install mesa |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1566 | </literallayout> |
| 1567 | By default, the <filename>devtool sdk-install</filename> assumes the |
| 1568 | item is available in pre-built form from your SDK provider. |
| 1569 | If the item is not available and it is acceptable to build the item |
| 1570 | from source, you can add the "-s" option as follows: |
| 1571 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1572 | $ devtool sdk-install -s mesa |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1573 | </literallayout> |
| 1574 | It is important to remember that building the item from source takes |
| 1575 | significantly longer than installing the pre-built artifact. |
| 1576 | Also, if no recipe exists for the item you want to add to the SDK, you |
| 1577 | must instead add it using the <filename>devtool add</filename> command. |
| 1578 | </para> |
| 1579 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1580 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1581 | <section id='sdk-updating-the-extensible-sdk'> |
| 1582 | <title>Updating the Extensible SDK</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1583 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1584 | <para> |
| 1585 | If you are working with an extensible SDK that gets occasionally |
| 1586 | updated (e.g. typically when that SDK has been provided to you by |
| 1587 | another party), then you will need to manually pull down those |
| 1588 | updates to your installed SDK. |
| 1589 | </para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1590 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1591 | <para> |
| 1592 | To update your installed SDK, run the following: |
| 1593 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1594 | $ devtool sdk-update |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1595 | </literallayout> |
| 1596 | The previous command assumes your SDK provider has set the default |
| 1597 | update URL for you. |
| 1598 | If that URL has not been set, you need to specify it yourself as |
| 1599 | follows: |
| 1600 | <literallayout class='monospaced'> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1601 | $ devtool sdk-update <replaceable>path_to_update_directory</replaceable> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1602 | </literallayout> |
| 1603 | <note> |
| 1604 | The URL needs to point specifically to a published SDK and not an |
| 1605 | SDK installer that you would download and install. |
| 1606 | </note> |
| 1607 | </para> |
| 1608 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1609 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1610 | <section id='sdk-creating-a-derivative-sdk-with-additional-components'> |
| 1611 | <title>Creating a Derivative SDK With Additional Components</title> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1612 | |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1613 | <para> |
| 1614 | You might need to produce an SDK that contains your own custom |
| 1615 | libraries for sending to a third party (e.g., if you are a vendor with |
| 1616 | customers needing to build their own software for the target platform). |
| 1617 | If that is the case, then you can produce a derivative SDK based on |
| 1618 | the currently installed SDK fairly easily. |
| 1619 | Use these steps: |
| 1620 | <orderedlist> |
| 1621 | <listitem><para>If necessary, install an extensible SDK that |
| 1622 | you want to use as a base for your derivative SDK. |
| 1623 | </para></listitem> |
| 1624 | <listitem><para>Source the environment script for the SDK. |
| 1625 | </para></listitem> |
| 1626 | <listitem><para>Add the extra libraries or other components |
| 1627 | you want by using the <filename>devtool add</filename> |
| 1628 | command. |
| 1629 | </para></listitem> |
| 1630 | <listitem><para>Run the <filename>devtool build-sdk</filename> |
| 1631 | command. |
| 1632 | </para></listitem> |
| 1633 | </orderedlist> |
| 1634 | The above procedure takes the recipes added to the workspace and |
| 1635 | constructs a new SDK installer containing those recipes and the |
| 1636 | resulting binary artifacts. |
| 1637 | The recipes go into their own separate layer in the constructed |
| 1638 | derivative SDK, leaving the workspace clean and ready for users |
| 1639 | to add their own recipes. |
| 1640 | </para> |
| 1641 | </section> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1642 | </chapter> |
| 1643 | <!-- |
| 1644 | vim: expandtab tw=80 ts=4 |
| 1645 | --> |