Patrick Williams | c124f4f | 2015-09-15 14:41:29 -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='closer-look'> |
| 6 | <title>A Closer Look at the Yocto Project Development Environment</title> |
| 7 | |
| 8 | <para> |
| 9 | This chapter takes a more detailed look at the Yocto Project |
| 10 | development environment. |
| 11 | The following diagram represents the development environment at a |
| 12 | high level. |
| 13 | The remainder of this chapter expands on the fundamental input, output, |
| 14 | process, and |
| 15 | <ulink url='&YOCTO_DOCS_DEV_URL;#metadata'>Metadata</ulink>) blocks |
| 16 | in the Yocto Project development environment. |
| 17 | </para> |
| 18 | |
| 19 | <para id='general-yocto-environment-figure'> |
| 20 | <imagedata fileref="figures/yocto-environment-ref.png" align="center" width="8in" depth="4.25in" /> |
| 21 | </para> |
| 22 | |
| 23 | <para> |
| 24 | The generalized Yocto Project Development Environment consists of |
| 25 | several functional areas: |
| 26 | <itemizedlist> |
| 27 | <listitem><para><emphasis>User Configuration:</emphasis> |
| 28 | Metadata you can use to control the build process. |
| 29 | </para></listitem> |
| 30 | <listitem><para><emphasis>Metadata Layers:</emphasis> |
| 31 | Various layers that provide software, machine, and |
| 32 | distro Metadata.</para></listitem> |
| 33 | <listitem><para><emphasis>Source Files:</emphasis> |
| 34 | Upstream releases, local projects, and SCMs.</para></listitem> |
| 35 | <listitem><para><emphasis>Build System:</emphasis> |
| 36 | Processes under the control of |
| 37 | <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink>. |
| 38 | This block expands on how BitBake fetches source, applies |
| 39 | patches, completes compilation, analyzes output for package |
| 40 | generation, creates and tests packages, generates images, and |
| 41 | generates cross-development tools.</para></listitem> |
| 42 | <listitem><para><emphasis>Package Feeds:</emphasis> |
| 43 | Directories containing output packages (RPM, DEB or IPK), |
| 44 | which are subsequently used in the construction of an image or |
| 45 | SDK, produced by the build system. |
| 46 | These feeds can also be copied and shared using a web server or |
| 47 | other means to facilitate extending or updating existing |
| 48 | images on devices at runtime if runtime package management is |
| 49 | enabled.</para></listitem> |
| 50 | <listitem><para><emphasis>Images:</emphasis> |
| 51 | Images produced by the development process. |
| 52 | </para></listitem> |
| 53 | <listitem><para><emphasis>Application Development SDK:</emphasis> |
| 54 | Cross-development tools that are produced along with an image |
| 55 | or separately with BitBake.</para></listitem> |
| 56 | </itemizedlist> |
| 57 | </para> |
| 58 | |
| 59 | <section id="user-configuration"> |
| 60 | <title>User Configuration</title> |
| 61 | |
| 62 | <para> |
| 63 | User configuration helps define the build. |
| 64 | Through user configuration, you can tell BitBake the |
| 65 | target architecture for which you are building the image, |
| 66 | where to store downloaded source, and other build properties. |
| 67 | </para> |
| 68 | |
| 69 | <para> |
| 70 | The following figure shows an expanded representation of the |
| 71 | "User Configuration" box of the |
| 72 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>: |
| 73 | </para> |
| 74 | |
| 75 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 76 | <imagedata fileref="figures/user-configuration.png" align="center" /> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 77 | </para> |
| 78 | |
| 79 | <para> |
| 80 | BitBake needs some basic configuration files in order to complete |
| 81 | a build. |
| 82 | These files are <filename>*.conf</filename> files. |
| 83 | The minimally necessary ones reside as example files in the |
| 84 | <ulink url='&YOCTO_DOCS_DEV_URL;#source-directory'>Source Directory</ulink>. |
| 85 | For simplicity, this section refers to the Source Directory as |
| 86 | the "Poky Directory." |
| 87 | </para> |
| 88 | |
| 89 | <para> |
| 90 | When you clone the <filename>poky</filename> Git repository or you |
| 91 | download and unpack a Yocto Project release, you can set up the |
| 92 | Source Directory to be named anything you want. |
| 93 | For this discussion, the cloned repository uses the default |
| 94 | name <filename>poky</filename>. |
| 95 | <note> |
| 96 | The Poky repository is primarily an aggregation of existing |
| 97 | repositories. |
| 98 | It is not a canonical upstream source. |
| 99 | </note> |
| 100 | </para> |
| 101 | |
| 102 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 103 | The <filename>meta-poky</filename> layer inside Poky contains |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 104 | a <filename>conf</filename> directory that has example |
| 105 | configuration files. |
| 106 | These example files are used as a basis for creating actual |
| 107 | configuration files when you source the build environment |
| 108 | script |
| 109 | (i.e. |
| 110 | <link linkend='structure-core-script'><filename>&OE_INIT_FILE;</filename></link> |
| 111 | or |
| 112 | <link linkend='structure-memres-core-script'><filename>oe-init-build-env-memres</filename></link>). |
| 113 | </para> |
| 114 | |
| 115 | <para> |
| 116 | Sourcing the build environment script creates a |
| 117 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 118 | if one does not already exist. |
| 119 | BitBake uses the Build Directory for all its work during builds. |
| 120 | The Build Directory has a <filename>conf</filename> directory that |
| 121 | contains default versions of your <filename>local.conf</filename> |
| 122 | and <filename>bblayers.conf</filename> configuration files. |
| 123 | These default configuration files are created only if versions |
| 124 | do not already exist in the Build Directory at the time you |
| 125 | source the build environment setup script. |
| 126 | </para> |
| 127 | |
| 128 | <para> |
| 129 | Because the Poky repository is fundamentally an aggregation of |
| 130 | existing repositories, some users might be familiar with running |
| 131 | the <filename>&OE_INIT_FILE;</filename> or |
| 132 | <filename>oe-init-build-env-memres</filename> script in the context |
| 133 | of separate OpenEmbedded-Core and BitBake repositories rather than a |
| 134 | single Poky repository. |
| 135 | This discussion assumes the script is executed from within a cloned |
| 136 | or unpacked version of Poky. |
| 137 | </para> |
| 138 | |
| 139 | <para> |
| 140 | Depending on where the script is sourced, different sub-scripts |
| 141 | are called to set up the Build Directory (Yocto or OpenEmbedded). |
| 142 | Specifically, the script |
| 143 | <filename>scripts/oe-setup-builddir</filename> inside the |
| 144 | poky directory sets up the Build Directory and seeds the directory |
| 145 | (if necessary) with configuration files appropriate for the |
| 146 | Yocto Project development environment. |
| 147 | <note> |
| 148 | The <filename>scripts/oe-setup-builddir</filename> script |
| 149 | uses the <filename>$TEMPLATECONF</filename> variable to |
| 150 | determine which sample configuration files to locate. |
| 151 | </note> |
| 152 | </para> |
| 153 | |
| 154 | <para> |
| 155 | The <filename>local.conf</filename> file provides many |
| 156 | basic variables that define a build environment. |
| 157 | Here is a list of a few. |
| 158 | To see the default configurations in a <filename>local.conf</filename> |
| 159 | file created by the build environment script, see the |
| 160 | <filename>local.conf.sample</filename> in the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 161 | <filename>meta-poky</filename> layer: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 162 | <itemizedlist> |
| 163 | <listitem><para><emphasis>Parallelism Options:</emphasis> |
| 164 | Controlled by the |
| 165 | <link linkend='var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename></link>, |
| 166 | <link linkend='var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></link>, |
| 167 | and |
| 168 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename></ulink> |
| 169 | variables.</para></listitem> |
| 170 | <listitem><para><emphasis>Target Machine Selection:</emphasis> |
| 171 | Controlled by the |
| 172 | <link linkend='var-MACHINE'><filename>MACHINE</filename></link> |
| 173 | variable.</para></listitem> |
| 174 | <listitem><para><emphasis>Download Directory:</emphasis> |
| 175 | Controlled by the |
| 176 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 177 | variable.</para></listitem> |
| 178 | <listitem><para><emphasis>Shared State Directory:</emphasis> |
| 179 | Controlled by the |
| 180 | <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link> |
| 181 | variable.</para></listitem> |
| 182 | <listitem><para><emphasis>Build Output:</emphasis> |
| 183 | Controlled by the |
| 184 | <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link> |
| 185 | variable.</para></listitem> |
| 186 | </itemizedlist> |
| 187 | <note> |
| 188 | Configurations set in the <filename>conf/local.conf</filename> |
| 189 | file can also be set in the |
| 190 | <filename>conf/site.conf</filename> and |
| 191 | <filename>conf/auto.conf</filename> configuration files. |
| 192 | </note> |
| 193 | </para> |
| 194 | |
| 195 | <para> |
| 196 | The <filename>bblayers.conf</filename> file tells BitBake what |
| 197 | layers you want considered during the build. |
| 198 | By default, the layers listed in this file include layers |
| 199 | minimally needed by the build system. |
| 200 | However, you must manually add any custom layers you have created. |
| 201 | You can find more information on working with the |
| 202 | <filename>bblayers.conf</filename> file in the |
| 203 | "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>" |
| 204 | section in the Yocto Project Development Manual. |
| 205 | </para> |
| 206 | |
| 207 | <para> |
| 208 | The files <filename>site.conf</filename> and |
| 209 | <filename>auto.conf</filename> are not created by the environment |
| 210 | initialization script. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 211 | If you want the <filename>site.conf</filename> file, you need to |
| 212 | create that yourself. |
| 213 | The <filename>auto.conf</filename> file is typically created by |
| 214 | an autobuilder: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 215 | <itemizedlist> |
| 216 | <listitem><para><emphasis><filename>site.conf</filename>:</emphasis> |
| 217 | You can use the <filename>conf/site.conf</filename> |
| 218 | configuration file to configure multiple build directories. |
| 219 | For example, suppose you had several build environments and |
| 220 | they shared some common features. |
| 221 | You can set these default build properties here. |
| 222 | A good example is perhaps the packaging format to use |
| 223 | through the |
| 224 | <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link> |
| 225 | variable.</para> |
| 226 | <para>One useful scenario for using the |
| 227 | <filename>conf/site.conf</filename> file is to extend your |
| 228 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link> |
| 229 | variable to include the path to a |
| 230 | <filename>conf/site.conf</filename>. |
| 231 | Then, when BitBake looks for Metadata using |
| 232 | <filename>BBPATH</filename>, it finds the |
| 233 | <filename>conf/site.conf</filename> file and applies your |
| 234 | common configurations found in the file. |
| 235 | To override configurations in a particular build directory, |
| 236 | alter the similar configurations within that build |
| 237 | directory's <filename>conf/local.conf</filename> file. |
| 238 | </para></listitem> |
| 239 | <listitem><para><emphasis><filename>auto.conf</filename>:</emphasis> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 240 | The file is usually created and written to by |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 241 | an autobuilder. |
| 242 | The settings put into the file are typically the same as |
| 243 | you would find in the <filename>conf/local.conf</filename> |
| 244 | or the <filename>conf/site.conf</filename> files. |
| 245 | </para></listitem> |
| 246 | </itemizedlist> |
| 247 | </para> |
| 248 | |
| 249 | <para> |
| 250 | You can edit all configuration files to further define |
| 251 | any particular build environment. |
| 252 | This process is represented by the "User Configuration Edits" |
| 253 | box in the figure. |
| 254 | </para> |
| 255 | |
| 256 | <para> |
| 257 | When you launch your build with the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 258 | <filename>bitbake <replaceable>target</replaceable></filename> |
| 259 | command, BitBake sorts out the configurations to ultimately |
| 260 | define your build environment. |
| 261 | It is important to understand that the OpenEmbedded build system |
| 262 | reads the configuration files in a specific order: |
| 263 | <filename>site.conf</filename>, <filename>auto.conf</filename>, |
| 264 | and <filename>local.conf</filename>. |
| 265 | And, the build system applies the normal assignment statement |
| 266 | rules. |
| 267 | Because the files are parsed in a specific order, variable |
| 268 | assignments for the same variable could be affected. |
| 269 | For example, if the <filename>auto.conf</filename> file and |
| 270 | the <filename>local.conf</filename> set |
| 271 | <replaceable>variable1</replaceable> to different values, because |
| 272 | the build system parses <filename>local.conf</filename> after |
| 273 | <filename>auto.conf</filename>, |
| 274 | <replaceable>variable1</replaceable> is assigned the value from |
| 275 | the <filename>local.conf</filename> file. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 276 | </para> |
| 277 | </section> |
| 278 | |
| 279 | <section id="metadata-machine-configuration-and-policy-configuration"> |
| 280 | <title>Metadata, Machine Configuration, and Policy Configuration</title> |
| 281 | |
| 282 | <para> |
| 283 | The previous section described the user configurations that |
| 284 | define BitBake's global behavior. |
| 285 | This section takes a closer look at the layers the build system |
| 286 | uses to further control the build. |
| 287 | These layers provide Metadata for the software, machine, and |
| 288 | policy. |
| 289 | </para> |
| 290 | |
| 291 | <para> |
| 292 | In general, three types of layer input exist: |
| 293 | <itemizedlist> |
| 294 | <listitem><para><emphasis>Policy Configuration:</emphasis> |
| 295 | Distribution Layers provide top-level or general |
| 296 | policies for the image or SDK being built. |
| 297 | For example, this layer would dictate whether BitBake |
| 298 | produces RPM or IPK packages.</para></listitem> |
| 299 | <listitem><para><emphasis>Machine Configuration:</emphasis> |
| 300 | Board Support Package (BSP) layers provide machine |
| 301 | configurations. |
| 302 | This type of information is specific to a particular |
| 303 | target architecture.</para></listitem> |
| 304 | <listitem><para><emphasis>Metadata:</emphasis> |
| 305 | Software layers contain user-supplied recipe files, |
| 306 | patches, and append files. |
| 307 | </para></listitem> |
| 308 | </itemizedlist> |
| 309 | </para> |
| 310 | |
| 311 | <para> |
| 312 | The following figure shows an expanded representation of the |
| 313 | Metadata, Machine Configuration, and Policy Configuration input |
| 314 | (layers) boxes of the |
| 315 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>: |
| 316 | </para> |
| 317 | |
| 318 | <para> |
| 319 | <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="7.5in" /> |
| 320 | </para> |
| 321 | |
| 322 | <para> |
| 323 | In general, all layers have a similar structure. |
| 324 | They all contain a licensing file |
| 325 | (e.g. <filename>COPYING</filename>) if the layer is to be |
| 326 | distributed, a <filename>README</filename> file as good practice |
| 327 | and especially if the layer is to be distributed, a |
| 328 | configuration directory, and recipe directories. |
| 329 | </para> |
| 330 | |
| 331 | <para> |
| 332 | The Yocto Project has many layers that can be used. |
| 333 | You can see a web-interface listing of them on the |
| 334 | <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink> |
| 335 | page. |
| 336 | The layers are shown at the bottom categorized under |
| 337 | "Yocto Metadata Layers." |
| 338 | These layers are fundamentally a subset of the |
| 339 | <ulink url="http://layers.openembedded.org/layerindex/layers/">OpenEmbedded Metadata Index</ulink>, |
| 340 | which lists all layers provided by the OpenEmbedded community. |
| 341 | <note> |
| 342 | Layers exist in the Yocto Project Source Repositories that |
| 343 | cannot be found in the OpenEmbedded Metadata Index. |
| 344 | These layers are either deprecated or experimental in nature. |
| 345 | </note> |
| 346 | </para> |
| 347 | |
| 348 | <para> |
| 349 | BitBake uses the <filename>conf/bblayers.conf</filename> file, |
| 350 | which is part of the user configuration, to find what layers it |
| 351 | should be using as part of the build. |
| 352 | </para> |
| 353 | |
| 354 | <para> |
| 355 | For more information on layers, see the |
| 356 | "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" |
| 357 | section in the Yocto Project Development Manual. |
| 358 | </para> |
| 359 | |
| 360 | <section id="distro-layer"> |
| 361 | <title>Distro Layer</title> |
| 362 | |
| 363 | <para> |
| 364 | The distribution layer provides policy configurations for your |
| 365 | distribution. |
| 366 | Best practices dictate that you isolate these types of |
| 367 | configurations into their own layer. |
| 368 | Settings you provide in |
| 369 | <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override |
| 370 | similar |
| 371 | settings that BitBake finds in your |
| 372 | <filename>conf/local.conf</filename> file in the Build |
| 373 | Directory. |
| 374 | </para> |
| 375 | |
| 376 | <para> |
| 377 | The following list provides some explanation and references |
| 378 | for what you typically find in the distribution layer: |
| 379 | <itemizedlist> |
| 380 | <listitem><para><emphasis>classes:</emphasis> |
| 381 | Class files (<filename>.bbclass</filename>) hold |
| 382 | common functionality that can be shared among |
| 383 | recipes in the distribution. |
| 384 | When your recipes inherit a class, they take on the |
| 385 | settings and functions for that class. |
| 386 | You can read more about class files in the |
| 387 | "<link linkend='ref-classes'>Classes</link>" section. |
| 388 | </para></listitem> |
| 389 | <listitem><para><emphasis>conf:</emphasis> |
| 390 | This area holds configuration files for the |
| 391 | layer (<filename>conf/layer.conf</filename>), |
| 392 | the distribution |
| 393 | (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>), |
| 394 | and any distribution-wide include files. |
| 395 | </para></listitem> |
| 396 | <listitem><para><emphasis>recipes-*:</emphasis> |
| 397 | Recipes and append files that affect common |
| 398 | functionality across the distribution. |
| 399 | This area could include recipes and append files |
| 400 | to add distribution-specific configuration, |
| 401 | initialization scripts, custom image recipes, |
| 402 | and so forth.</para></listitem> |
| 403 | </itemizedlist> |
| 404 | </para> |
| 405 | </section> |
| 406 | |
| 407 | <section id="bsp-layer"> |
| 408 | <title>BSP Layer</title> |
| 409 | |
| 410 | <para> |
| 411 | The BSP Layer provides machine configurations. |
| 412 | Everything in this layer is specific to the machine for which |
| 413 | you are building the image or the SDK. |
| 414 | A common structure or form is defined for BSP layers. |
| 415 | You can learn more about this structure in the |
| 416 | <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>. |
| 417 | <note> |
| 418 | In order for a BSP layer to be considered compliant with the |
| 419 | Yocto Project, it must meet some structural requirements. |
| 420 | </note> |
| 421 | </para> |
| 422 | |
| 423 | <para> |
| 424 | The BSP Layer's configuration directory contains |
| 425 | configuration files for the machine |
| 426 | (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>) and, |
| 427 | of course, the layer (<filename>conf/layer.conf</filename>). |
| 428 | </para> |
| 429 | |
| 430 | <para> |
| 431 | The remainder of the layer is dedicated to specific recipes |
| 432 | by function: <filename>recipes-bsp</filename>, |
| 433 | <filename>recipes-core</filename>, |
| 434 | <filename>recipes-graphics</filename>, and |
| 435 | <filename>recipes-kernel</filename>. |
| 436 | Metadata can exist for multiple formfactors, graphics |
| 437 | support systems, and so forth. |
| 438 | <note> |
| 439 | While the figure shows several <filename>recipes-*</filename> |
| 440 | directories, not all these directories appear in all |
| 441 | BSP layers. |
| 442 | </note> |
| 443 | </para> |
| 444 | </section> |
| 445 | |
| 446 | <section id="software-layer"> |
| 447 | <title>Software Layer</title> |
| 448 | |
| 449 | <para> |
| 450 | The software layer provides the Metadata for additional |
| 451 | software packages used during the build. |
| 452 | This layer does not include Metadata that is specific to the |
| 453 | distribution or the machine, which are found in their |
| 454 | respective layers. |
| 455 | </para> |
| 456 | |
| 457 | <para> |
| 458 | This layer contains any new recipes that your project needs |
| 459 | in the form of recipe files. |
| 460 | </para> |
| 461 | </section> |
| 462 | </section> |
| 463 | |
| 464 | <section id="sources-dev-environment"> |
| 465 | <title>Sources</title> |
| 466 | |
| 467 | <para> |
| 468 | In order for the OpenEmbedded build system to create an image or |
| 469 | any target, it must be able to access source files. |
| 470 | The |
| 471 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 472 | represents source files using the "Upstream Project Releases", |
| 473 | "Local Projects", and "SCMs (optional)" boxes. |
| 474 | The figure represents mirrors, which also play a role in locating |
| 475 | source files, with the "Source Mirror(s)" box. |
| 476 | </para> |
| 477 | |
| 478 | <para> |
| 479 | The method by which source files are ultimately organized is |
| 480 | a function of the project. |
| 481 | For example, for released software, projects tend to use tarballs |
| 482 | or other archived files that can capture the state of a release |
| 483 | guaranteeing that it is statically represented. |
| 484 | On the other hand, for a project that is more dynamic or |
| 485 | experimental in nature, a project might keep source files in a |
| 486 | repository controlled by a Source Control Manager (SCM) such as |
| 487 | Git. |
| 488 | Pulling source from a repository allows you to control |
| 489 | the point in the repository (the revision) from which you want to |
| 490 | build software. |
| 491 | Finally, a combination of the two might exist, which would give the |
| 492 | consumer a choice when deciding where to get source files. |
| 493 | </para> |
| 494 | |
| 495 | <para> |
| 496 | BitBake uses the |
| 497 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 498 | variable to point to source files regardless of their location. |
| 499 | Each recipe must have a <filename>SRC_URI</filename> variable |
| 500 | that points to the source. |
| 501 | </para> |
| 502 | |
| 503 | <para> |
| 504 | Another area that plays a significant role in where source files |
| 505 | come from is pointed to by the |
| 506 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 507 | variable. |
| 508 | This area is a cache that can hold previously downloaded source. |
| 509 | You can also instruct the OpenEmbedded build system to create |
| 510 | tarballs from Git repositories, which is not the default behavior, |
| 511 | and store them in the <filename>DL_DIR</filename> by using the |
| 512 | <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link> |
| 513 | variable. |
| 514 | </para> |
| 515 | |
| 516 | <para> |
| 517 | Judicious use of a <filename>DL_DIR</filename> directory can |
| 518 | save the build system a trip across the Internet when looking |
| 519 | for files. |
| 520 | A good method for using a download directory is to have |
| 521 | <filename>DL_DIR</filename> point to an area outside of your |
| 522 | Build Directory. |
| 523 | Doing so allows you to safely delete the Build Directory |
| 524 | if needed without fear of removing any downloaded source file. |
| 525 | </para> |
| 526 | |
| 527 | <para> |
| 528 | The remainder of this section provides a deeper look into the |
| 529 | source files and the mirrors. |
| 530 | Here is a more detailed look at the source file area of the |
| 531 | base figure: |
| 532 | <imagedata fileref="figures/source-input.png" align="center" width="7in" depth="7.5in" /> |
| 533 | </para> |
| 534 | |
| 535 | <section id='upstream-project-releases'> |
| 536 | <title>Upstream Project Releases</title> |
| 537 | |
| 538 | <para> |
| 539 | Upstream project releases exist anywhere in the form of an |
| 540 | archived file (e.g. tarball or zip file). |
| 541 | These files correspond to individual recipes. |
| 542 | For example, the figure uses specific releases each for |
| 543 | BusyBox, Qt, and Dbus. |
| 544 | An archive file can be for any released product that can be |
| 545 | built using a recipe. |
| 546 | </para> |
| 547 | </section> |
| 548 | |
| 549 | <section id='local-projects'> |
| 550 | <title>Local Projects</title> |
| 551 | |
| 552 | <para> |
| 553 | Local projects are custom bits of software the user provides. |
| 554 | These bits reside somewhere local to a project - perhaps |
| 555 | a directory into which the user checks in items (e.g. |
| 556 | a local directory containing a development source tree |
| 557 | used by the group). |
| 558 | </para> |
| 559 | |
| 560 | <para> |
| 561 | The canonical method through which to include a local project |
| 562 | is to use the |
| 563 | <link linkend='ref-classes-externalsrc'><filename>externalsrc</filename></link> |
| 564 | class to include that local project. |
| 565 | You use either the <filename>local.conf</filename> or a |
| 566 | recipe's append file to override or set the |
| 567 | recipe to point to the local directory on your disk to pull |
| 568 | in the whole source tree. |
| 569 | </para> |
| 570 | |
| 571 | <para> |
| 572 | For information on how to use the |
| 573 | <filename>externalsrc</filename> class, see the |
| 574 | "<link linkend='ref-classes-externalsrc'><filename>externalsrc.bbclass</filename></link>" |
| 575 | section. |
| 576 | </para> |
| 577 | </section> |
| 578 | |
| 579 | <section id='scms'> |
| 580 | <title>Source Control Managers (Optional)</title> |
| 581 | |
| 582 | <para> |
| 583 | Another place the build system can get source files from is |
| 584 | through an SCM such as Git or Subversion. |
| 585 | In this case, a repository is cloned or checked out. |
| 586 | The |
| 587 | <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link> |
| 588 | task inside BitBake uses |
| 589 | the <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 590 | variable and the argument's prefix to determine the correct |
| 591 | fetcher module. |
| 592 | </para> |
| 593 | |
| 594 | <note> |
| 595 | For information on how to have the OpenEmbedded build system |
| 596 | generate tarballs for Git repositories and place them in the |
| 597 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 598 | directory, see the |
| 599 | <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link> |
| 600 | variable. |
| 601 | </note> |
| 602 | |
| 603 | <para> |
| 604 | When fetching a repository, BitBake uses the |
| 605 | <link linkend='var-SRCREV'><filename>SRCREV</filename></link> |
| 606 | variable to determine the specific revision from which to |
| 607 | build. |
| 608 | </para> |
| 609 | </section> |
| 610 | |
| 611 | <section id='source-mirrors'> |
| 612 | <title>Source Mirror(s)</title> |
| 613 | |
| 614 | <para> |
| 615 | Two kinds of mirrors exist: pre-mirrors and regular mirrors. |
| 616 | The <link linkend='var-PREMIRRORS'><filename>PREMIRRORS</filename></link> |
| 617 | and |
| 618 | <link linkend='var-MIRRORS'><filename>MIRRORS</filename></link> |
| 619 | variables point to these, respectively. |
| 620 | BitBake checks pre-mirrors before looking upstream for any |
| 621 | source files. |
| 622 | Pre-mirrors are appropriate when you have a shared directory |
| 623 | that is not a directory defined by the |
| 624 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 625 | variable. |
| 626 | A Pre-mirror typically points to a shared directory that is |
| 627 | local to your organization. |
| 628 | </para> |
| 629 | |
| 630 | <para> |
| 631 | Regular mirrors can be any site across the Internet that is |
| 632 | used as an alternative location for source code should the |
| 633 | primary site not be functioning for some reason or another. |
| 634 | </para> |
| 635 | </section> |
| 636 | </section> |
| 637 | |
| 638 | <section id="package-feeds-dev-environment"> |
| 639 | <title>Package Feeds</title> |
| 640 | |
| 641 | <para> |
| 642 | When the OpenEmbedded build system generates an image or an SDK, |
| 643 | it gets the packages from a package feed area located in the |
| 644 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>. |
| 645 | The |
| 646 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 647 | shows this package feeds area in the upper-right corner. |
| 648 | </para> |
| 649 | |
| 650 | <para> |
| 651 | This section looks a little closer into the package feeds area used |
| 652 | by the build system. |
| 653 | Here is a more detailed look at the area: |
| 654 | <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" /> |
| 655 | </para> |
| 656 | |
| 657 | <para> |
| 658 | Package feeds are an intermediary step in the build process. |
| 659 | The OpenEmbedded build system provides classes to generate |
| 660 | different package types, and you specify which classes to enable |
| 661 | through the |
| 662 | <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link> |
| 663 | variable. |
| 664 | Before placing the packages into package feeds, |
| 665 | the build process validates them with generated output quality |
| 666 | assurance checks through the |
| 667 | <link linkend='ref-classes-insane'><filename>insane</filename></link> |
| 668 | class. |
| 669 | </para> |
| 670 | |
| 671 | <para> |
| 672 | The package feed area resides in the Build Directory. |
| 673 | The directory the build system uses to temporarily store packages |
| 674 | is determined by a combination of variables and the particular |
| 675 | package manager in use. |
| 676 | See the "Package Feeds" box in the illustration and note the |
| 677 | information to the right of that area. |
| 678 | In particular, the following defines where package files are |
| 679 | kept: |
| 680 | <itemizedlist> |
| 681 | <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>: |
| 682 | Defined as <filename>tmp/deploy</filename> in the Build |
| 683 | Directory. |
| 684 | </para></listitem> |
| 685 | <listitem><para><filename>DEPLOY_DIR_*</filename>: |
| 686 | Depending on the package manager used, the package type |
| 687 | sub-folder. |
| 688 | Given RPM, IPK, or DEB packaging and tarball creation, the |
| 689 | <link linkend='var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></link>, |
| 690 | <link linkend='var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></link>, |
| 691 | <link linkend='var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></link>, |
| 692 | or |
| 693 | <link linkend='var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></link>, |
| 694 | variables are used, respectively. |
| 695 | </para></listitem> |
| 696 | <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link>: |
| 697 | Defines architecture-specific sub-folders. |
| 698 | For example, packages could exist for the i586 or qemux86 |
| 699 | architectures. |
| 700 | </para></listitem> |
| 701 | </itemizedlist> |
| 702 | </para> |
| 703 | |
| 704 | <para> |
| 705 | BitBake uses the <filename>do_package_write_*</filename> tasks to |
| 706 | generate packages and place them into the package holding area (e.g. |
| 707 | <filename>do_package_write_ipk</filename> for IPK packages). |
| 708 | See the |
| 709 | "<link linkend='ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></link>", |
| 710 | "<link linkend='ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></link>", |
| 711 | "<link linkend='ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></link>", |
| 712 | and |
| 713 | "<link linkend='ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></link>" |
| 714 | sections for additional information. |
| 715 | As an example, consider a scenario where an IPK packaging manager |
| 716 | is being used and package architecture support for both i586 |
| 717 | and qemux86 exist. |
| 718 | Packages for the i586 architecture are placed in |
| 719 | <filename>build/tmp/deploy/ipk/i586</filename>, while packages for |
| 720 | the qemux86 architecture are placed in |
| 721 | <filename>build/tmp/deploy/ipk/qemux86</filename>. |
| 722 | </para> |
| 723 | </section> |
| 724 | |
| 725 | <section id='bitbake-dev-environment'> |
| 726 | <title>BitBake</title> |
| 727 | |
| 728 | <para> |
| 729 | The OpenEmbedded build system uses |
| 730 | <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink> |
| 731 | to produce images. |
| 732 | You can see from the |
| 733 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, |
| 734 | the BitBake area consists of several functional areas. |
| 735 | This section takes a closer look at each of those areas. |
| 736 | </para> |
| 737 | |
| 738 | <para> |
| 739 | Separate documentation exists for the BitBake tool. |
| 740 | See the |
| 741 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink> |
| 742 | for reference material on BitBake. |
| 743 | </para> |
| 744 | |
| 745 | <section id='source-fetching-dev-environment'> |
| 746 | <title>Source Fetching</title> |
| 747 | |
| 748 | <para> |
| 749 | The first stages of building a recipe are to fetch and unpack |
| 750 | the source code: |
| 751 | <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" /> |
| 752 | </para> |
| 753 | |
| 754 | <para> |
| 755 | The |
| 756 | <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link> |
| 757 | and |
| 758 | <link linkend='ref-tasks-unpack'><filename>do_unpack</filename></link> |
| 759 | tasks fetch the source files and unpack them into the work |
| 760 | directory. |
| 761 | <note> |
| 762 | For every local file (e.g. <filename>file://</filename>) |
| 763 | that is part of a recipe's |
| 764 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 765 | statement, the OpenEmbedded build system takes a checksum |
| 766 | of the file for the recipe and inserts the checksum into |
| 767 | the signature for the <filename>do_fetch</filename>. |
| 768 | If any local file has been modified, the |
| 769 | <filename>do_fetch</filename> task and all tasks that |
| 770 | depend on it are re-executed. |
| 771 | </note> |
| 772 | By default, everything is accomplished in the |
| 773 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>, |
| 774 | which has a defined structure. |
| 775 | For additional general information on the Build Directory, |
| 776 | see the |
| 777 | "<link linkend='structure-core-build'><filename>build/</filename></link>" |
| 778 | section. |
| 779 | </para> |
| 780 | |
| 781 | <para> |
| 782 | Unpacked source files are pointed to by the |
| 783 | <link linkend='var-S'><filename>S</filename></link> variable. |
| 784 | Each recipe has an area in the Build Directory where the |
| 785 | unpacked source code resides. |
| 786 | The name of that directory for any given recipe is defined from |
| 787 | several different variables. |
| 788 | You can see the variables that define these directories |
| 789 | by looking at the figure: |
| 790 | <itemizedlist> |
| 791 | <listitem><para><link linkend='var-TMPDIR'><filename>TMPDIR</filename></link> - |
| 792 | The base directory where the OpenEmbedded build system |
| 793 | performs all its work during the build. |
| 794 | </para></listitem> |
| 795 | <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link> - |
| 796 | The architecture of the built package or packages. |
| 797 | </para></listitem> |
| 798 | <listitem><para><link linkend='var-TARGET_OS'><filename>TARGET_OS</filename></link> - |
| 799 | The operating system of the target device. |
| 800 | </para></listitem> |
| 801 | <listitem><para><link linkend='var-PN'><filename>PN</filename></link> - |
| 802 | The name of the built package. |
| 803 | </para></listitem> |
| 804 | <listitem><para><link linkend='var-PV'><filename>PV</filename></link> - |
| 805 | The version of the recipe used to build the package. |
| 806 | </para></listitem> |
| 807 | <listitem><para><link linkend='var-PR'><filename>PR</filename></link> - |
| 808 | The revision of the recipe used to build the package. |
| 809 | </para></listitem> |
| 810 | <listitem><para><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link> - |
| 811 | The location within <filename>TMPDIR</filename> where |
| 812 | a specific package is built. |
| 813 | </para></listitem> |
| 814 | <listitem><para><link linkend='var-S'><filename>S</filename></link> - |
| 815 | Contains the unpacked source files for a given recipe. |
| 816 | </para></listitem> |
| 817 | </itemizedlist> |
| 818 | </para> |
| 819 | </section> |
| 820 | |
| 821 | <section id='patching-dev-environment'> |
| 822 | <title>Patching</title> |
| 823 | |
| 824 | <para> |
| 825 | Once source code is fetched and unpacked, BitBake locates |
| 826 | patch files and applies them to the source files: |
| 827 | <imagedata fileref="figures/patching.png" align="center" width="6in" depth="5in" /> |
| 828 | </para> |
| 829 | |
| 830 | <para> |
| 831 | The |
| 832 | <link linkend='ref-tasks-patch'><filename>do_patch</filename></link> |
| 833 | task processes recipes by |
| 834 | using the |
| 835 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 836 | variable to locate applicable patch files, which by default |
| 837 | are <filename>*.patch</filename> or |
| 838 | <filename>*.diff</filename> files, or any file if |
| 839 | "apply=yes" is specified for the file in |
| 840 | <filename>SRC_URI</filename>. |
| 841 | </para> |
| 842 | |
| 843 | <para> |
| 844 | BitBake finds and applies multiple patches for a single recipe |
| 845 | in the order in which it finds the patches. |
| 846 | Patches are applied to the recipe's source files located in the |
| 847 | <link linkend='var-S'><filename>S</filename></link> directory. |
| 848 | </para> |
| 849 | |
| 850 | <para> |
| 851 | For more information on how the source directories are |
| 852 | created, see the |
| 853 | "<link linkend='source-fetching-dev-environment'>Source Fetching</link>" |
| 854 | section. |
| 855 | </para> |
| 856 | </section> |
| 857 | |
| 858 | <section id='configuration-and-compilation-dev-environment'> |
| 859 | <title>Configuration and Compilation</title> |
| 860 | |
| 861 | <para> |
| 862 | After source code is patched, BitBake executes tasks that |
| 863 | configure and compile the source code: |
| 864 | <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" /> |
| 865 | </para> |
| 866 | |
| 867 | <para> |
| 868 | This step in the build process consists of three tasks: |
| 869 | <itemizedlist> |
| 870 | <listitem><para><emphasis><filename>do_configure</filename>:</emphasis> |
| 871 | This task configures the source by enabling and |
| 872 | disabling any build-time and configuration options for |
| 873 | the software being built. |
| 874 | Configurations can come from the recipe itself as well |
| 875 | as from an inherited class. |
| 876 | Additionally, the software itself might configure itself |
| 877 | depending on the target for which it is being built. |
| 878 | </para> |
| 879 | |
| 880 | <para>The configurations handled by the |
| 881 | <link linkend='ref-tasks-configure'><filename>do_configure</filename></link> |
| 882 | task are specific |
| 883 | to source code configuration for the source code |
| 884 | being built by the recipe.</para> |
| 885 | |
| 886 | <para>If you are using the |
| 887 | <link linkend='ref-classes-autotools'><filename>autotools</filename></link> |
| 888 | class, |
| 889 | you can add additional configuration options by using |
| 890 | the <link linkend='var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></link> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 891 | or |
| 892 | <link linkend='var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></link> |
| 893 | variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 894 | For information on how this variable works within |
| 895 | that class, see the |
| 896 | <filename>meta/classes/autotools.bbclass</filename> file. |
| 897 | </para></listitem> |
| 898 | <listitem><para><emphasis><filename>do_compile</filename>:</emphasis> |
| 899 | Once a configuration task has been satisfied, BitBake |
| 900 | compiles the source using the |
| 901 | <link linkend='ref-tasks-compile'><filename>do_compile</filename></link> |
| 902 | task. |
| 903 | Compilation occurs in the directory pointed to by the |
| 904 | <link linkend='var-B'><filename>B</filename></link> |
| 905 | variable. |
| 906 | Realize that the <filename>B</filename> directory is, by |
| 907 | default, the same as the |
| 908 | <link linkend='var-S'><filename>S</filename></link> |
| 909 | directory.</para></listitem> |
| 910 | <listitem><para><emphasis><filename>do_install</filename>:</emphasis> |
| 911 | Once compilation is done, BitBake executes the |
| 912 | <link linkend='ref-tasks-install'><filename>do_install</filename></link> |
| 913 | task. |
| 914 | This task copies files from the <filename>B</filename> |
| 915 | directory and places them in a holding area pointed to |
| 916 | by the |
| 917 | <link linkend='var-D'><filename>D</filename></link> |
| 918 | variable.</para></listitem> |
| 919 | </itemizedlist> |
| 920 | </para> |
| 921 | </section> |
| 922 | |
| 923 | <section id='package-splitting-dev-environment'> |
| 924 | <title>Package Splitting</title> |
| 925 | |
| 926 | <para> |
| 927 | After source code is configured and compiled, the |
| 928 | OpenEmbedded build system analyzes |
| 929 | the results and splits the output into packages: |
| 930 | <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" /> |
| 931 | </para> |
| 932 | |
| 933 | <para> |
| 934 | The |
| 935 | <link linkend='ref-tasks-package'><filename>do_package</filename></link> |
| 936 | and |
| 937 | <link linkend='ref-tasks-packagedata'><filename>do_packagedata</filename></link> |
| 938 | tasks combine to analyze |
| 939 | the files found in the |
| 940 | <link linkend='var-D'><filename>D</filename></link> directory |
| 941 | and split them into subsets based on available packages and |
| 942 | files. |
| 943 | The analyzing process involves the following as well as other |
| 944 | items: splitting out debugging symbols, |
| 945 | looking at shared library dependencies between packages, |
| 946 | and looking at package relationships. |
| 947 | The <filename>do_packagedata</filename> task creates package |
| 948 | metadata based on the analysis such that the |
| 949 | OpenEmbedded build system can generate the final packages. |
| 950 | Working, staged, and intermediate results of the analysis |
| 951 | and package splitting process use these areas: |
| 952 | <itemizedlist> |
| 953 | <listitem><para><link linkend='var-PKGD'><filename>PKGD</filename></link> - |
| 954 | The destination directory for packages before they are |
| 955 | split. |
| 956 | </para></listitem> |
| 957 | <listitem><para><link linkend='var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></link> - |
| 958 | A shared, global-state directory that holds data |
| 959 | generated during the packaging process. |
| 960 | </para></listitem> |
| 961 | <listitem><para><link linkend='var-PKGDESTWORK'><filename>PKGDESTWORK</filename></link> - |
| 962 | A temporary work area used by the |
| 963 | <filename>do_package</filename> task. |
| 964 | </para></listitem> |
| 965 | <listitem><para><link linkend='var-PKGDEST'><filename>PKGDEST</filename></link> - |
| 966 | The parent directory for packages after they have |
| 967 | been split. |
| 968 | </para></listitem> |
| 969 | </itemizedlist> |
| 970 | The <link linkend='var-FILES'><filename>FILES</filename></link> |
| 971 | variable defines the files that go into each package in |
| 972 | <link linkend='var-PACKAGES'><filename>PACKAGES</filename></link>. |
| 973 | If you want details on how this is accomplished, you can |
| 974 | look at the |
| 975 | <link linkend='ref-classes-package'><filename>package</filename></link> |
| 976 | class. |
| 977 | </para> |
| 978 | |
| 979 | <para> |
| 980 | Depending on the type of packages being created (RPM, DEB, or |
| 981 | IPK), the <filename>do_package_write_*</filename> task |
| 982 | creates the actual packages and places them in the |
| 983 | Package Feed area, which is |
| 984 | <filename>${TMPDIR}/deploy</filename>. |
| 985 | You can see the |
| 986 | "<link linkend='package-feeds-dev-environment'>Package Feeds</link>" |
| 987 | section for more detail on that part of the build process. |
| 988 | <note> |
| 989 | Support for creating feeds directly from the |
| 990 | <filename>deploy/*</filename> directories does not exist. |
| 991 | Creating such feeds usually requires some kind of feed |
| 992 | maintenance mechanism that would upload the new packages |
| 993 | into an official package feed (e.g. the |
| 994 | Ångström distribution). |
| 995 | This functionality is highly distribution-specific |
| 996 | and thus is not provided out of the box. |
| 997 | </note> |
| 998 | </para> |
| 999 | </section> |
| 1000 | |
| 1001 | <section id='image-generation-dev-environment'> |
| 1002 | <title>Image Generation</title> |
| 1003 | |
| 1004 | <para> |
| 1005 | Once packages are split and stored in the Package Feeds area, |
| 1006 | the OpenEmbedded build system uses BitBake to generate the |
| 1007 | root filesystem image: |
| 1008 | <imagedata fileref="figures/image-generation.png" align="center" width="6in" depth="7in" /> |
| 1009 | </para> |
| 1010 | |
| 1011 | <para> |
| 1012 | The image generation process consists of several stages and |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1013 | depends on several tasks and variables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1014 | The |
| 1015 | <link linkend='ref-tasks-rootfs'><filename>do_rootfs</filename></link> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1016 | task creates the root filesystem (file and directory structure) |
| 1017 | for an image. |
| 1018 | This task uses several key variables to help create the list |
| 1019 | of packages to actually install: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1020 | <itemizedlist> |
| 1021 | <listitem><para><link linkend='var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></link>: |
| 1022 | Lists out the base set of packages to install from |
| 1023 | the Package Feeds area.</para></listitem> |
| 1024 | <listitem><para><link linkend='var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></link>: |
| 1025 | Specifies packages that should not be installed. |
| 1026 | </para></listitem> |
| 1027 | <listitem><para><link linkend='var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></link>: |
| 1028 | Specifies features to include in the image. |
| 1029 | Most of these features map to additional packages for |
| 1030 | installation.</para></listitem> |
| 1031 | <listitem><para><link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link>: |
| 1032 | Specifies the package backend to use and consequently |
| 1033 | helps determine where to locate packages within the |
| 1034 | Package Feeds area.</para></listitem> |
| 1035 | <listitem><para><link linkend='var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></link>: |
| 1036 | Determines the language(s) for which additional |
| 1037 | language support packages are installed. |
| 1038 | </para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1039 | <listitem><para><link linkend='var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></link>: |
| 1040 | The final list of packages passed to the package manager |
| 1041 | for installation into the image. |
| 1042 | </para></listitem> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1043 | </itemizedlist> |
| 1044 | </para> |
| 1045 | |
| 1046 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1047 | With |
| 1048 | <link linkend='var-IMAGE_ROOTFS'><filename>IMAGE_ROOTFS</filename></link> |
| 1049 | pointing to the location of the filesystem under construction and |
| 1050 | the <filename>PACKAGE_INSTALL</filename> variable providing the |
| 1051 | final list of packages to install, the root file system is |
| 1052 | created. |
| 1053 | </para> |
| 1054 | |
| 1055 | <para> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1056 | Package installation is under control of the package manager |
| 1057 | (e.g. smart/rpm, opkg, or apt/dpkg) regardless of whether or |
| 1058 | not package management is enabled for the target. |
| 1059 | At the end of the process, if package management is not |
| 1060 | enabled for the target, the package manager's data files |
| 1061 | are deleted from the root filesystem. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1062 | As part of the final stage of package installation, postinstall |
| 1063 | scripts that are part of the packages are run. |
| 1064 | Any scripts that fail to run |
| 1065 | on the build host are run on the target when the target system |
| 1066 | is first booted. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1067 | If you are using a |
| 1068 | <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>, |
| 1069 | all the post installation scripts must succeed during the |
| 1070 | package installation phase since the root filesystem is |
| 1071 | read-only. |
| 1072 | </para> |
| 1073 | |
| 1074 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1075 | The final stages of the <filename>do_rootfs</filename> task |
| 1076 | handle post processing. |
| 1077 | Post processing includes creation of a manifest file and |
| 1078 | optimizations. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1079 | </para> |
| 1080 | |
| 1081 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1082 | The manifest file (<filename>.manifest</filename>) resides |
| 1083 | in the same directory as the root filesystem image. |
| 1084 | This file lists out, line-by-line, the installed packages. |
| 1085 | The manifest file is useful for the |
Patrick Williams | f1e5d69 | 2016-03-30 15:21:19 -0500 | [diff] [blame] | 1086 | <link linkend='ref-classes-testimage*'><filename>testimage</filename></link> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1087 | class, for example, to determine whether or not to run |
| 1088 | specific tests. |
| 1089 | See the |
| 1090 | <link linkend='var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></link> |
| 1091 | variable for additional information. |
| 1092 | </para> |
| 1093 | |
| 1094 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1095 | Optimizing processes run across the image include |
| 1096 | <filename>mklibs</filename>, <filename>prelink</filename>, |
| 1097 | and any other post-processing commands as defined by the |
| 1098 | <link linkend='var-ROOTFS_POSTPROCESS_COMMAND'><filename>ROOTFS_POSTPROCESS_COMMAND</filename></link> |
| 1099 | variable. |
| 1100 | The <filename>mklibs</filename> process optimizes the size |
| 1101 | of the libraries, while the |
| 1102 | <filename>prelink</filename> process optimizes the dynamic |
| 1103 | linking of shared libraries to reduce start up time of |
| 1104 | executables. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1105 | </para> |
| 1106 | |
| 1107 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1108 | After the root filesystem is built, processing begins on |
| 1109 | the image through the <filename>do_image</filename> task. |
| 1110 | The build system runs any pre-processing commands as defined |
| 1111 | by the |
| 1112 | <link linkend='var-IMAGE_PREPROCESS_COMMAND'><filename>IMAGE_PREPROCESS_COMMAND</filename></link> |
| 1113 | variable. |
| 1114 | This variable specifies a list of functions to call before |
| 1115 | the OpenEmbedded build system creates the final image output |
| 1116 | files. |
| 1117 | </para> |
| 1118 | |
| 1119 | <para> |
| 1120 | The <filename>do_image</filename> task dynamically creates |
| 1121 | other <filename>do_image_*</filename> tasks as needed, which |
| 1122 | include compressing the root filesystem image to reduce the |
| 1123 | overall size of the image. |
| 1124 | The process turns everything into an image file or a set of |
| 1125 | image files. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1126 | The formats used for the root filesystem depend on the |
| 1127 | <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link> |
| 1128 | variable. |
| 1129 | </para> |
| 1130 | |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1131 | <para> |
| 1132 | The final task involved in image creation is the |
| 1133 | <filename>do_image_complete</filename> task. |
| 1134 | This task completes the image by applying any image |
| 1135 | post processing as defined through the |
| 1136 | <link linkend='var-IMAGE_POSTPROCESS_COMMAND'><filename>IMAGE_POSTPROCESS_COMMAND</filename></link> |
| 1137 | variable. |
| 1138 | The variable specifies a list of functions to call once the |
| 1139 | OpenEmbedded build system has created the final image output |
| 1140 | files. |
| 1141 | </para> |
| 1142 | |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1143 | <note> |
| 1144 | The entire image generation process is run under Pseudo. |
| 1145 | Running under Pseudo ensures that the files in the root |
| 1146 | filesystem have correct ownership. |
| 1147 | </note> |
| 1148 | </section> |
| 1149 | |
| 1150 | <section id='sdk-generation-dev-environment'> |
| 1151 | <title>SDK Generation</title> |
| 1152 | |
| 1153 | <para> |
| 1154 | The OpenEmbedded build system uses BitBake to generate the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1155 | Software Development Kit (SDK) installer script for both the |
| 1156 | standard and extensible SDKs: |
| 1157 | <imagedata fileref="figures/sdk-generation.png" align="center" /> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1158 | </para> |
| 1159 | |
| 1160 | <note> |
| 1161 | For more information on the cross-development toolchain |
| 1162 | generation, see the |
| 1163 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" |
| 1164 | section. |
| 1165 | For information on advantages gained when building a |
| 1166 | cross-development toolchain using the |
| 1167 | <link linkend='ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></link> |
| 1168 | task, see the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1169 | "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>" |
| 1170 | section in the Yocto Project Software Development Kit (SDK) |
| 1171 | Developer's Guide. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1172 | </note> |
| 1173 | |
| 1174 | <para> |
| 1175 | Like image generation, the SDK script process consists of |
| 1176 | several stages and depends on many variables. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1177 | The <filename>do_populate_sdk</filename> and |
| 1178 | <filename>do_populate_sdk_ext</filename> tasks use these |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1179 | key variables to help create the list of packages to actually |
| 1180 | install. |
| 1181 | For information on the variables listed in the figure, see the |
| 1182 | "<link linkend='sdk-dev-environment'>Application Development SDK</link>" |
| 1183 | section. |
| 1184 | </para> |
| 1185 | |
| 1186 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1187 | The <filename>do_populate_sdk</filename> task helps create |
| 1188 | the standard SDK and handles two parts: a target part and a |
| 1189 | host part. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1190 | The target part is the part built for the target hardware and |
| 1191 | includes libraries and headers. |
| 1192 | The host part is the part of the SDK that runs on the |
| 1193 | <link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>. |
| 1194 | </para> |
| 1195 | |
| 1196 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1197 | The <filename>do_populate_sdk_ext</filename> task helps create |
| 1198 | the extensible SDK and handles host and target parts |
| 1199 | differently than its counter part does for the standard SDK. |
| 1200 | For the extensible SDK, the task encapsulates the build system, |
| 1201 | which includes everything needed (host and target) for the SDK. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1202 | </para> |
| 1203 | |
| 1204 | <para> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1205 | Regardless of the type of SDK being constructed, the |
| 1206 | tasks perform some cleanup after which a cross-development |
| 1207 | environment setup script and any needed configuration files |
| 1208 | are created. |
| 1209 | The final output is the Cross-development |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1210 | toolchain installation script (<filename>.sh</filename> file), |
| 1211 | which includes the environment setup script. |
| 1212 | </para> |
| 1213 | </section> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1214 | |
| 1215 | <section id='stamp-files-and-the-rerunning-of-tasks'> |
| 1216 | <title>Stamp Files and the Rerunning of Tasks</title> |
| 1217 | |
| 1218 | <para> |
| 1219 | For each task that completes successfully, BitBake writes a |
| 1220 | stamp file into the |
| 1221 | <link linkend='var-STAMPS_DIR'><filename>STAMPS_DIR</filename></link> |
| 1222 | directory. |
| 1223 | The beginning of the stamp file's filename is determined by the |
| 1224 | <link linkend='var-STAMP'><filename>STAMP</filename></link> |
| 1225 | variable, and the end of the name consists of the task's name |
| 1226 | and current |
| 1227 | <ulink url='&YOCTO_DOCS_BB_URL;#checksums'>input checksum</ulink>. |
| 1228 | <note> |
| 1229 | This naming scheme assumes that |
| 1230 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SIGNATURE_HANDLER'><filename>BB_SIGNATURE_HANDLER</filename></ulink> |
| 1231 | is "OEBasicHash", which is almost always the case in |
| 1232 | current OpenEmbedded. |
| 1233 | </note> |
| 1234 | To determine if a task needs to be rerun, BitBake checks if a |
| 1235 | stamp file with a matching input checksum exists for the task. |
| 1236 | If such a stamp file exists, the task's output is assumed to |
| 1237 | exist and still be valid. |
| 1238 | If the file does not exist, the task is rerun. |
| 1239 | <note> |
| 1240 | <para>The stamp mechanism is more general than the shared |
| 1241 | state (sstate) cache mechanism described in the |
| 1242 | "<link linkend='setscene-tasks-and-shared-state'>Setscene Tasks and Shared State</link>" |
| 1243 | section. |
| 1244 | BitBake avoids rerunning any task that has a valid |
| 1245 | stamp file, not just tasks that can be accelerated through |
| 1246 | the sstate cache.</para> |
| 1247 | <para>However, you should realize that stamp files only |
| 1248 | serve as a marker that some work has been done and that |
| 1249 | these files do not record task output. |
| 1250 | The actual task output would usually be somewhere in |
| 1251 | <link linkend='var-TMPDIR'><filename>TMPDIR</filename></link> |
| 1252 | (e.g. in some recipe's |
| 1253 | <link linkend='var-WORKDIR'><filename>WORKDIR</filename></link>.) |
| 1254 | What the sstate cache mechanism adds is a way to cache task |
| 1255 | output that can then be shared between build machines. |
| 1256 | </para> |
| 1257 | </note> |
| 1258 | Since <filename>STAMPS_DIR</filename> is usually a subdirectory |
| 1259 | of <filename>TMPDIR</filename>, removing |
| 1260 | <filename>TMPDIR</filename> will also remove |
| 1261 | <filename>STAMPS_DIR</filename>, which means tasks will |
| 1262 | properly be rerun to repopulate <filename>TMPDIR</filename>. |
| 1263 | </para> |
| 1264 | |
| 1265 | <para> |
| 1266 | If you want some task to always be considered "out of date", |
| 1267 | you can mark it with the |
| 1268 | <ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink> |
| 1269 | varflag. |
| 1270 | If some other task depends on such a task, then that task will |
| 1271 | also always be considered out of date, which might not be what |
| 1272 | you want. |
| 1273 | </para> |
| 1274 | |
| 1275 | <para> |
| 1276 | For details on how to view information about a task's |
| 1277 | signature, see the |
| 1278 | "<link linkend='usingpoky-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</link>" |
| 1279 | section. |
| 1280 | </para> |
| 1281 | </section> |
| 1282 | |
| 1283 | <section id='setscene-tasks-and-shared-state'> |
| 1284 | <title>Setscene Tasks and Shared State</title> |
| 1285 | |
| 1286 | <para> |
| 1287 | The description of tasks so far assumes that BitBake needs to |
| 1288 | build everything and there are no prebuilt objects available. |
| 1289 | BitBake does support skipping tasks if prebuilt objects are |
| 1290 | available. |
| 1291 | These objects are usually made available in the form of a |
| 1292 | shared state (sstate) cache. |
| 1293 | <note> |
| 1294 | For information on variables affecting sstate, see the |
| 1295 | <link linkend='var-SSTATE_DIR'><filename>SSTATE_DIR</filename></link> |
| 1296 | and |
| 1297 | <link linkend='var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></link> |
| 1298 | variables. |
| 1299 | </note> |
| 1300 | </para> |
| 1301 | |
| 1302 | <para> |
| 1303 | The idea of a setscene task (i.e |
| 1304 | <filename>do_</filename><replaceable>taskname</replaceable><filename>_setscene</filename>) |
| 1305 | is a version of the task where |
| 1306 | instead of building something, BitBake can skip to the end |
| 1307 | result and simply place a set of files into specific locations |
| 1308 | as needed. |
| 1309 | In some cases, it makes sense to have a setscene task variant |
| 1310 | (e.g. generating package files in the |
| 1311 | <filename>do_package_write_*</filename> task). |
| 1312 | In other cases, it does not make sense, (e.g. a |
| 1313 | <link linkend='ref-tasks-patch'><filename>do_patch</filename></link> |
| 1314 | task or |
| 1315 | <link linkend='ref-tasks-unpack'><filename>do_unpack</filename></link> |
| 1316 | task) since the work involved would be equal to or greater than |
| 1317 | the underlying task. |
| 1318 | </para> |
| 1319 | |
| 1320 | <para> |
| 1321 | In the OpenEmbedded build system, the common tasks that have |
| 1322 | setscene variants are <link linkend='ref-tasks-package'><filename>do_package</filename></link>, |
| 1323 | <filename>do_package_write_*</filename>, |
| 1324 | <link linkend='ref-tasks-deploy'><filename>do_deploy</filename></link>, |
| 1325 | <link linkend='ref-tasks-packagedata'><filename>do_packagedata</filename></link>, |
| 1326 | and |
| 1327 | <link linkend='ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></link>. |
| 1328 | Notice that these are most of the tasks whose output is an |
| 1329 | end result. |
| 1330 | </para> |
| 1331 | |
| 1332 | <para> |
| 1333 | The OpenEmbedded build system has knowledge of the relationship |
| 1334 | between these tasks and other tasks that precede them. |
| 1335 | For example, if BitBake runs |
| 1336 | <filename>do_populate_sysroot_setscene</filename> for |
| 1337 | something, there is little point in running any of the |
| 1338 | <filename>do_fetch</filename>, <filename>do_unpack</filename>, |
| 1339 | <filename>do_patch</filename>, |
| 1340 | <filename>do_configure</filename>, |
| 1341 | <filename>do_compile</filename>, and |
| 1342 | <filename>do_install</filename> tasks. |
| 1343 | However, if <filename>do_package</filename> needs to be run, |
| 1344 | BitBake would need to run those other tasks. |
| 1345 | </para> |
| 1346 | |
| 1347 | <para> |
| 1348 | It becomes more complicated if everything can come from an |
| 1349 | sstate cache because some objects are simply not required at |
| 1350 | all. |
| 1351 | For example, you do not need a compiler or native tools, such |
| 1352 | as quilt, if there is nothing to compile or patch. |
| 1353 | If the <filename>do_package_write_*</filename> packages are |
| 1354 | available from sstate, BitBake does not need the |
| 1355 | <filename>do_package</filename> task data. |
| 1356 | </para> |
| 1357 | |
| 1358 | <para> |
| 1359 | To handle all these complexities, BitBake runs in two phases. |
| 1360 | The first is the "setscene" stage. |
| 1361 | During this stage, BitBake first checks the sstate cache for |
| 1362 | any targets it is planning to build. |
| 1363 | BitBake does a fast check to see if the object exists rather |
| 1364 | than a complete download. |
| 1365 | If nothing exists, the second phase, which is the setscene |
| 1366 | stage, completes and the main build proceeds. |
| 1367 | </para> |
| 1368 | |
| 1369 | <para> |
| 1370 | If objects are found in the sstate cache, the OpenEmbedded |
| 1371 | build system works backwards from the end targets specified |
| 1372 | by the user. |
| 1373 | For example, if an image is being built, the OpenEmbedded build |
| 1374 | system first looks for the packages needed for that image and |
| 1375 | the tools needed to construct an image. |
| 1376 | If those are available, the compiler is not needed. |
| 1377 | Thus, the compiler is not even downloaded. |
| 1378 | If something was found to be unavailable, or the download or |
| 1379 | setscene task fails, the OpenEmbedded build system then tries |
| 1380 | to install dependencies, such as the compiler, from the cache. |
| 1381 | </para> |
| 1382 | |
| 1383 | <para> |
| 1384 | The availability of objects in the sstate cache is handled by |
| 1385 | the function specified by the |
| 1386 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHCHECK_FUNCTION'><filename>BB_HASHCHECK_FUNCTION</filename></ulink> |
| 1387 | variable and returns a list of the objects that are available. |
| 1388 | The function specified by the |
| 1389 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_DEPVALID'><filename>BB_SETSCENE_DEPVALID</filename></ulink> |
| 1390 | variable is the function that determines whether a given |
| 1391 | dependency needs to be followed, and whether for any given |
| 1392 | relationship the function needs to be passed. |
| 1393 | The function returns a True or False value. |
| 1394 | </para> |
| 1395 | |
| 1396 | <para> |
| 1397 | Once the setscene process completes, the OpenEmbedded build |
| 1398 | system has a list of tasks that it believes it can "accelerate" |
| 1399 | and therefore does not need to run. |
| 1400 | There is a final function call to the function specified by the |
| 1401 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_VERIFY_FUNCTION2'><filename>BB_SETSCENE_VERIFY_FUNCTION2</filename></ulink> |
| 1402 | variable that is able to require the tasks to be run that |
| 1403 | that the OpenEmbedded build system initially was going to |
| 1404 | skip. |
| 1405 | </para> |
| 1406 | </section> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1407 | </section> |
| 1408 | |
| 1409 | <section id='images-dev-environment'> |
| 1410 | <title>Images</title> |
| 1411 | |
| 1412 | <para> |
| 1413 | The images produced by the OpenEmbedded build system |
| 1414 | are compressed forms of the |
| 1415 | root filesystem that are ready to boot on a target device. |
| 1416 | You can see from the |
| 1417 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 1418 | that BitBake output, in part, consists of images. |
| 1419 | This section is going to look more closely at this output: |
| 1420 | <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" /> |
| 1421 | </para> |
| 1422 | |
| 1423 | <para> |
| 1424 | For a list of example images that the Yocto Project provides, |
| 1425 | see the |
| 1426 | "<link linkend='ref-images'>Images</link>" chapter. |
| 1427 | </para> |
| 1428 | |
| 1429 | <para> |
| 1430 | Images are written out to the |
| 1431 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 1432 | inside the <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename> |
| 1433 | folder as shown in the figure. |
| 1434 | This folder contains any files expected to be loaded on the |
| 1435 | target device. |
| 1436 | The |
| 1437 | <link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link> |
| 1438 | variable points to the <filename>deploy</filename> directory, |
| 1439 | while the |
| 1440 | <link linkend='var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></link> |
| 1441 | variable points to the appropriate directory containing images for |
| 1442 | the current configuration. |
| 1443 | <itemizedlist> |
| 1444 | <listitem><para><filename><replaceable>kernel-image</replaceable></filename>: |
| 1445 | A kernel binary file. |
| 1446 | The <link linkend='var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></link> |
| 1447 | variable setting determines the naming scheme for the |
| 1448 | kernel image file. |
| 1449 | Depending on that variable, the file could begin with |
| 1450 | a variety of naming strings. |
| 1451 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1452 | directory can contain multiple image files for the |
| 1453 | machine.</para></listitem> |
| 1454 | <listitem><para><filename><replaceable>root-filesystem-image</replaceable></filename>: |
| 1455 | Root filesystems for the target device (e.g. |
| 1456 | <filename>*.ext3</filename> or <filename>*.bz2</filename> |
| 1457 | files). |
| 1458 | The <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link> |
| 1459 | variable setting determines the root filesystem image |
| 1460 | type. |
| 1461 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1462 | directory can contain multiple root filesystems for the |
| 1463 | machine.</para></listitem> |
| 1464 | <listitem><para><filename><replaceable>kernel-modules</replaceable></filename>: |
| 1465 | Tarballs that contain all the modules built for the kernel. |
| 1466 | Kernel module tarballs exist for legacy purposes and |
| 1467 | can be suppressed by setting the |
| 1468 | <link linkend='var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></link> |
| 1469 | variable to "0". |
| 1470 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1471 | directory can contain multiple kernel module tarballs |
| 1472 | for the machine.</para></listitem> |
| 1473 | <listitem><para><filename><replaceable>bootloaders</replaceable></filename>: |
| 1474 | Bootloaders supporting the image, if applicable to the |
| 1475 | target machine. |
| 1476 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1477 | directory can contain multiple bootloaders for the |
| 1478 | machine.</para></listitem> |
| 1479 | <listitem><para><filename><replaceable>symlinks</replaceable></filename>: |
| 1480 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1481 | folder contains |
| 1482 | a symbolic link that points to the most recently built file |
| 1483 | for each machine. |
| 1484 | These links might be useful for external scripts that |
| 1485 | need to obtain the latest version of each file. |
| 1486 | </para></listitem> |
| 1487 | </itemizedlist> |
| 1488 | </para> |
| 1489 | </section> |
| 1490 | |
| 1491 | <section id='sdk-dev-environment'> |
| 1492 | <title>Application Development SDK</title> |
| 1493 | |
| 1494 | <para> |
| 1495 | In the |
| 1496 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, |
| 1497 | the output labeled "Application Development SDK" represents an |
| 1498 | SDK. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1499 | The SDK generation process differs depending on whether you build |
| 1500 | a standard SDK |
| 1501 | (e.g. <filename>bitbake -c populate_sdk</filename> <replaceable>imagename</replaceable>) |
| 1502 | or an extensible SDK |
| 1503 | (e.g. <filename>bitbake -c populate_sdk_ext</filename> <replaceable>imagename</replaceable>). |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1504 | This section is going to take a closer look at this output: |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1505 | <imagedata fileref="figures/sdk.png" align="center" width="9in" depth="7.25in" /> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1506 | </para> |
| 1507 | |
| 1508 | <para> |
| 1509 | The specific form of this output is a self-extracting |
| 1510 | SDK installer (<filename>*.sh</filename>) that, when run, |
| 1511 | installs the SDK, which consists of a cross-development |
| 1512 | toolchain, a set of libraries and headers, and an SDK |
| 1513 | environment setup script. |
| 1514 | Running this installer essentially sets up your |
| 1515 | cross-development environment. |
| 1516 | You can think of the cross-toolchain as the "host" |
| 1517 | part because it runs on the SDK machine. |
| 1518 | You can think of the libraries and headers as the "target" |
| 1519 | part because they are built for the target hardware. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1520 | The environment setup script is added so that you can initialize |
| 1521 | the environment before using the tools. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1522 | </para> |
| 1523 | |
| 1524 | <note> |
| 1525 | <para> |
| 1526 | The Yocto Project supports several methods by which you can |
| 1527 | set up this cross-development environment. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1528 | These methods include downloading pre-built SDK installers |
| 1529 | or building and installing your own SDK installer. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1530 | </para> |
| 1531 | |
| 1532 | <para> |
| 1533 | For background information on cross-development toolchains |
| 1534 | in the Yocto Project development environment, see the |
| 1535 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" |
| 1536 | section. |
| 1537 | For information on setting up a cross-development |
| 1538 | environment, see the |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1539 | <ulink url='&YOCTO_DOCS_SDK_URL;#sdk-manual'>Yocto Project Software Development Kit (SDK) Developer's Guide</ulink>. |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1540 | </para> |
| 1541 | </note> |
| 1542 | |
| 1543 | <para> |
| 1544 | Once built, the SDK installers are written out to the |
| 1545 | <filename>deploy/sdk</filename> folder inside the |
| 1546 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 1547 | as shown in the figure at the beginning of this section. |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1548 | Depending on the type of SDK, several variables exist that help |
| 1549 | configure these files. |
| 1550 | The following list shows the variables associated with a standard |
| 1551 | SDK: |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1552 | <itemizedlist> |
| 1553 | <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>: |
| 1554 | Points to the <filename>deploy</filename> |
| 1555 | directory.</para></listitem> |
| 1556 | <listitem><para><link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>: |
| 1557 | Specifies the architecture of the machine |
| 1558 | on which the cross-development tools are run to |
| 1559 | create packages for the target hardware. |
| 1560 | </para></listitem> |
| 1561 | <listitem><para><link linkend='var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></link>: |
| 1562 | Lists the features to include in the "target" part |
| 1563 | of the SDK. |
| 1564 | </para></listitem> |
| 1565 | <listitem><para><link linkend='var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></link>: |
| 1566 | Lists packages that make up the host |
| 1567 | part of the SDK (i.e. the part that runs on |
| 1568 | the <filename>SDKMACHINE</filename>). |
| 1569 | When you use |
| 1570 | <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename> |
| 1571 | to create the SDK, a set of default packages |
| 1572 | apply. |
| 1573 | This variable allows you to add more packages. |
| 1574 | </para></listitem> |
| 1575 | <listitem><para><link linkend='var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></link>: |
| 1576 | Lists packages that make up the target part |
| 1577 | of the SDK (i.e. the part built for the |
| 1578 | target hardware). |
| 1579 | </para></listitem> |
| 1580 | <listitem><para><link linkend='var-SDKPATH'><filename>SDKPATH</filename></link>: |
| 1581 | Defines the default SDK installation path offered by the |
| 1582 | installation script. |
| 1583 | </para></listitem> |
| 1584 | </itemizedlist> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1585 | This next list, shows the variables associated with an extensible |
| 1586 | SDK: |
| 1587 | <itemizedlist> |
| 1588 | <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>: |
| 1589 | Points to the <filename>deploy</filename> directory. |
| 1590 | </para></listitem> |
| 1591 | <listitem><para><link linkend='var-SDK_EXT_TYPE'><filename>SDK_EXT_TYPE</filename></link>: |
| 1592 | Controls whether or not shared state artifacts are copied |
| 1593 | into the extensible SDK. |
| 1594 | By default, all required shared state artifacts are copied |
| 1595 | into the SDK. |
| 1596 | </para></listitem> |
| 1597 | <listitem><para><link linkend='var-SDK_INCLUDE_PKGDATA'><filename>SDK_INCLUDE_PKGDATA</filename></link>: |
| 1598 | Specifies whether or not packagedata will be included in |
| 1599 | the extensible SDK for all recipes in the "world" target. |
| 1600 | </para></listitem> |
Patrick Williams | c0f7c04 | 2017-02-23 20:41:17 -0600 | [diff] [blame] | 1601 | <listitem><para><link linkend='var-SDK_INCLUDE_TOOLCHAIN'><filename>SDK_INCLUDE_TOOLCHAIN</filename></link>: |
| 1602 | Specifies whether or not the toolchain will be included |
| 1603 | when building the extensible SDK. |
| 1604 | </para></listitem> |
Patrick Williams | d8c66bc | 2016-06-20 12:57:21 -0500 | [diff] [blame] | 1605 | <listitem><para><link linkend='var-SDK_LOCAL_CONF_WHITELIST'><filename>SDK_LOCAL_CONF_WHITELIST</filename></link>: |
| 1606 | A list of variables allowed through from the build system |
| 1607 | configuration into the extensible SDK configuration. |
| 1608 | </para></listitem> |
| 1609 | <listitem><para><link linkend='var-SDK_LOCAL_CONF_BLACKLIST'><filename>SDK_LOCAL_CONF_BLACKLIST</filename></link>: |
| 1610 | A list of variables not allowed through from the build |
| 1611 | system configuration into the extensible SDK configuration. |
| 1612 | </para></listitem> |
| 1613 | <listitem><para><link linkend='var-SDK_INHERIT_BLACKLIST'><filename>SDK_INHERIT_BLACKLIST</filename></link>: |
| 1614 | A list of classes to remove from the |
| 1615 | <link linkend='var-INHERIT'><filename>INHERIT</filename></link> |
| 1616 | value globally within the extensible SDK configuration. |
| 1617 | </para></listitem> |
| 1618 | </itemizedlist> |
Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1619 | </para> |
| 1620 | </section> |
| 1621 | |
| 1622 | </chapter> |
| 1623 | <!-- |
| 1624 | vim: expandtab tw=80 ts=4 |
| 1625 | --> |