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> |
| 76 | <imagedata fileref="figures/user-configuration.png" align="center" width="5.5in" depth="3.5in" /> |
| 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> |
| 103 | The <filename>meta-yocto</filename> layer inside Poky contains |
| 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 |
| 161 | <filename>meta-yocto</filename> layer: |
| 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. |
| 211 | If you want these configuration files, you must create them |
| 212 | yourself: |
| 213 | <itemizedlist> |
| 214 | <listitem><para><emphasis><filename>site.conf</filename>:</emphasis> |
| 215 | You can use the <filename>conf/site.conf</filename> |
| 216 | configuration file to configure multiple build directories. |
| 217 | For example, suppose you had several build environments and |
| 218 | they shared some common features. |
| 219 | You can set these default build properties here. |
| 220 | A good example is perhaps the packaging format to use |
| 221 | through the |
| 222 | <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link> |
| 223 | variable.</para> |
| 224 | <para>One useful scenario for using the |
| 225 | <filename>conf/site.conf</filename> file is to extend your |
| 226 | <link linkend='var-BBPATH'><filename>BBPATH</filename></link> |
| 227 | variable to include the path to a |
| 228 | <filename>conf/site.conf</filename>. |
| 229 | Then, when BitBake looks for Metadata using |
| 230 | <filename>BBPATH</filename>, it finds the |
| 231 | <filename>conf/site.conf</filename> file and applies your |
| 232 | common configurations found in the file. |
| 233 | To override configurations in a particular build directory, |
| 234 | alter the similar configurations within that build |
| 235 | directory's <filename>conf/local.conf</filename> file. |
| 236 | </para></listitem> |
| 237 | <listitem><para><emphasis><filename>auto.conf</filename>:</emphasis> |
| 238 | This file is not hand-created. |
| 239 | Rather, the file is usually created and written to by |
| 240 | an autobuilder. |
| 241 | The settings put into the file are typically the same as |
| 242 | you would find in the <filename>conf/local.conf</filename> |
| 243 | or the <filename>conf/site.conf</filename> files. |
| 244 | </para></listitem> |
| 245 | </itemizedlist> |
| 246 | </para> |
| 247 | |
| 248 | <para> |
| 249 | You can edit all configuration files to further define |
| 250 | any particular build environment. |
| 251 | This process is represented by the "User Configuration Edits" |
| 252 | box in the figure. |
| 253 | </para> |
| 254 | |
| 255 | <para> |
| 256 | When you launch your build with the |
| 257 | <filename>bitbake <replaceable>target</replaceable></filename> command, BitBake |
| 258 | sorts out the configurations to ultimately define your build |
| 259 | environment. |
| 260 | </para> |
| 261 | </section> |
| 262 | |
| 263 | <section id="metadata-machine-configuration-and-policy-configuration"> |
| 264 | <title>Metadata, Machine Configuration, and Policy Configuration</title> |
| 265 | |
| 266 | <para> |
| 267 | The previous section described the user configurations that |
| 268 | define BitBake's global behavior. |
| 269 | This section takes a closer look at the layers the build system |
| 270 | uses to further control the build. |
| 271 | These layers provide Metadata for the software, machine, and |
| 272 | policy. |
| 273 | </para> |
| 274 | |
| 275 | <para> |
| 276 | In general, three types of layer input exist: |
| 277 | <itemizedlist> |
| 278 | <listitem><para><emphasis>Policy Configuration:</emphasis> |
| 279 | Distribution Layers provide top-level or general |
| 280 | policies for the image or SDK being built. |
| 281 | For example, this layer would dictate whether BitBake |
| 282 | produces RPM or IPK packages.</para></listitem> |
| 283 | <listitem><para><emphasis>Machine Configuration:</emphasis> |
| 284 | Board Support Package (BSP) layers provide machine |
| 285 | configurations. |
| 286 | This type of information is specific to a particular |
| 287 | target architecture.</para></listitem> |
| 288 | <listitem><para><emphasis>Metadata:</emphasis> |
| 289 | Software layers contain user-supplied recipe files, |
| 290 | patches, and append files. |
| 291 | </para></listitem> |
| 292 | </itemizedlist> |
| 293 | </para> |
| 294 | |
| 295 | <para> |
| 296 | The following figure shows an expanded representation of the |
| 297 | Metadata, Machine Configuration, and Policy Configuration input |
| 298 | (layers) boxes of the |
| 299 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>: |
| 300 | </para> |
| 301 | |
| 302 | <para> |
| 303 | <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="7.5in" /> |
| 304 | </para> |
| 305 | |
| 306 | <para> |
| 307 | In general, all layers have a similar structure. |
| 308 | They all contain a licensing file |
| 309 | (e.g. <filename>COPYING</filename>) if the layer is to be |
| 310 | distributed, a <filename>README</filename> file as good practice |
| 311 | and especially if the layer is to be distributed, a |
| 312 | configuration directory, and recipe directories. |
| 313 | </para> |
| 314 | |
| 315 | <para> |
| 316 | The Yocto Project has many layers that can be used. |
| 317 | You can see a web-interface listing of them on the |
| 318 | <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink> |
| 319 | page. |
| 320 | The layers are shown at the bottom categorized under |
| 321 | "Yocto Metadata Layers." |
| 322 | These layers are fundamentally a subset of the |
| 323 | <ulink url="http://layers.openembedded.org/layerindex/layers/">OpenEmbedded Metadata Index</ulink>, |
| 324 | which lists all layers provided by the OpenEmbedded community. |
| 325 | <note> |
| 326 | Layers exist in the Yocto Project Source Repositories that |
| 327 | cannot be found in the OpenEmbedded Metadata Index. |
| 328 | These layers are either deprecated or experimental in nature. |
| 329 | </note> |
| 330 | </para> |
| 331 | |
| 332 | <para> |
| 333 | BitBake uses the <filename>conf/bblayers.conf</filename> file, |
| 334 | which is part of the user configuration, to find what layers it |
| 335 | should be using as part of the build. |
| 336 | </para> |
| 337 | |
| 338 | <para> |
| 339 | For more information on layers, see the |
| 340 | "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" |
| 341 | section in the Yocto Project Development Manual. |
| 342 | </para> |
| 343 | |
| 344 | <section id="distro-layer"> |
| 345 | <title>Distro Layer</title> |
| 346 | |
| 347 | <para> |
| 348 | The distribution layer provides policy configurations for your |
| 349 | distribution. |
| 350 | Best practices dictate that you isolate these types of |
| 351 | configurations into their own layer. |
| 352 | Settings you provide in |
| 353 | <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override |
| 354 | similar |
| 355 | settings that BitBake finds in your |
| 356 | <filename>conf/local.conf</filename> file in the Build |
| 357 | Directory. |
| 358 | </para> |
| 359 | |
| 360 | <para> |
| 361 | The following list provides some explanation and references |
| 362 | for what you typically find in the distribution layer: |
| 363 | <itemizedlist> |
| 364 | <listitem><para><emphasis>classes:</emphasis> |
| 365 | Class files (<filename>.bbclass</filename>) hold |
| 366 | common functionality that can be shared among |
| 367 | recipes in the distribution. |
| 368 | When your recipes inherit a class, they take on the |
| 369 | settings and functions for that class. |
| 370 | You can read more about class files in the |
| 371 | "<link linkend='ref-classes'>Classes</link>" section. |
| 372 | </para></listitem> |
| 373 | <listitem><para><emphasis>conf:</emphasis> |
| 374 | This area holds configuration files for the |
| 375 | layer (<filename>conf/layer.conf</filename>), |
| 376 | the distribution |
| 377 | (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>), |
| 378 | and any distribution-wide include files. |
| 379 | </para></listitem> |
| 380 | <listitem><para><emphasis>recipes-*:</emphasis> |
| 381 | Recipes and append files that affect common |
| 382 | functionality across the distribution. |
| 383 | This area could include recipes and append files |
| 384 | to add distribution-specific configuration, |
| 385 | initialization scripts, custom image recipes, |
| 386 | and so forth.</para></listitem> |
| 387 | </itemizedlist> |
| 388 | </para> |
| 389 | </section> |
| 390 | |
| 391 | <section id="bsp-layer"> |
| 392 | <title>BSP Layer</title> |
| 393 | |
| 394 | <para> |
| 395 | The BSP Layer provides machine configurations. |
| 396 | Everything in this layer is specific to the machine for which |
| 397 | you are building the image or the SDK. |
| 398 | A common structure or form is defined for BSP layers. |
| 399 | You can learn more about this structure in the |
| 400 | <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>. |
| 401 | <note> |
| 402 | In order for a BSP layer to be considered compliant with the |
| 403 | Yocto Project, it must meet some structural requirements. |
| 404 | </note> |
| 405 | </para> |
| 406 | |
| 407 | <para> |
| 408 | The BSP Layer's configuration directory contains |
| 409 | configuration files for the machine |
| 410 | (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>) and, |
| 411 | of course, the layer (<filename>conf/layer.conf</filename>). |
| 412 | </para> |
| 413 | |
| 414 | <para> |
| 415 | The remainder of the layer is dedicated to specific recipes |
| 416 | by function: <filename>recipes-bsp</filename>, |
| 417 | <filename>recipes-core</filename>, |
| 418 | <filename>recipes-graphics</filename>, and |
| 419 | <filename>recipes-kernel</filename>. |
| 420 | Metadata can exist for multiple formfactors, graphics |
| 421 | support systems, and so forth. |
| 422 | <note> |
| 423 | While the figure shows several <filename>recipes-*</filename> |
| 424 | directories, not all these directories appear in all |
| 425 | BSP layers. |
| 426 | </note> |
| 427 | </para> |
| 428 | </section> |
| 429 | |
| 430 | <section id="software-layer"> |
| 431 | <title>Software Layer</title> |
| 432 | |
| 433 | <para> |
| 434 | The software layer provides the Metadata for additional |
| 435 | software packages used during the build. |
| 436 | This layer does not include Metadata that is specific to the |
| 437 | distribution or the machine, which are found in their |
| 438 | respective layers. |
| 439 | </para> |
| 440 | |
| 441 | <para> |
| 442 | This layer contains any new recipes that your project needs |
| 443 | in the form of recipe files. |
| 444 | </para> |
| 445 | </section> |
| 446 | </section> |
| 447 | |
| 448 | <section id="sources-dev-environment"> |
| 449 | <title>Sources</title> |
| 450 | |
| 451 | <para> |
| 452 | In order for the OpenEmbedded build system to create an image or |
| 453 | any target, it must be able to access source files. |
| 454 | The |
| 455 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 456 | represents source files using the "Upstream Project Releases", |
| 457 | "Local Projects", and "SCMs (optional)" boxes. |
| 458 | The figure represents mirrors, which also play a role in locating |
| 459 | source files, with the "Source Mirror(s)" box. |
| 460 | </para> |
| 461 | |
| 462 | <para> |
| 463 | The method by which source files are ultimately organized is |
| 464 | a function of the project. |
| 465 | For example, for released software, projects tend to use tarballs |
| 466 | or other archived files that can capture the state of a release |
| 467 | guaranteeing that it is statically represented. |
| 468 | On the other hand, for a project that is more dynamic or |
| 469 | experimental in nature, a project might keep source files in a |
| 470 | repository controlled by a Source Control Manager (SCM) such as |
| 471 | Git. |
| 472 | Pulling source from a repository allows you to control |
| 473 | the point in the repository (the revision) from which you want to |
| 474 | build software. |
| 475 | Finally, a combination of the two might exist, which would give the |
| 476 | consumer a choice when deciding where to get source files. |
| 477 | </para> |
| 478 | |
| 479 | <para> |
| 480 | BitBake uses the |
| 481 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 482 | variable to point to source files regardless of their location. |
| 483 | Each recipe must have a <filename>SRC_URI</filename> variable |
| 484 | that points to the source. |
| 485 | </para> |
| 486 | |
| 487 | <para> |
| 488 | Another area that plays a significant role in where source files |
| 489 | come from is pointed to by the |
| 490 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 491 | variable. |
| 492 | This area is a cache that can hold previously downloaded source. |
| 493 | You can also instruct the OpenEmbedded build system to create |
| 494 | tarballs from Git repositories, which is not the default behavior, |
| 495 | and store them in the <filename>DL_DIR</filename> by using the |
| 496 | <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link> |
| 497 | variable. |
| 498 | </para> |
| 499 | |
| 500 | <para> |
| 501 | Judicious use of a <filename>DL_DIR</filename> directory can |
| 502 | save the build system a trip across the Internet when looking |
| 503 | for files. |
| 504 | A good method for using a download directory is to have |
| 505 | <filename>DL_DIR</filename> point to an area outside of your |
| 506 | Build Directory. |
| 507 | Doing so allows you to safely delete the Build Directory |
| 508 | if needed without fear of removing any downloaded source file. |
| 509 | </para> |
| 510 | |
| 511 | <para> |
| 512 | The remainder of this section provides a deeper look into the |
| 513 | source files and the mirrors. |
| 514 | Here is a more detailed look at the source file area of the |
| 515 | base figure: |
| 516 | <imagedata fileref="figures/source-input.png" align="center" width="7in" depth="7.5in" /> |
| 517 | </para> |
| 518 | |
| 519 | <section id='upstream-project-releases'> |
| 520 | <title>Upstream Project Releases</title> |
| 521 | |
| 522 | <para> |
| 523 | Upstream project releases exist anywhere in the form of an |
| 524 | archived file (e.g. tarball or zip file). |
| 525 | These files correspond to individual recipes. |
| 526 | For example, the figure uses specific releases each for |
| 527 | BusyBox, Qt, and Dbus. |
| 528 | An archive file can be for any released product that can be |
| 529 | built using a recipe. |
| 530 | </para> |
| 531 | </section> |
| 532 | |
| 533 | <section id='local-projects'> |
| 534 | <title>Local Projects</title> |
| 535 | |
| 536 | <para> |
| 537 | Local projects are custom bits of software the user provides. |
| 538 | These bits reside somewhere local to a project - perhaps |
| 539 | a directory into which the user checks in items (e.g. |
| 540 | a local directory containing a development source tree |
| 541 | used by the group). |
| 542 | </para> |
| 543 | |
| 544 | <para> |
| 545 | The canonical method through which to include a local project |
| 546 | is to use the |
| 547 | <link linkend='ref-classes-externalsrc'><filename>externalsrc</filename></link> |
| 548 | class to include that local project. |
| 549 | You use either the <filename>local.conf</filename> or a |
| 550 | recipe's append file to override or set the |
| 551 | recipe to point to the local directory on your disk to pull |
| 552 | in the whole source tree. |
| 553 | </para> |
| 554 | |
| 555 | <para> |
| 556 | For information on how to use the |
| 557 | <filename>externalsrc</filename> class, see the |
| 558 | "<link linkend='ref-classes-externalsrc'><filename>externalsrc.bbclass</filename></link>" |
| 559 | section. |
| 560 | </para> |
| 561 | </section> |
| 562 | |
| 563 | <section id='scms'> |
| 564 | <title>Source Control Managers (Optional)</title> |
| 565 | |
| 566 | <para> |
| 567 | Another place the build system can get source files from is |
| 568 | through an SCM such as Git or Subversion. |
| 569 | In this case, a repository is cloned or checked out. |
| 570 | The |
| 571 | <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link> |
| 572 | task inside BitBake uses |
| 573 | the <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 574 | variable and the argument's prefix to determine the correct |
| 575 | fetcher module. |
| 576 | </para> |
| 577 | |
| 578 | <note> |
| 579 | For information on how to have the OpenEmbedded build system |
| 580 | generate tarballs for Git repositories and place them in the |
| 581 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 582 | directory, see the |
| 583 | <link linkend='var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></link> |
| 584 | variable. |
| 585 | </note> |
| 586 | |
| 587 | <para> |
| 588 | When fetching a repository, BitBake uses the |
| 589 | <link linkend='var-SRCREV'><filename>SRCREV</filename></link> |
| 590 | variable to determine the specific revision from which to |
| 591 | build. |
| 592 | </para> |
| 593 | </section> |
| 594 | |
| 595 | <section id='source-mirrors'> |
| 596 | <title>Source Mirror(s)</title> |
| 597 | |
| 598 | <para> |
| 599 | Two kinds of mirrors exist: pre-mirrors and regular mirrors. |
| 600 | The <link linkend='var-PREMIRRORS'><filename>PREMIRRORS</filename></link> |
| 601 | and |
| 602 | <link linkend='var-MIRRORS'><filename>MIRRORS</filename></link> |
| 603 | variables point to these, respectively. |
| 604 | BitBake checks pre-mirrors before looking upstream for any |
| 605 | source files. |
| 606 | Pre-mirrors are appropriate when you have a shared directory |
| 607 | that is not a directory defined by the |
| 608 | <link linkend='var-DL_DIR'><filename>DL_DIR</filename></link> |
| 609 | variable. |
| 610 | A Pre-mirror typically points to a shared directory that is |
| 611 | local to your organization. |
| 612 | </para> |
| 613 | |
| 614 | <para> |
| 615 | Regular mirrors can be any site across the Internet that is |
| 616 | used as an alternative location for source code should the |
| 617 | primary site not be functioning for some reason or another. |
| 618 | </para> |
| 619 | </section> |
| 620 | </section> |
| 621 | |
| 622 | <section id="package-feeds-dev-environment"> |
| 623 | <title>Package Feeds</title> |
| 624 | |
| 625 | <para> |
| 626 | When the OpenEmbedded build system generates an image or an SDK, |
| 627 | it gets the packages from a package feed area located in the |
| 628 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>. |
| 629 | The |
| 630 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 631 | shows this package feeds area in the upper-right corner. |
| 632 | </para> |
| 633 | |
| 634 | <para> |
| 635 | This section looks a little closer into the package feeds area used |
| 636 | by the build system. |
| 637 | Here is a more detailed look at the area: |
| 638 | <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" /> |
| 639 | </para> |
| 640 | |
| 641 | <para> |
| 642 | Package feeds are an intermediary step in the build process. |
| 643 | The OpenEmbedded build system provides classes to generate |
| 644 | different package types, and you specify which classes to enable |
| 645 | through the |
| 646 | <link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link> |
| 647 | variable. |
| 648 | Before placing the packages into package feeds, |
| 649 | the build process validates them with generated output quality |
| 650 | assurance checks through the |
| 651 | <link linkend='ref-classes-insane'><filename>insane</filename></link> |
| 652 | class. |
| 653 | </para> |
| 654 | |
| 655 | <para> |
| 656 | The package feed area resides in the Build Directory. |
| 657 | The directory the build system uses to temporarily store packages |
| 658 | is determined by a combination of variables and the particular |
| 659 | package manager in use. |
| 660 | See the "Package Feeds" box in the illustration and note the |
| 661 | information to the right of that area. |
| 662 | In particular, the following defines where package files are |
| 663 | kept: |
| 664 | <itemizedlist> |
| 665 | <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>: |
| 666 | Defined as <filename>tmp/deploy</filename> in the Build |
| 667 | Directory. |
| 668 | </para></listitem> |
| 669 | <listitem><para><filename>DEPLOY_DIR_*</filename>: |
| 670 | Depending on the package manager used, the package type |
| 671 | sub-folder. |
| 672 | Given RPM, IPK, or DEB packaging and tarball creation, the |
| 673 | <link linkend='var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></link>, |
| 674 | <link linkend='var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></link>, |
| 675 | <link linkend='var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></link>, |
| 676 | or |
| 677 | <link linkend='var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></link>, |
| 678 | variables are used, respectively. |
| 679 | </para></listitem> |
| 680 | <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link>: |
| 681 | Defines architecture-specific sub-folders. |
| 682 | For example, packages could exist for the i586 or qemux86 |
| 683 | architectures. |
| 684 | </para></listitem> |
| 685 | </itemizedlist> |
| 686 | </para> |
| 687 | |
| 688 | <para> |
| 689 | BitBake uses the <filename>do_package_write_*</filename> tasks to |
| 690 | generate packages and place them into the package holding area (e.g. |
| 691 | <filename>do_package_write_ipk</filename> for IPK packages). |
| 692 | See the |
| 693 | "<link linkend='ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></link>", |
| 694 | "<link linkend='ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></link>", |
| 695 | "<link linkend='ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></link>", |
| 696 | and |
| 697 | "<link linkend='ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></link>" |
| 698 | sections for additional information. |
| 699 | As an example, consider a scenario where an IPK packaging manager |
| 700 | is being used and package architecture support for both i586 |
| 701 | and qemux86 exist. |
| 702 | Packages for the i586 architecture are placed in |
| 703 | <filename>build/tmp/deploy/ipk/i586</filename>, while packages for |
| 704 | the qemux86 architecture are placed in |
| 705 | <filename>build/tmp/deploy/ipk/qemux86</filename>. |
| 706 | </para> |
| 707 | </section> |
| 708 | |
| 709 | <section id='bitbake-dev-environment'> |
| 710 | <title>BitBake</title> |
| 711 | |
| 712 | <para> |
| 713 | The OpenEmbedded build system uses |
| 714 | <ulink url='&YOCTO_DOCS_DEV_URL;#bitbake-term'>BitBake</ulink> |
| 715 | to produce images. |
| 716 | You can see from the |
| 717 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, |
| 718 | the BitBake area consists of several functional areas. |
| 719 | This section takes a closer look at each of those areas. |
| 720 | </para> |
| 721 | |
| 722 | <para> |
| 723 | Separate documentation exists for the BitBake tool. |
| 724 | See the |
| 725 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink> |
| 726 | for reference material on BitBake. |
| 727 | </para> |
| 728 | |
| 729 | <section id='source-fetching-dev-environment'> |
| 730 | <title>Source Fetching</title> |
| 731 | |
| 732 | <para> |
| 733 | The first stages of building a recipe are to fetch and unpack |
| 734 | the source code: |
| 735 | <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" /> |
| 736 | </para> |
| 737 | |
| 738 | <para> |
| 739 | The |
| 740 | <link linkend='ref-tasks-fetch'><filename>do_fetch</filename></link> |
| 741 | and |
| 742 | <link linkend='ref-tasks-unpack'><filename>do_unpack</filename></link> |
| 743 | tasks fetch the source files and unpack them into the work |
| 744 | directory. |
| 745 | <note> |
| 746 | For every local file (e.g. <filename>file://</filename>) |
| 747 | that is part of a recipe's |
| 748 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 749 | statement, the OpenEmbedded build system takes a checksum |
| 750 | of the file for the recipe and inserts the checksum into |
| 751 | the signature for the <filename>do_fetch</filename>. |
| 752 | If any local file has been modified, the |
| 753 | <filename>do_fetch</filename> task and all tasks that |
| 754 | depend on it are re-executed. |
| 755 | </note> |
| 756 | By default, everything is accomplished in the |
| 757 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink>, |
| 758 | which has a defined structure. |
| 759 | For additional general information on the Build Directory, |
| 760 | see the |
| 761 | "<link linkend='structure-core-build'><filename>build/</filename></link>" |
| 762 | section. |
| 763 | </para> |
| 764 | |
| 765 | <para> |
| 766 | Unpacked source files are pointed to by the |
| 767 | <link linkend='var-S'><filename>S</filename></link> variable. |
| 768 | Each recipe has an area in the Build Directory where the |
| 769 | unpacked source code resides. |
| 770 | The name of that directory for any given recipe is defined from |
| 771 | several different variables. |
| 772 | You can see the variables that define these directories |
| 773 | by looking at the figure: |
| 774 | <itemizedlist> |
| 775 | <listitem><para><link linkend='var-TMPDIR'><filename>TMPDIR</filename></link> - |
| 776 | The base directory where the OpenEmbedded build system |
| 777 | performs all its work during the build. |
| 778 | </para></listitem> |
| 779 | <listitem><para><link linkend='var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></link> - |
| 780 | The architecture of the built package or packages. |
| 781 | </para></listitem> |
| 782 | <listitem><para><link linkend='var-TARGET_OS'><filename>TARGET_OS</filename></link> - |
| 783 | The operating system of the target device. |
| 784 | </para></listitem> |
| 785 | <listitem><para><link linkend='var-PN'><filename>PN</filename></link> - |
| 786 | The name of the built package. |
| 787 | </para></listitem> |
| 788 | <listitem><para><link linkend='var-PV'><filename>PV</filename></link> - |
| 789 | The version of the recipe used to build the package. |
| 790 | </para></listitem> |
| 791 | <listitem><para><link linkend='var-PR'><filename>PR</filename></link> - |
| 792 | The revision of the recipe used to build the package. |
| 793 | </para></listitem> |
| 794 | <listitem><para><link linkend='var-WORKDIR'><filename>WORKDIR</filename></link> - |
| 795 | The location within <filename>TMPDIR</filename> where |
| 796 | a specific package is built. |
| 797 | </para></listitem> |
| 798 | <listitem><para><link linkend='var-S'><filename>S</filename></link> - |
| 799 | Contains the unpacked source files for a given recipe. |
| 800 | </para></listitem> |
| 801 | </itemizedlist> |
| 802 | </para> |
| 803 | </section> |
| 804 | |
| 805 | <section id='patching-dev-environment'> |
| 806 | <title>Patching</title> |
| 807 | |
| 808 | <para> |
| 809 | Once source code is fetched and unpacked, BitBake locates |
| 810 | patch files and applies them to the source files: |
| 811 | <imagedata fileref="figures/patching.png" align="center" width="6in" depth="5in" /> |
| 812 | </para> |
| 813 | |
| 814 | <para> |
| 815 | The |
| 816 | <link linkend='ref-tasks-patch'><filename>do_patch</filename></link> |
| 817 | task processes recipes by |
| 818 | using the |
| 819 | <link linkend='var-SRC_URI'><filename>SRC_URI</filename></link> |
| 820 | variable to locate applicable patch files, which by default |
| 821 | are <filename>*.patch</filename> or |
| 822 | <filename>*.diff</filename> files, or any file if |
| 823 | "apply=yes" is specified for the file in |
| 824 | <filename>SRC_URI</filename>. |
| 825 | </para> |
| 826 | |
| 827 | <para> |
| 828 | BitBake finds and applies multiple patches for a single recipe |
| 829 | in the order in which it finds the patches. |
| 830 | Patches are applied to the recipe's source files located in the |
| 831 | <link linkend='var-S'><filename>S</filename></link> directory. |
| 832 | </para> |
| 833 | |
| 834 | <para> |
| 835 | For more information on how the source directories are |
| 836 | created, see the |
| 837 | "<link linkend='source-fetching-dev-environment'>Source Fetching</link>" |
| 838 | section. |
| 839 | </para> |
| 840 | </section> |
| 841 | |
| 842 | <section id='configuration-and-compilation-dev-environment'> |
| 843 | <title>Configuration and Compilation</title> |
| 844 | |
| 845 | <para> |
| 846 | After source code is patched, BitBake executes tasks that |
| 847 | configure and compile the source code: |
| 848 | <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" /> |
| 849 | </para> |
| 850 | |
| 851 | <para> |
| 852 | This step in the build process consists of three tasks: |
| 853 | <itemizedlist> |
| 854 | <listitem><para><emphasis><filename>do_configure</filename>:</emphasis> |
| 855 | This task configures the source by enabling and |
| 856 | disabling any build-time and configuration options for |
| 857 | the software being built. |
| 858 | Configurations can come from the recipe itself as well |
| 859 | as from an inherited class. |
| 860 | Additionally, the software itself might configure itself |
| 861 | depending on the target for which it is being built. |
| 862 | </para> |
| 863 | |
| 864 | <para>The configurations handled by the |
| 865 | <link linkend='ref-tasks-configure'><filename>do_configure</filename></link> |
| 866 | task are specific |
| 867 | to source code configuration for the source code |
| 868 | being built by the recipe.</para> |
| 869 | |
| 870 | <para>If you are using the |
| 871 | <link linkend='ref-classes-autotools'><filename>autotools</filename></link> |
| 872 | class, |
| 873 | you can add additional configuration options by using |
| 874 | the <link linkend='var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></link> |
| 875 | variable. |
| 876 | For information on how this variable works within |
| 877 | that class, see the |
| 878 | <filename>meta/classes/autotools.bbclass</filename> file. |
| 879 | </para></listitem> |
| 880 | <listitem><para><emphasis><filename>do_compile</filename>:</emphasis> |
| 881 | Once a configuration task has been satisfied, BitBake |
| 882 | compiles the source using the |
| 883 | <link linkend='ref-tasks-compile'><filename>do_compile</filename></link> |
| 884 | task. |
| 885 | Compilation occurs in the directory pointed to by the |
| 886 | <link linkend='var-B'><filename>B</filename></link> |
| 887 | variable. |
| 888 | Realize that the <filename>B</filename> directory is, by |
| 889 | default, the same as the |
| 890 | <link linkend='var-S'><filename>S</filename></link> |
| 891 | directory.</para></listitem> |
| 892 | <listitem><para><emphasis><filename>do_install</filename>:</emphasis> |
| 893 | Once compilation is done, BitBake executes the |
| 894 | <link linkend='ref-tasks-install'><filename>do_install</filename></link> |
| 895 | task. |
| 896 | This task copies files from the <filename>B</filename> |
| 897 | directory and places them in a holding area pointed to |
| 898 | by the |
| 899 | <link linkend='var-D'><filename>D</filename></link> |
| 900 | variable.</para></listitem> |
| 901 | </itemizedlist> |
| 902 | </para> |
| 903 | </section> |
| 904 | |
| 905 | <section id='package-splitting-dev-environment'> |
| 906 | <title>Package Splitting</title> |
| 907 | |
| 908 | <para> |
| 909 | After source code is configured and compiled, the |
| 910 | OpenEmbedded build system analyzes |
| 911 | the results and splits the output into packages: |
| 912 | <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" /> |
| 913 | </para> |
| 914 | |
| 915 | <para> |
| 916 | The |
| 917 | <link linkend='ref-tasks-package'><filename>do_package</filename></link> |
| 918 | and |
| 919 | <link linkend='ref-tasks-packagedata'><filename>do_packagedata</filename></link> |
| 920 | tasks combine to analyze |
| 921 | the files found in the |
| 922 | <link linkend='var-D'><filename>D</filename></link> directory |
| 923 | and split them into subsets based on available packages and |
| 924 | files. |
| 925 | The analyzing process involves the following as well as other |
| 926 | items: splitting out debugging symbols, |
| 927 | looking at shared library dependencies between packages, |
| 928 | and looking at package relationships. |
| 929 | The <filename>do_packagedata</filename> task creates package |
| 930 | metadata based on the analysis such that the |
| 931 | OpenEmbedded build system can generate the final packages. |
| 932 | Working, staged, and intermediate results of the analysis |
| 933 | and package splitting process use these areas: |
| 934 | <itemizedlist> |
| 935 | <listitem><para><link linkend='var-PKGD'><filename>PKGD</filename></link> - |
| 936 | The destination directory for packages before they are |
| 937 | split. |
| 938 | </para></listitem> |
| 939 | <listitem><para><link linkend='var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></link> - |
| 940 | A shared, global-state directory that holds data |
| 941 | generated during the packaging process. |
| 942 | </para></listitem> |
| 943 | <listitem><para><link linkend='var-PKGDESTWORK'><filename>PKGDESTWORK</filename></link> - |
| 944 | A temporary work area used by the |
| 945 | <filename>do_package</filename> task. |
| 946 | </para></listitem> |
| 947 | <listitem><para><link linkend='var-PKGDEST'><filename>PKGDEST</filename></link> - |
| 948 | The parent directory for packages after they have |
| 949 | been split. |
| 950 | </para></listitem> |
| 951 | </itemizedlist> |
| 952 | The <link linkend='var-FILES'><filename>FILES</filename></link> |
| 953 | variable defines the files that go into each package in |
| 954 | <link linkend='var-PACKAGES'><filename>PACKAGES</filename></link>. |
| 955 | If you want details on how this is accomplished, you can |
| 956 | look at the |
| 957 | <link linkend='ref-classes-package'><filename>package</filename></link> |
| 958 | class. |
| 959 | </para> |
| 960 | |
| 961 | <para> |
| 962 | Depending on the type of packages being created (RPM, DEB, or |
| 963 | IPK), the <filename>do_package_write_*</filename> task |
| 964 | creates the actual packages and places them in the |
| 965 | Package Feed area, which is |
| 966 | <filename>${TMPDIR}/deploy</filename>. |
| 967 | You can see the |
| 968 | "<link linkend='package-feeds-dev-environment'>Package Feeds</link>" |
| 969 | section for more detail on that part of the build process. |
| 970 | <note> |
| 971 | Support for creating feeds directly from the |
| 972 | <filename>deploy/*</filename> directories does not exist. |
| 973 | Creating such feeds usually requires some kind of feed |
| 974 | maintenance mechanism that would upload the new packages |
| 975 | into an official package feed (e.g. the |
| 976 | Ångström distribution). |
| 977 | This functionality is highly distribution-specific |
| 978 | and thus is not provided out of the box. |
| 979 | </note> |
| 980 | </para> |
| 981 | </section> |
| 982 | |
| 983 | <section id='image-generation-dev-environment'> |
| 984 | <title>Image Generation</title> |
| 985 | |
| 986 | <para> |
| 987 | Once packages are split and stored in the Package Feeds area, |
| 988 | the OpenEmbedded build system uses BitBake to generate the |
| 989 | root filesystem image: |
| 990 | <imagedata fileref="figures/image-generation.png" align="center" width="6in" depth="7in" /> |
| 991 | </para> |
| 992 | |
| 993 | <para> |
| 994 | The image generation process consists of several stages and |
| 995 | depends on many variables. |
| 996 | The |
| 997 | <link linkend='ref-tasks-rootfs'><filename>do_rootfs</filename></link> |
| 998 | task uses these key variables |
| 999 | to help create the list of packages to actually install: |
| 1000 | <itemizedlist> |
| 1001 | <listitem><para><link linkend='var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></link>: |
| 1002 | Lists out the base set of packages to install from |
| 1003 | the Package Feeds area.</para></listitem> |
| 1004 | <listitem><para><link linkend='var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></link>: |
| 1005 | Specifies packages that should not be installed. |
| 1006 | </para></listitem> |
| 1007 | <listitem><para><link linkend='var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></link>: |
| 1008 | Specifies features to include in the image. |
| 1009 | Most of these features map to additional packages for |
| 1010 | installation.</para></listitem> |
| 1011 | <listitem><para><link linkend='var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></link>: |
| 1012 | Specifies the package backend to use and consequently |
| 1013 | helps determine where to locate packages within the |
| 1014 | Package Feeds area.</para></listitem> |
| 1015 | <listitem><para><link linkend='var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></link>: |
| 1016 | Determines the language(s) for which additional |
| 1017 | language support packages are installed. |
| 1018 | </para></listitem> |
| 1019 | </itemizedlist> |
| 1020 | </para> |
| 1021 | |
| 1022 | <para> |
| 1023 | Package installation is under control of the package manager |
| 1024 | (e.g. smart/rpm, opkg, or apt/dpkg) regardless of whether or |
| 1025 | not package management is enabled for the target. |
| 1026 | At the end of the process, if package management is not |
| 1027 | enabled for the target, the package manager's data files |
| 1028 | are deleted from the root filesystem. |
| 1029 | </para> |
| 1030 | |
| 1031 | <para> |
| 1032 | During image generation, the build system attempts to run |
| 1033 | all post-installation scripts. |
| 1034 | Any that fail to run on the build host are run on the |
| 1035 | target when the target system is first booted. |
| 1036 | If you are using a |
| 1037 | <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>, |
| 1038 | all the post installation scripts must succeed during the |
| 1039 | package installation phase since the root filesystem is |
| 1040 | read-only. |
| 1041 | </para> |
| 1042 | |
| 1043 | <para> |
| 1044 | During Optimization, optimizing processes are run across |
| 1045 | the image. |
| 1046 | These processes include <filename>mklibs</filename> and |
| 1047 | <filename>prelink</filename>. |
| 1048 | The <filename>mklibs</filename> process optimizes the size |
| 1049 | of the libraries. |
| 1050 | A <filename>prelink</filename> process optimizes the dynamic |
| 1051 | linking of shared libraries to reduce start up time of |
| 1052 | executables. |
| 1053 | </para> |
| 1054 | |
| 1055 | <para> |
| 1056 | Along with writing out the root filesystem image, the |
| 1057 | <filename>do_rootfs</filename> task creates a manifest file |
| 1058 | (<filename>.manifest</filename>) in the same directory as |
| 1059 | the root filesystem image that lists out, line-by-line, the |
| 1060 | installed packages. |
| 1061 | This manifest file is useful for the |
| 1062 | <link linkend='ref-classes-testimage'><filename>testimage</filename></link> |
| 1063 | class, for example, to determine whether or not to run |
| 1064 | specific tests. |
| 1065 | See the |
| 1066 | <link linkend='var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></link> |
| 1067 | variable for additional information. |
| 1068 | </para> |
| 1069 | |
| 1070 | <para> |
| 1071 | Part of the image generation process includes compressing the |
| 1072 | root filesystem image. |
| 1073 | Compression is accomplished through several optimization |
| 1074 | routines designed to reduce the overall size of the image. |
| 1075 | </para> |
| 1076 | |
| 1077 | <para> |
| 1078 | After the root filesystem has been constructed, the image |
| 1079 | generation process turns everything into an image file or |
| 1080 | a set of image files. |
| 1081 | The formats used for the root filesystem depend on the |
| 1082 | <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link> |
| 1083 | variable. |
| 1084 | </para> |
| 1085 | |
| 1086 | <note> |
| 1087 | The entire image generation process is run under Pseudo. |
| 1088 | Running under Pseudo ensures that the files in the root |
| 1089 | filesystem have correct ownership. |
| 1090 | </note> |
| 1091 | </section> |
| 1092 | |
| 1093 | <section id='sdk-generation-dev-environment'> |
| 1094 | <title>SDK Generation</title> |
| 1095 | |
| 1096 | <para> |
| 1097 | The OpenEmbedded build system uses BitBake to generate the |
| 1098 | Software Development Kit (SDK) installer script: |
| 1099 | <imagedata fileref="figures/sdk-generation.png" align="center" width="6in" depth="7in" /> |
| 1100 | </para> |
| 1101 | |
| 1102 | <note> |
| 1103 | For more information on the cross-development toolchain |
| 1104 | generation, see the |
| 1105 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" |
| 1106 | section. |
| 1107 | For information on advantages gained when building a |
| 1108 | cross-development toolchain using the |
| 1109 | <link linkend='ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></link> |
| 1110 | task, see the |
| 1111 | "<ulink url='&YOCTO_DOCS_ADT_URL;#optionally-building-a-toolchain-installer'>Optionally Building a Toolchain Installer</ulink>" |
| 1112 | section in the Yocto Project Application Developer's Guide. |
| 1113 | </note> |
| 1114 | |
| 1115 | <para> |
| 1116 | Like image generation, the SDK script process consists of |
| 1117 | several stages and depends on many variables. |
| 1118 | The <filename>do_populate_sdk</filename> task uses these |
| 1119 | key variables to help create the list of packages to actually |
| 1120 | install. |
| 1121 | For information on the variables listed in the figure, see the |
| 1122 | "<link linkend='sdk-dev-environment'>Application Development SDK</link>" |
| 1123 | section. |
| 1124 | </para> |
| 1125 | |
| 1126 | <para> |
| 1127 | The <filename>do_populate_sdk</filename> task handles two |
| 1128 | parts: a target part and a host part. |
| 1129 | The target part is the part built for the target hardware and |
| 1130 | includes libraries and headers. |
| 1131 | The host part is the part of the SDK that runs on the |
| 1132 | <link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>. |
| 1133 | </para> |
| 1134 | |
| 1135 | <para> |
| 1136 | Once both parts are constructed, the |
| 1137 | <filename>do_populate_sdk</filename> task performs some cleanup |
| 1138 | on both parts. |
| 1139 | After the cleanup, the task creates a cross-development |
| 1140 | environment setup script and any configuration files that |
| 1141 | might be needed. |
| 1142 | </para> |
| 1143 | |
| 1144 | <para> |
| 1145 | The final output of the task is the Cross-development |
| 1146 | toolchain installation script (<filename>.sh</filename> file), |
| 1147 | which includes the environment setup script. |
| 1148 | </para> |
| 1149 | </section> |
| 1150 | </section> |
| 1151 | |
| 1152 | <section id='images-dev-environment'> |
| 1153 | <title>Images</title> |
| 1154 | |
| 1155 | <para> |
| 1156 | The images produced by the OpenEmbedded build system |
| 1157 | are compressed forms of the |
| 1158 | root filesystem that are ready to boot on a target device. |
| 1159 | You can see from the |
| 1160 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> |
| 1161 | that BitBake output, in part, consists of images. |
| 1162 | This section is going to look more closely at this output: |
| 1163 | <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" /> |
| 1164 | </para> |
| 1165 | |
| 1166 | <para> |
| 1167 | For a list of example images that the Yocto Project provides, |
| 1168 | see the |
| 1169 | "<link linkend='ref-images'>Images</link>" chapter. |
| 1170 | </para> |
| 1171 | |
| 1172 | <para> |
| 1173 | Images are written out to the |
| 1174 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 1175 | inside the <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename> |
| 1176 | folder as shown in the figure. |
| 1177 | This folder contains any files expected to be loaded on the |
| 1178 | target device. |
| 1179 | The |
| 1180 | <link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link> |
| 1181 | variable points to the <filename>deploy</filename> directory, |
| 1182 | while the |
| 1183 | <link linkend='var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></link> |
| 1184 | variable points to the appropriate directory containing images for |
| 1185 | the current configuration. |
| 1186 | <itemizedlist> |
| 1187 | <listitem><para><filename><replaceable>kernel-image</replaceable></filename>: |
| 1188 | A kernel binary file. |
| 1189 | The <link linkend='var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></link> |
| 1190 | variable setting determines the naming scheme for the |
| 1191 | kernel image file. |
| 1192 | Depending on that variable, the file could begin with |
| 1193 | a variety of naming strings. |
| 1194 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1195 | directory can contain multiple image files for the |
| 1196 | machine.</para></listitem> |
| 1197 | <listitem><para><filename><replaceable>root-filesystem-image</replaceable></filename>: |
| 1198 | Root filesystems for the target device (e.g. |
| 1199 | <filename>*.ext3</filename> or <filename>*.bz2</filename> |
| 1200 | files). |
| 1201 | The <link linkend='var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></link> |
| 1202 | variable setting determines the root filesystem image |
| 1203 | type. |
| 1204 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1205 | directory can contain multiple root filesystems for the |
| 1206 | machine.</para></listitem> |
| 1207 | <listitem><para><filename><replaceable>kernel-modules</replaceable></filename>: |
| 1208 | Tarballs that contain all the modules built for the kernel. |
| 1209 | Kernel module tarballs exist for legacy purposes and |
| 1210 | can be suppressed by setting the |
| 1211 | <link linkend='var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></link> |
| 1212 | variable to "0". |
| 1213 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1214 | directory can contain multiple kernel module tarballs |
| 1215 | for the machine.</para></listitem> |
| 1216 | <listitem><para><filename><replaceable>bootloaders</replaceable></filename>: |
| 1217 | Bootloaders supporting the image, if applicable to the |
| 1218 | target machine. |
| 1219 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1220 | directory can contain multiple bootloaders for the |
| 1221 | machine.</para></listitem> |
| 1222 | <listitem><para><filename><replaceable>symlinks</replaceable></filename>: |
| 1223 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> |
| 1224 | folder contains |
| 1225 | a symbolic link that points to the most recently built file |
| 1226 | for each machine. |
| 1227 | These links might be useful for external scripts that |
| 1228 | need to obtain the latest version of each file. |
| 1229 | </para></listitem> |
| 1230 | </itemizedlist> |
| 1231 | </para> |
| 1232 | </section> |
| 1233 | |
| 1234 | <section id='sdk-dev-environment'> |
| 1235 | <title>Application Development SDK</title> |
| 1236 | |
| 1237 | <para> |
| 1238 | In the |
| 1239 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, |
| 1240 | the output labeled "Application Development SDK" represents an |
| 1241 | SDK. |
| 1242 | This section is going to take a closer look at this output: |
| 1243 | <imagedata fileref="figures/sdk.png" align="center" width="5in" depth="4in" /> |
| 1244 | </para> |
| 1245 | |
| 1246 | <para> |
| 1247 | The specific form of this output is a self-extracting |
| 1248 | SDK installer (<filename>*.sh</filename>) that, when run, |
| 1249 | installs the SDK, which consists of a cross-development |
| 1250 | toolchain, a set of libraries and headers, and an SDK |
| 1251 | environment setup script. |
| 1252 | Running this installer essentially sets up your |
| 1253 | cross-development environment. |
| 1254 | You can think of the cross-toolchain as the "host" |
| 1255 | part because it runs on the SDK machine. |
| 1256 | You can think of the libraries and headers as the "target" |
| 1257 | part because they are built for the target hardware. |
| 1258 | The setup script is added so that you can initialize the |
| 1259 | environment before using the tools. |
| 1260 | </para> |
| 1261 | |
| 1262 | <note> |
| 1263 | <para> |
| 1264 | The Yocto Project supports several methods by which you can |
| 1265 | set up this cross-development environment. |
| 1266 | These methods include downloading pre-built SDK installers, |
| 1267 | building and installing your own SDK installer, or running |
| 1268 | an Application Development Toolkit (ADT) installer to |
| 1269 | install not just cross-development toolchains |
| 1270 | but also additional tools to help in this type of |
| 1271 | development. |
| 1272 | </para> |
| 1273 | |
| 1274 | <para> |
| 1275 | For background information on cross-development toolchains |
| 1276 | in the Yocto Project development environment, see the |
| 1277 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" |
| 1278 | section. |
| 1279 | For information on setting up a cross-development |
| 1280 | environment, see the |
| 1281 | "<ulink url='&YOCTO_DOCS_ADT_URL;#installing-the-adt'>Installing the ADT and Toolchains</ulink>" |
| 1282 | section in the Yocto Project Application Developer's Guide. |
| 1283 | </para> |
| 1284 | </note> |
| 1285 | |
| 1286 | <para> |
| 1287 | Once built, the SDK installers are written out to the |
| 1288 | <filename>deploy/sdk</filename> folder inside the |
| 1289 | <ulink url='&YOCTO_DOCS_DEV_URL;#build-directory'>Build Directory</ulink> |
| 1290 | as shown in the figure at the beginning of this section. |
| 1291 | Several variables exist that help configure these files: |
| 1292 | <itemizedlist> |
| 1293 | <listitem><para><link linkend='var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></link>: |
| 1294 | Points to the <filename>deploy</filename> |
| 1295 | directory.</para></listitem> |
| 1296 | <listitem><para><link linkend='var-SDKMACHINE'><filename>SDKMACHINE</filename></link>: |
| 1297 | Specifies the architecture of the machine |
| 1298 | on which the cross-development tools are run to |
| 1299 | create packages for the target hardware. |
| 1300 | </para></listitem> |
| 1301 | <listitem><para><link linkend='var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></link>: |
| 1302 | Lists the features to include in the "target" part |
| 1303 | of the SDK. |
| 1304 | </para></listitem> |
| 1305 | <listitem><para><link linkend='var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></link>: |
| 1306 | Lists packages that make up the host |
| 1307 | part of the SDK (i.e. the part that runs on |
| 1308 | the <filename>SDKMACHINE</filename>). |
| 1309 | When you use |
| 1310 | <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename> |
| 1311 | to create the SDK, a set of default packages |
| 1312 | apply. |
| 1313 | This variable allows you to add more packages. |
| 1314 | </para></listitem> |
| 1315 | <listitem><para><link linkend='var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></link>: |
| 1316 | Lists packages that make up the target part |
| 1317 | of the SDK (i.e. the part built for the |
| 1318 | target hardware). |
| 1319 | </para></listitem> |
| 1320 | <listitem><para><link linkend='var-SDKPATH'><filename>SDKPATH</filename></link>: |
| 1321 | Defines the default SDK installation path offered by the |
| 1322 | installation script. |
| 1323 | </para></listitem> |
| 1324 | </itemizedlist> |
| 1325 | </para> |
| 1326 | </section> |
| 1327 | |
| 1328 | </chapter> |
| 1329 | <!-- |
| 1330 | vim: expandtab tw=80 ts=4 |
| 1331 | --> |