diff options
Diffstat (limited to 'documentation/getting-started/getting-started-development-environment.xml')
| -rw-r--r-- | documentation/getting-started/getting-started-development-environment.xml | 2890 |
1 files changed, 2890 insertions, 0 deletions
diff --git a/documentation/getting-started/getting-started-development-environment.xml b/documentation/getting-started/getting-started-development-environment.xml new file mode 100644 index 0000000000..7d177cecca --- /dev/null +++ b/documentation/getting-started/getting-started-development-environment.xml | |||
| @@ -0,0 +1,2890 @@ | |||
| 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='overview-development-environment'> | ||
| 6 | <title>The Yocto Project Development Environment</title> | ||
| 7 | |||
| 8 | <para> | ||
| 9 | This chapter takes a look at the Yocto Project development | ||
| 10 | environment and also provides a detailed look at what goes on during | ||
| 11 | development in that environment. | ||
| 12 | The chapter provides Yocto Project Development environment concepts that | ||
| 13 | help you understand how work is accomplished in an open source environment, | ||
| 14 | which is very different as compared to work accomplished in a closed, | ||
| 15 | proprietary environment. | ||
| 16 | </para> | ||
| 17 | |||
| 18 | <para> | ||
| 19 | Specifically, this chapter addresses open source philosophy, workflows, | ||
| 20 | Git, source repositories, licensing, recipe syntax, and development | ||
| 21 | syntax. | ||
| 22 | </para> | ||
| 23 | |||
| 24 | <section id='yp-intro'> | ||
| 25 | <title>Introduction</title> | ||
| 26 | |||
| 27 | <para> | ||
| 28 | The Yocto Project is an open-source collaboration project whose | ||
| 29 | focus is for developers of embedded Linux systems. | ||
| 30 | Among other things, the Yocto Project uses an | ||
| 31 | <ulink url='&YOCTO_DOCS_REF_URL;#build-system-term'>OpenEmbedded build system</ulink>. | ||
| 32 | The build system, which is based on the OpenEmbedded (OE) project and | ||
| 33 | uses the | ||
| 34 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> tool, | ||
| 35 | constructs complete Linux images for architectures based on ARM, MIPS, | ||
| 36 | PowerPC, x86 and x86-64. | ||
| 37 | <note> | ||
| 38 | Historically, the OpenEmbedded build system, which is the | ||
| 39 | combination of BitBake and OE components, formed a reference | ||
| 40 | build host that was known as | ||
| 41 | "<ulink url='&YOCTO_DOCS_REF_URL;#poky'>Poky</ulink>" | ||
| 42 | (<emphasis>Pah</emphasis>-kee). | ||
| 43 | The term "Poky", as used throughout the Yocto Project Documentation | ||
| 44 | set, can have different meanings. | ||
| 45 | </note> | ||
| 46 | The Yocto Project provides various ancillary tools for the embedded | ||
| 47 | developer and also features the Sato reference User Interface, which | ||
| 48 | is optimized for stylus-driven, low-resolution screens. | ||
| 49 | </para> | ||
| 50 | |||
| 51 | <mediaobject> | ||
| 52 | <imageobject> | ||
| 53 | <imagedata fileref="figures/YP-flow-diagram.png" | ||
| 54 | format="PNG" align='center' width="8in"/> | ||
| 55 | </imageobject> | ||
| 56 | </mediaobject> | ||
| 57 | |||
| 58 | <para> | ||
| 59 | Here are some highlights for the Yocto Project: | ||
| 60 | </para> | ||
| 61 | |||
| 62 | <itemizedlist> | ||
| 63 | <listitem><para> | ||
| 64 | Provides a recent Linux kernel along with a set of system | ||
| 65 | commands and libraries suitable for the embedded | ||
| 66 | environment. | ||
| 67 | </para></listitem> | ||
| 68 | <listitem><para> | ||
| 69 | Makes available system components such as X11, GTK+, Qt, | ||
| 70 | Clutter, and SDL (among others) so you can create a rich user | ||
| 71 | experience on devices that have display hardware. | ||
| 72 | For devices that do not have a display or where you wish to | ||
| 73 | use alternative UI frameworks, these components need not be | ||
| 74 | installed. | ||
| 75 | </para></listitem> | ||
| 76 | <listitem><para> | ||
| 77 | Creates a focused and stable core compatible with the | ||
| 78 | OpenEmbedded project with which you can easily and reliably | ||
| 79 | build and develop. | ||
| 80 | </para></listitem> | ||
| 81 | <listitem><para> | ||
| 82 | Fully supports a wide range of hardware and device emulation | ||
| 83 | through the Quick EMUlator (QEMU). | ||
| 84 | </para></listitem> | ||
| 85 | <listitem><para> | ||
| 86 | Provides a layer mechanism that allows you to easily extend | ||
| 87 | the system, make customizations, and keep them organized. | ||
| 88 | </para></listitem> | ||
| 89 | </itemizedlist> | ||
| 90 | |||
| 91 | <para> | ||
| 92 | You can use the Yocto Project to generate images for many kinds | ||
| 93 | of devices. | ||
| 94 | As mentioned earlier, the Yocto Project supports creation of | ||
| 95 | reference images that you can boot within and emulate using QEMU. | ||
| 96 | The standard example machines target QEMU full-system | ||
| 97 | emulation for 32-bit and 64-bit variants of x86, ARM, MIPS, and | ||
| 98 | PowerPC architectures. | ||
| 99 | Beyond emulation, you can use the layer mechanism to extend | ||
| 100 | support to just about any platform that Linux can run on and that | ||
| 101 | a toolchain can target. | ||
| 102 | </para> | ||
| 103 | |||
| 104 | <para> | ||
| 105 | Another Yocto Project feature is the Sato reference User | ||
| 106 | Interface. | ||
| 107 | This optional UI that is based on GTK+ is intended for devices with | ||
| 108 | restricted screen sizes and is included as part of the | ||
| 109 | OpenEmbedded Core layer so that developers can test parts of the | ||
| 110 | software stack. | ||
| 111 | </para> | ||
| 112 | |||
| 113 | <para> | ||
| 114 | While the Yocto Project does not provide a strict testing framework, | ||
| 115 | it does provide or generate for you artifacts that let you perform | ||
| 116 | target-level and emulated testing and debugging. | ||
| 117 | Additionally, if you are an | ||
| 118 | <trademark class='trade'>Eclipse</trademark> IDE user, you can | ||
| 119 | install an Eclipse Yocto Plug-in to allow you to develop within that | ||
| 120 | familiar environment. | ||
| 121 | </para> | ||
| 122 | |||
| 123 | <para> | ||
| 124 | By default, using the Yocto Project to build an image creates a Poky | ||
| 125 | distribution. | ||
| 126 | However, you can create your own distribution by providing key | ||
| 127 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>. | ||
| 128 | A good example is Angstrom, which has had a distribution | ||
| 129 | based on the Yocto Project since its inception. | ||
| 130 | Other examples include commercial distributions like | ||
| 131 | <ulink url='https://www.yoctoproject.org/organization/wind-river-systems'>Wind River Linux</ulink>, | ||
| 132 | <ulink url='https://www.yoctoproject.org/organization/mentor-graphics'>Mentor Embedded Linux</ulink>, | ||
| 133 | <ulink url='https://www.yoctoproject.org/organization/enea-ab'>ENEA Linux</ulink> | ||
| 134 | and <ulink url='https://www.yoctoproject.org/ecosystem/member-organizations'>others</ulink>. | ||
| 135 | See the "<ulink url='&YOCTO_DOCS_DEV_URL;#creating-your-own-distribution'>Creating Your Own Distribution</ulink>" | ||
| 136 | section in the Yocto Project Development Tasks Manual for more | ||
| 137 | information. | ||
| 138 | </para> | ||
| 139 | </section> | ||
| 140 | |||
| 141 | <section id='open-source-philosophy'> | ||
| 142 | <title>Open Source Philosophy</title> | ||
| 143 | |||
| 144 | <para> | ||
| 145 | Open source philosophy is characterized by software development | ||
| 146 | directed by peer production and collaboration through an active | ||
| 147 | community of developers. | ||
| 148 | Contrast this to the more standard centralized development models | ||
| 149 | used by commercial software companies where a finite set of developers | ||
| 150 | produces a product for sale using a defined set of procedures that | ||
| 151 | ultimately result in an end product whose architecture and source | ||
| 152 | material are closed to the public. | ||
| 153 | </para> | ||
| 154 | |||
| 155 | <para> | ||
| 156 | Open source projects conceptually have differing concurrent agendas, | ||
| 157 | approaches, and production. | ||
| 158 | These facets of the development process can come from anyone in the | ||
| 159 | public (community) that has a stake in the software project. | ||
| 160 | The open source environment contains new copyright, licensing, domain, | ||
| 161 | and consumer issues that differ from the more traditional development | ||
| 162 | environment. | ||
| 163 | In an open source environment, the end product, source material, | ||
| 164 | and documentation are all available to the public at no cost. | ||
| 165 | </para> | ||
| 166 | |||
| 167 | <para> | ||
| 168 | A benchmark example of an open source project is the Linux kernel, | ||
| 169 | which was initially conceived and created by Finnish computer science | ||
| 170 | student Linus Torvalds in 1991. | ||
| 171 | Conversely, a good example of a non-open source project is the | ||
| 172 | <trademark class='registered'>Windows</trademark> family of operating | ||
| 173 | systems developed by | ||
| 174 | <trademark class='registered'>Microsoft</trademark> Corporation. | ||
| 175 | </para> | ||
| 176 | |||
| 177 | <para> | ||
| 178 | Wikipedia has a good historical description of the Open Source | ||
| 179 | Philosophy | ||
| 180 | <ulink url='http://en.wikipedia.org/wiki/Open_source'>here</ulink>. | ||
| 181 | You can also find helpful information on how to participate in the | ||
| 182 | Linux Community | ||
| 183 | <ulink url='http://ldn.linuxfoundation.org/book/how-participate-linux-community'>here</ulink>. | ||
| 184 | </para> | ||
| 185 | </section> | ||
| 186 | |||
| 187 | <section id='workflows'> | ||
| 188 | <title>Workflows</title> | ||
| 189 | |||
| 190 | <para> | ||
| 191 | This section provides workflow concepts using the Yocto Project and | ||
| 192 | Git. | ||
| 193 | In particular, the information covers basic practices that describe | ||
| 194 | roles and actions in a collaborative development environment. | ||
| 195 | <note> | ||
| 196 | If you are familiar with this type of development environment, you | ||
| 197 | might not want to read this section. | ||
| 198 | </note> | ||
| 199 | </para> | ||
| 200 | |||
| 201 | <para> | ||
| 202 | The Yocto Project files are maintained using Git in "master" | ||
| 203 | branches whose Git histories track every change and whose structures | ||
| 204 | provides branches for all diverging functionality. | ||
| 205 | Although there is no need to use Git, many open source projects do so. | ||
| 206 | <para> | ||
| 207 | |||
| 208 | </para> | ||
| 209 | For the Yocto Project, a key individual called the "maintainer" is | ||
| 210 | responsible for the "master" branch of a given Git repository. | ||
| 211 | The "master" branch is the “upstream” repository from which final or | ||
| 212 | most recent builds of the project occur. | ||
| 213 | The maintainer is responsible for accepting changes from other | ||
| 214 | developers and for organizing the underlying branch structure to | ||
| 215 | reflect release strategies and so forth. | ||
| 216 | <note>For information on finding out who is responsible for (maintains) | ||
| 217 | a particular area of code, see the | ||
| 218 | "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>" | ||
| 219 | section of the Yocto Project Development Tasks Manual. | ||
| 220 | </note> | ||
| 221 | </para> | ||
| 222 | |||
| 223 | <para> | ||
| 224 | The Yocto Project <filename>poky</filename> Git repository also has an | ||
| 225 | upstream contribution Git repository named | ||
| 226 | <filename>poky-contrib</filename>. | ||
| 227 | You can see all the branches in this repository using the web interface | ||
| 228 | of the | ||
| 229 | <ulink url='&YOCTO_GIT_URL;'>Source Repositories</ulink> organized | ||
| 230 | within the "Poky Support" area. | ||
| 231 | These branches temporarily hold changes to the project that have been | ||
| 232 | submitted or committed by the Yocto Project development team and by | ||
| 233 | community members who contribute to the project. | ||
| 234 | The maintainer determines if the changes are qualified to be moved | ||
| 235 | from the "contrib" branches into the "master" branch of the Git | ||
| 236 | repository. | ||
| 237 | </para> | ||
| 238 | |||
| 239 | <para> | ||
| 240 | Developers (including contributing community members) create and | ||
| 241 | maintain cloned repositories of the upstream "master" branch. | ||
| 242 | The cloned repositories are local to their development platforms and | ||
| 243 | are used to develop changes. | ||
| 244 | When a developer is satisfied with a particular feature or change, | ||
| 245 | they "push" the changes to the appropriate "contrib" repository. | ||
| 246 | </para> | ||
| 247 | |||
| 248 | <para> | ||
| 249 | Developers are responsible for keeping their local repository | ||
| 250 | up-to-date with "master". | ||
| 251 | They are also responsible for straightening out any conflicts that | ||
| 252 | might arise within files that are being worked on simultaneously by | ||
| 253 | more than one person. | ||
| 254 | All this work is done locally on the developer’s machine before | ||
| 255 | anything is pushed to a "contrib" area and examined at the maintainer’s | ||
| 256 | level. | ||
| 257 | </para> | ||
| 258 | |||
| 259 | <para> | ||
| 260 | A somewhat formal method exists by which developers commit changes | ||
| 261 | and push them into the "contrib" area and subsequently request that | ||
| 262 | the maintainer include them into "master". | ||
| 263 | This process is called “submitting a patch” or "submitting a change." | ||
| 264 | For information on submitting patches and changes, see the | ||
| 265 | "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>" | ||
| 266 | section in the Yocto Project Development Tasks Manual. | ||
| 267 | </para> | ||
| 268 | |||
| 269 | <para> | ||
| 270 | To summarize the development workflow: a single point of entry | ||
| 271 | exists for changes into the project’s "master" branch of the | ||
| 272 | Git repository, which is controlled by the project’s maintainer. | ||
| 273 | And, a set of developers exist who independently develop, test, and | ||
| 274 | submit changes to "contrib" areas for the maintainer to examine. | ||
| 275 | The maintainer then chooses which changes are going to become a | ||
| 276 | permanent part of the project. | ||
| 277 | </para> | ||
| 278 | |||
| 279 | <para> | ||
| 280 | <imagedata fileref="figures/git-workflow.png" width="6in" depth="3in" align="left" scalefit="1" /> | ||
| 281 | </para> | ||
| 282 | |||
| 283 | <para> | ||
| 284 | While each development environment is unique, there are some best | ||
| 285 | practices or methods that help development run smoothly. | ||
| 286 | The following list describes some of these practices. | ||
| 287 | For more information about Git workflows, see the workflow topics in | ||
| 288 | the | ||
| 289 | <ulink url='http://book.git-scm.com'>Git Community Book</ulink>. | ||
| 290 | <itemizedlist> | ||
| 291 | <listitem><para> | ||
| 292 | <emphasis>Make Small Changes:</emphasis> | ||
| 293 | It is best to keep the changes you commit small as compared to | ||
| 294 | bundling many disparate changes into a single commit. | ||
| 295 | This practice not only keeps things manageable but also allows | ||
| 296 | the maintainer to more easily include or refuse changes.</para> | ||
| 297 | |||
| 298 | <para>It is also good practice to leave the repository in a | ||
| 299 | state that allows you to still successfully build your project. | ||
| 300 | In other words, do not commit half of a feature, | ||
| 301 | then add the other half as a separate, later commit. | ||
| 302 | Each commit should take you from one buildable project state | ||
| 303 | to another buildable state. | ||
| 304 | </para></listitem> | ||
| 305 | <listitem><para> | ||
| 306 | <emphasis>Use Branches Liberally:</emphasis> | ||
| 307 | It is very easy to create, use, and delete local branches in | ||
| 308 | your working Git repository. | ||
| 309 | You can name these branches anything you like. | ||
| 310 | It is helpful to give them names associated with the particular | ||
| 311 | feature or change on which you are working. | ||
| 312 | Once you are done with a feature or change and have merged it | ||
| 313 | into your local master branch, simply discard the temporary | ||
| 314 | branch. | ||
| 315 | </para></listitem> | ||
| 316 | <listitem><para> | ||
| 317 | <emphasis>Merge Changes:</emphasis> | ||
| 318 | The <filename>git merge</filename> command allows you to take | ||
| 319 | the changes from one branch and fold them into another branch. | ||
| 320 | This process is especially helpful when more than a single | ||
| 321 | developer might be working on different parts of the same | ||
| 322 | feature. | ||
| 323 | Merging changes also automatically identifies any collisions | ||
| 324 | or "conflicts" that might happen as a result of the same lines | ||
| 325 | of code being altered by two different developers. | ||
| 326 | </para></listitem> | ||
| 327 | <listitem><para> | ||
| 328 | <emphasis>Manage Branches:</emphasis> | ||
| 329 | Because branches are easy to use, you should use a system | ||
| 330 | where branches indicate varying levels of code readiness. | ||
| 331 | For example, you can have a "work" branch to develop in, a | ||
| 332 | "test" branch where the code or change is tested, a "stage" | ||
| 333 | branch where changes are ready to be committed, and so forth. | ||
| 334 | As your project develops, you can merge code across the | ||
| 335 | branches to reflect ever-increasing stable states of the | ||
| 336 | development. | ||
| 337 | </para></listitem> | ||
| 338 | <listitem><para> | ||
| 339 | <emphasis>Use Push and Pull:</emphasis> | ||
| 340 | The push-pull workflow is based on the concept of developers | ||
| 341 | "pushing" local commits to a remote repository, which is | ||
| 342 | usually a contribution repository. | ||
| 343 | This workflow is also based on developers "pulling" known | ||
| 344 | states of the project down into their local development | ||
| 345 | repositories. | ||
| 346 | The workflow easily allows you to pull changes submitted by | ||
| 347 | other developers from the upstream repository into your | ||
| 348 | work area ensuring that you have the most recent software | ||
| 349 | on which to develop. | ||
| 350 | The Yocto Project has two scripts named | ||
| 351 | <filename>create-pull-request</filename> and | ||
| 352 | <filename>send-pull-request</filename> that ship with the | ||
| 353 | release to facilitate this workflow. | ||
| 354 | You can find these scripts in the <filename>scripts</filename> | ||
| 355 | folder of the | ||
| 356 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. | ||
| 357 | For information on how to use these scripts, see the | ||
| 358 | "<ulink url='&YOCTO_DOCS_DEV_URL;#pushing-a-change-upstream'>Using Scripts to Push a Change Upstream and Request a Pull</ulink>" | ||
| 359 | section in the Yocto Project Development Tasks Manual. | ||
| 360 | </para></listitem> | ||
| 361 | <listitem><para> | ||
| 362 | <emphasis>Patch Workflow:</emphasis> | ||
| 363 | This workflow allows you to notify the maintainer through an | ||
| 364 | email that you have a change (or patch) you would like | ||
| 365 | considered for the "master" branch of the Git repository. | ||
| 366 | To send this type of change, you format the patch and then | ||
| 367 | send the email using the Git commands | ||
| 368 | <filename>git format-patch</filename> and | ||
| 369 | <filename>git send-email</filename>. | ||
| 370 | For information on how to use these scripts, see the | ||
| 371 | "<ulink url='&YOCTO_DOCS_DEV_URL;#how-to-submit-a-change'>Submitting a Change to the Yocto Project</ulink>" | ||
| 372 | section in the Yocto Project Development Tasks Manual. | ||
| 373 | </para></listitem> | ||
| 374 | </itemizedlist> | ||
| 375 | </para> | ||
| 376 | </section> | ||
| 377 | |||
| 378 | <section id='git'> | ||
| 379 | <title>Git</title> | ||
| 380 | |||
| 381 | <para> | ||
| 382 | The Yocto Project makes extensive use of Git, which is a | ||
| 383 | free, open source distributed version control system. | ||
| 384 | Git supports distributed development, non-linear development, | ||
| 385 | and can handle large projects. | ||
| 386 | It is best that you have some fundamental understanding | ||
| 387 | of how Git tracks projects and how to work with Git if | ||
| 388 | you are going to use the Yocto Project for development. | ||
| 389 | This section provides a quick overview of how Git works and | ||
| 390 | provides you with a summary of some essential Git commands. | ||
| 391 | <note><title>Notes</title> | ||
| 392 | <itemizedlist> | ||
| 393 | <listitem><para> | ||
| 394 | For more information on Git, see | ||
| 395 | <ulink url='http://git-scm.com/documentation'></ulink>. | ||
| 396 | </para></listitem> | ||
| 397 | <listitem><para> | ||
| 398 | If you need to download Git, it is recommended that you add | ||
| 399 | Git to your system through your distribution's "software | ||
| 400 | store" (e.g. for Ubuntu, use the Ubuntu Software feature). | ||
| 401 | For the Git download page, see | ||
| 402 | <ulink url='http://git-scm.com/download'></ulink>. | ||
| 403 | </para></listitem> | ||
| 404 | <listitem><para> | ||
| 405 | For examples beyond the limited few in this section on how | ||
| 406 | to use Git with the Yocto Project, see the | ||
| 407 | "<ulink url='&YOCTO_DOCS_DEV_URL;#working-with-yocto-project-source-files'>Working With Yocto Project Source Files</ulink>" | ||
| 408 | section in the Yocto Project Development Tasks Manual. | ||
| 409 | </para></listitem> | ||
| 410 | </itemizedlist> | ||
| 411 | </note> | ||
| 412 | </para> | ||
| 413 | |||
| 414 | <section id='repositories-tags-and-branches'> | ||
| 415 | <title>Repositories, Tags, and Branches</title> | ||
| 416 | |||
| 417 | <para> | ||
| 418 | As mentioned briefly in the previous section and also in the | ||
| 419 | "<link linkend='workflows'>Workflows</link>" section, | ||
| 420 | the Yocto Project maintains source repositories at | ||
| 421 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi'></ulink>. | ||
| 422 | If you look at this web-interface of the repositories, each item | ||
| 423 | is a separate Git repository. | ||
| 424 | </para> | ||
| 425 | |||
| 426 | <para> | ||
| 427 | Git repositories use branching techniques that track content | ||
| 428 | change (not files) within a project (e.g. a new feature or updated | ||
| 429 | documentation). | ||
| 430 | Creating a tree-like structure based on project divergence allows | ||
| 431 | for excellent historical information over the life of a project. | ||
| 432 | This methodology also allows for an environment from which you can | ||
| 433 | do lots of local experimentation on projects as you develop | ||
| 434 | changes or new features. | ||
| 435 | </para> | ||
| 436 | |||
| 437 | <para> | ||
| 438 | A Git repository represents all development efforts for a given | ||
| 439 | project. | ||
| 440 | For example, the Git repository <filename>poky</filename> contains | ||
| 441 | all changes and developments for Poky over the course of its | ||
| 442 | entire life. | ||
| 443 | That means that all changes that make up all releases are captured. | ||
| 444 | The repository maintains a complete history of changes. | ||
| 445 | </para> | ||
| 446 | |||
| 447 | <para> | ||
| 448 | You can create a local copy of any repository by "cloning" it | ||
| 449 | with the <filename>git clone</filename> command. | ||
| 450 | When you clone a Git repository, you end up with an identical | ||
| 451 | copy of the repository on your development system. | ||
| 452 | Once you have a local copy of a repository, you can take steps to | ||
| 453 | develop locally. | ||
| 454 | For examples on how to clone Git repositories, see the | ||
| 455 | "<ulink url='&YOCTO_DOCS_DEV_URL;#working-with-yocto-project-source-files'>Working With Yocto Project Source Files</ulink>" | ||
| 456 | section in the Yocto Project Development Tasks Manual. | ||
| 457 | </para> | ||
| 458 | |||
| 459 | <para> | ||
| 460 | It is important to understand that Git tracks content change and | ||
| 461 | not files. | ||
| 462 | Git uses "branches" to organize different development efforts. | ||
| 463 | For example, the <filename>poky</filename> repository has | ||
| 464 | several branches that include the current "&DISTRO_NAME_NO_CAP;" | ||
| 465 | branch, the "master" branch, and many branches for past | ||
| 466 | Yocto Project releases. | ||
| 467 | You can see all the branches by going to | ||
| 468 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and | ||
| 469 | clicking on the | ||
| 470 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/heads'>[...]</ulink></filename> | ||
| 471 | link beneath the "Branch" heading. | ||
| 472 | </para> | ||
| 473 | |||
| 474 | <para> | ||
| 475 | Each of these branches represents a specific area of development. | ||
| 476 | The "master" branch represents the current or most recent | ||
| 477 | development. | ||
| 478 | All other branches represent offshoots of the "master" branch. | ||
| 479 | </para> | ||
| 480 | |||
| 481 | <para> | ||
| 482 | When you create a local copy of a Git repository, the copy has | ||
| 483 | the same set of branches as the original. | ||
| 484 | This means you can use Git to create a local working area | ||
| 485 | (also called a branch) that tracks a specific development branch | ||
| 486 | from the upstream source Git repository. | ||
| 487 | in other words, you can define your local Git environment to | ||
| 488 | work on any development branch in the repository. | ||
| 489 | To help illustrate, consider the following example Git commands: | ||
| 490 | <literallayout class='monospaced'> | ||
| 491 | $ cd ~ | ||
| 492 | $ git clone git://git.yoctoproject.org/poky | ||
| 493 | $ cd poky | ||
| 494 | $ git checkout -b &DISTRO_NAME_NO_CAP; origin/&DISTRO_NAME_NO_CAP; | ||
| 495 | </literallayout> | ||
| 496 | In the previous example after moving to the home directory, the | ||
| 497 | <filename>git clone</filename> command creates a | ||
| 498 | local copy of the upstream <filename>poky</filename> Git repository. | ||
| 499 | By default, Git checks out the "master" branch for your work. | ||
| 500 | After changing the working directory to the new local repository | ||
| 501 | (i.e. <filename>poky</filename>), the | ||
| 502 | <filename>git checkout</filename> command creates | ||
| 503 | and checks out a local branch named "&DISTRO_NAME_NO_CAP;", which | ||
| 504 | tracks the upstream "origin/&DISTRO_NAME_NO_CAP;" branch. | ||
| 505 | Changes you make while in this branch would ultimately affect | ||
| 506 | the upstream "&DISTRO_NAME_NO_CAP;" branch of the | ||
| 507 | <filename>poky</filename> repository. | ||
| 508 | </para> | ||
| 509 | |||
| 510 | <para> | ||
| 511 | It is important to understand that when you create and checkout a | ||
| 512 | local working branch based on a branch name, | ||
| 513 | your local environment matches the "tip" of that particular | ||
| 514 | development branch at the time you created your local branch, | ||
| 515 | which could be different from the files in the "master" branch | ||
| 516 | of the upstream repository. | ||
| 517 | In other words, creating and checking out a local branch based on | ||
| 518 | the "&DISTRO_NAME_NO_CAP;" branch name is not the same as | ||
| 519 | cloning and checking out the "master" branch if the repository. | ||
| 520 | Keep reading to see how you create a local snapshot of a Yocto | ||
| 521 | Project Release. | ||
| 522 | </para> | ||
| 523 | |||
| 524 | <para> | ||
| 525 | Git uses "tags" to mark specific changes in a repository. | ||
| 526 | Typically, a tag is used to mark a special point such as the final | ||
| 527 | change before a project is released. | ||
| 528 | You can see the tags used with the <filename>poky</filename> Git | ||
| 529 | repository by going to | ||
| 530 | <ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/'></ulink> and | ||
| 531 | clicking on the | ||
| 532 | <filename><ulink url='&YOCTO_GIT_URL;/cgit.cgi/poky/refs/tags'>[...]</ulink></filename> | ||
| 533 | link beneath the "Tag" heading. | ||
| 534 | </para> | ||
| 535 | |||
| 536 | <para> | ||
| 537 | Some key tags for the <filename>poky</filename> are | ||
| 538 | <filename>jethro-14.0.3</filename>, | ||
| 539 | <filename>morty-16.0.1</filename>, | ||
| 540 | <filename>pyro-17.0.0</filename>, and | ||
| 541 | <filename>&DISTRO_NAME_NO_CAP;-&POKYVERSION;</filename>. | ||
| 542 | These tags represent Yocto Project releases. | ||
| 543 | </para> | ||
| 544 | |||
| 545 | <para> | ||
| 546 | When you create a local copy of the Git repository, you also | ||
| 547 | have access to all the tags in the upstream repository. | ||
| 548 | Similar to branches, you can create and checkout a local working | ||
| 549 | Git branch based on a tag name. | ||
| 550 | When you do this, you get a snapshot of the Git repository that | ||
| 551 | reflects the state of the files when the change was made associated | ||
| 552 | with that tag. | ||
| 553 | The most common use is to checkout a working branch that matches | ||
| 554 | a specific Yocto Project release. | ||
| 555 | Here is an example: | ||
| 556 | <literallayout class='monospaced'> | ||
| 557 | $ cd ~ | ||
| 558 | $ git clone git://git.yoctoproject.org/poky | ||
| 559 | $ cd poky | ||
| 560 | $ git fetch --all --tags --prune | ||
| 561 | $ git checkout tags/pyro-17.0.0 -b my-pyro-17.0.0 | ||
| 562 | </literallayout> | ||
| 563 | In this example, the name of the top-level directory of your | ||
| 564 | local Yocto Project repository is <filename>poky</filename>. | ||
| 565 | After moving to the <filename>poky</filename> directory, the | ||
| 566 | <filename>git fetch</filename> command makes all the upstream | ||
| 567 | tags available locally in your repository. | ||
| 568 | Finally, the <filename>git checkout</filename> command | ||
| 569 | creates and checks out a branch named "my-pyro-17.0.0" that is | ||
| 570 | based on the specific change upstream in the repository | ||
| 571 | associated with the "pyro-17.0.0" tag. | ||
| 572 | The files in your repository now exactly match that particular | ||
| 573 | Yocto Project release as it is tagged in the upstream Git | ||
| 574 | repository. | ||
| 575 | It is important to understand that when you create and | ||
| 576 | checkout a local working branch based on a tag, your environment | ||
| 577 | matches a specific point in time and not the entire development | ||
| 578 | branch (i.e. the "tip" of the branch). | ||
| 579 | </para> | ||
| 580 | </section> | ||
| 581 | |||
| 582 | <section id='basic-commands'> | ||
| 583 | <title>Basic Commands</title> | ||
| 584 | |||
| 585 | <para> | ||
| 586 | Git has an extensive set of commands that lets you manage changes | ||
| 587 | and perform collaboration over the life of a project. | ||
| 588 | Conveniently though, you can manage with a small set of basic | ||
| 589 | operations and workflows once you understand the basic | ||
| 590 | philosophy behind Git. | ||
| 591 | You do not have to be an expert in Git to be functional. | ||
| 592 | A good place to look for instruction on a minimal set of Git | ||
| 593 | commands is | ||
| 594 | <ulink url='http://git-scm.com/documentation'>here</ulink>. | ||
| 595 | </para> | ||
| 596 | |||
| 597 | <para> | ||
| 598 | If you do not know much about Git, you should educate | ||
| 599 | yourself by visiting the links previously mentioned. | ||
| 600 | </para> | ||
| 601 | |||
| 602 | <para> | ||
| 603 | The following list of Git commands briefly describes some basic | ||
| 604 | Git operations as a way to get started. | ||
| 605 | As with any set of commands, this list (in most cases) simply shows | ||
| 606 | the base command and omits the many arguments they support. | ||
| 607 | See the Git documentation for complete descriptions and strategies | ||
| 608 | on how to use these commands: | ||
| 609 | <itemizedlist> | ||
| 610 | <listitem><para> | ||
| 611 | <emphasis><filename>git init</filename>:</emphasis> | ||
| 612 | Initializes an empty Git repository. | ||
| 613 | You cannot use Git commands unless you have a | ||
| 614 | <filename>.git</filename> repository. | ||
| 615 | </para></listitem> | ||
| 616 | <listitem><para id='git-commands-clone'> | ||
| 617 | <emphasis><filename>git clone</filename>:</emphasis> | ||
| 618 | Creates a local clone of a Git repository that is on | ||
| 619 | equal footing with a fellow developer’s Git repository | ||
| 620 | or an upstream repository. | ||
| 621 | </para></listitem> | ||
| 622 | <listitem><para> | ||
| 623 | <emphasis><filename>git add</filename>:</emphasis> | ||
| 624 | Locally stages updated file contents to the index that | ||
| 625 | Git uses to track changes. | ||
| 626 | You must stage all files that have changed before you | ||
| 627 | can commit them. | ||
| 628 | </para></listitem> | ||
| 629 | <listitem><para> | ||
| 630 | <emphasis><filename>git commit</filename>:</emphasis> | ||
| 631 | Creates a local "commit" that documents the changes you | ||
| 632 | made. | ||
| 633 | Only changes that have been staged can be committed. | ||
| 634 | Commits are used for historical purposes, for determining | ||
| 635 | if a maintainer of a project will allow the change, | ||
| 636 | and for ultimately pushing the change from your local | ||
| 637 | Git repository into the project’s upstream repository. | ||
| 638 | </para></listitem> | ||
| 639 | <listitem><para> | ||
| 640 | <emphasis><filename>git status</filename>:</emphasis> | ||
| 641 | Reports any modified files that possibly need to be | ||
| 642 | staged and gives you a status of where you stand regarding | ||
| 643 | local commits as compared to the upstream repository. | ||
| 644 | </para></listitem> | ||
| 645 | <listitem><para> | ||
| 646 | <emphasis><filename>git checkout</filename> <replaceable>branch-name</replaceable>:</emphasis> | ||
| 647 | Changes your working branch. | ||
| 648 | This command is analogous to "cd". | ||
| 649 | </para></listitem> | ||
| 650 | <listitem><para><emphasis><filename>git checkout –b</filename> <replaceable>working-branch</replaceable>:</emphasis> | ||
| 651 | Creates and checks out a working branch on your local | ||
| 652 | machine that you can use to isolate your work. | ||
| 653 | It is a good idea to use local branches when adding | ||
| 654 | specific features or changes. | ||
| 655 | Using isolated branches facilitates easy removal of | ||
| 656 | changes if they do not work out. | ||
| 657 | </para></listitem> | ||
| 658 | <listitem><para><emphasis><filename>git branch</filename>:</emphasis> | ||
| 659 | Displays the existing local branches associated with your | ||
| 660 | local repository. | ||
| 661 | The branch that you have currently checked out is noted | ||
| 662 | with an asterisk character. | ||
| 663 | </para></listitem> | ||
| 664 | <listitem><para> | ||
| 665 | <emphasis><filename>git branch -D</filename> <replaceable>branch-name</replaceable>:</emphasis> | ||
| 666 | Deletes an existing local branch. | ||
| 667 | You need to be in a local branch other than the one you | ||
| 668 | are deleting in order to delete | ||
| 669 | <replaceable>branch-name</replaceable>. | ||
| 670 | </para></listitem> | ||
| 671 | <listitem><para> | ||
| 672 | <emphasis><filename>git pull</filename>:</emphasis> | ||
| 673 | Retrieves information from an upstream Git repository | ||
| 674 | and places it in your local Git repository. | ||
| 675 | You use this command to make sure you are synchronized with | ||
| 676 | the repository from which you are basing changes | ||
| 677 | (.e.g. the "master" branch). | ||
| 678 | </para></listitem> | ||
| 679 | <listitem><para> | ||
| 680 | <emphasis><filename>git push</filename>:</emphasis> | ||
| 681 | Sends all your committed local changes to the upstream Git | ||
| 682 | repository that your local repository is tracking | ||
| 683 | (e.g. a contribution repository). | ||
| 684 | The maintainer of the project draws from these repositories | ||
| 685 | to merge changes (commits) into the appropriate branch | ||
| 686 | of project's upstream repository. | ||
| 687 | </para></listitem> | ||
| 688 | <listitem><para> | ||
| 689 | <emphasis><filename>git merge</filename>:</emphasis> | ||
| 690 | Combines or adds changes from one | ||
| 691 | local branch of your repository with another branch. | ||
| 692 | When you create a local Git repository, the default branch | ||
| 693 | is named "master". | ||
| 694 | A typical workflow is to create a temporary branch that is | ||
| 695 | based off "master" that you would use for isolated work. | ||
| 696 | You would make your changes in that isolated branch, | ||
| 697 | stage and commit them locally, switch to the "master" | ||
| 698 | branch, and then use the <filename>git merge</filename> | ||
| 699 | command to apply the changes from your isolated branch | ||
| 700 | into the currently checked out branch (e.g. "master"). | ||
| 701 | After the merge is complete and if you are done with | ||
| 702 | working in that isolated branch, you can safely delete | ||
| 703 | the isolated branch. | ||
| 704 | </para></listitem> | ||
| 705 | <listitem><para> | ||
| 706 | <emphasis><filename>git cherry-pick</filename>:</emphasis> | ||
| 707 | Choose and apply specific commits from one branch | ||
| 708 | into another branch. | ||
| 709 | There are times when you might not be able to merge | ||
| 710 | all the changes in one branch with | ||
| 711 | another but need to pick out certain ones. | ||
| 712 | </para></listitem> | ||
| 713 | <listitem><para> | ||
| 714 | <emphasis><filename>gitk</filename>:</emphasis> | ||
| 715 | Provides a GUI view of the branches and changes in your | ||
| 716 | local Git repository. | ||
| 717 | This command is a good way to graphically see where things | ||
| 718 | have diverged in your local repository. | ||
| 719 | <note> | ||
| 720 | You need to install the <filename>gitk</filename> | ||
| 721 | package on your development system to use this | ||
| 722 | command. | ||
| 723 | </note> | ||
| 724 | </para></listitem> | ||
| 725 | <listitem><para> | ||
| 726 | <emphasis><filename>git log</filename>:</emphasis> | ||
| 727 | Reports a history of your commits to the repository. | ||
| 728 | This report lists all commits regardless of whether you | ||
| 729 | have pushed them upstream or not. | ||
| 730 | </para></listitem> | ||
| 731 | <listitem><para> | ||
| 732 | <emphasis><filename>git diff</filename>:</emphasis> | ||
| 733 | Displays line-by-line differences between a local | ||
| 734 | working file and the same file as understood by Git. | ||
| 735 | This command is useful to see what you have changed | ||
| 736 | in any given file. | ||
| 737 | </para></listitem> | ||
| 738 | </itemizedlist> | ||
| 739 | </para> | ||
| 740 | </section> | ||
| 741 | </section> | ||
| 742 | |||
| 743 | <section id='yocto-project-repositories'> | ||
| 744 | <title>Yocto Project Source Repositories</title> | ||
| 745 | |||
| 746 | <para> | ||
| 747 | The Yocto Project team maintains complete source repositories for all | ||
| 748 | Yocto Project files at | ||
| 749 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'></ulink>. | ||
| 750 | This web-based source code browser is organized into categories by | ||
| 751 | function such as IDE Plugins, Matchbox, Poky, Yocto Linux Kernel, and | ||
| 752 | so forth. | ||
| 753 | From the interface, you can click on any particular item in the "Name" | ||
| 754 | column and see the URL at the bottom of the page that you need to clone | ||
| 755 | a Git repository for that particular item. | ||
| 756 | Having a local Git repository of the | ||
| 757 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>, | ||
| 758 | which is usually named "poky", allows | ||
| 759 | you to make changes, contribute to the history, and ultimately enhance | ||
| 760 | the Yocto Project's tools, Board Support Packages, and so forth. | ||
| 761 | </para> | ||
| 762 | |||
| 763 | <para> | ||
| 764 | For any supported release of Yocto Project, you can also go to the | ||
| 765 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink> and | ||
| 766 | select the "Downloads" tab and get a released tarball of the | ||
| 767 | <filename>poky</filename> repository or any supported BSP tarballs. | ||
| 768 | Unpacking these tarballs gives you a snapshot of the released | ||
| 769 | files. | ||
| 770 | <note><title>Notes</title> | ||
| 771 | <itemizedlist> | ||
| 772 | <listitem><para> | ||
| 773 | The recommended method for setting up the Yocto Project | ||
| 774 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | ||
| 775 | and the files for supported BSPs | ||
| 776 | (e.g., <filename>meta-intel</filename>) is to use | ||
| 777 | <link linkend='git'>Git</link> to create a local copy of | ||
| 778 | the upstream repositories. | ||
| 779 | </para></listitem> | ||
| 780 | <listitem><para> | ||
| 781 | Be sure to always work in matching branches for both | ||
| 782 | the selected BSP repository and the | ||
| 783 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | ||
| 784 | (i.e. <filename>poky</filename>) repository. | ||
| 785 | For example, if you have checked out the "master" branch | ||
| 786 | of <filename>poky</filename> and you are going to use | ||
| 787 | <filename>meta-intel</filename>, be sure to checkout the | ||
| 788 | "master" branch of <filename>meta-intel</filename>. | ||
| 789 | </para></listitem> | ||
| 790 | </itemizedlist> | ||
| 791 | </note> | ||
| 792 | </para> | ||
| 793 | |||
| 794 | <para> | ||
| 795 | In summary, here is where you can get the project files needed for | ||
| 796 | development: | ||
| 797 | <itemizedlist> | ||
| 798 | <listitem><para id='source-repositories'> | ||
| 799 | <emphasis> | ||
| 800 | <ulink url='&YOCTO_GIT_URL;/cgit/cgit.cgi'>Source Repositories:</ulink> | ||
| 801 | </emphasis> | ||
| 802 | This area contains IDE Plugins, Matchbox, Poky, Poky Support, | ||
| 803 | Tools, Yocto Linux Kernel, and Yocto Metadata Layers. | ||
| 804 | You can create local copies of Git repositories for each of | ||
| 805 | these areas.</para> | ||
| 806 | |||
| 807 | <para> | ||
| 808 | <imagedata fileref="figures/source-repos.png" align="center" width="6in" depth="4in" /> | ||
| 809 | For steps on how to view and access these upstream Git | ||
| 810 | repositories, see the | ||
| 811 | "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-source-repositories'>Accessing Source Repositories</ulink>" | ||
| 812 | Section in the Yocto Project Development Tasks Manual. | ||
| 813 | </para></listitem> | ||
| 814 | <listitem><para><anchor id='index-downloads' /> | ||
| 815 | <emphasis> | ||
| 816 | <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink> | ||
| 817 | </emphasis> | ||
| 818 | This is an index of releases such as | ||
| 819 | the <trademark class='trade'>Eclipse</trademark> | ||
| 820 | Yocto Plug-in, miscellaneous support, Poky, Pseudo, installers | ||
| 821 | for cross-development toolchains, and all released versions of | ||
| 822 | Yocto Project in the form of images or tarballs. | ||
| 823 | Downloading and extracting these files does not produce a local | ||
| 824 | copy of the Git repository but rather a snapshot of a | ||
| 825 | particular release or image.</para> | ||
| 826 | |||
| 827 | <para> | ||
| 828 | <imagedata fileref="figures/index-downloads.png" align="center" width="6in" depth="3.5in" /> | ||
| 829 | For steps on how to view and access these files, see the | ||
| 830 | "<ulink url='&YOCTO_DOCS_DEV_URL;#accessing-index-of-releases'>Accessing Index of Releases</ulink>" | ||
| 831 | section in the Yocto Project Development Tasks Manual. | ||
| 832 | </para></listitem> | ||
| 833 | <listitem><para id='downloads-page'> | ||
| 834 | <emphasis>"Downloads" page for the | ||
| 835 | <ulink url='&YOCTO_HOME_URL;'>Yocto Project Website</ulink>: | ||
| 836 | </emphasis></para> | ||
| 837 | |||
| 838 | <para role="writernotes">This section will change due to | ||
| 839 | reworking of the YP Website.</para> | ||
| 840 | |||
| 841 | <para>The Yocto Project website includes a "Downloads" tab | ||
| 842 | that allows you to download any Yocto Project | ||
| 843 | release and Board Support Package (BSP) in tarball form. | ||
| 844 | The tarballs are similar to those found in the | ||
| 845 | <ulink url='&YOCTO_DL_URL;/releases/'>Index of /releases:</ulink> area.</para> | ||
| 846 | |||
| 847 | <para> | ||
| 848 | <imagedata fileref="figures/yp-download.png" align="center" width="6in" depth="4in" /> | ||
| 849 | For steps on how to use the "Downloads" page, see the | ||
| 850 | "<ulink url='&YOCTO_DOCS_DEV_URL;#using-the-downloads-page'>Using the Downloads Page</ulink>" | ||
| 851 | section in the Yocto Project Development Tasks Manual. | ||
| 852 | </para></listitem> | ||
| 853 | </itemizedlist> | ||
| 854 | </para> | ||
| 855 | </section> | ||
| 856 | |||
| 857 | <section id='licensing'> | ||
| 858 | <title>Licensing</title> | ||
| 859 | |||
| 860 | <para> | ||
| 861 | Because open source projects are open to the public, they have | ||
| 862 | different licensing structures in place. | ||
| 863 | License evolution for both Open Source and Free Software has an | ||
| 864 | interesting history. | ||
| 865 | If you are interested in this history, you can find basic information | ||
| 866 | here: | ||
| 867 | <itemizedlist> | ||
| 868 | <listitem><para> | ||
| 869 | <ulink url='http://en.wikipedia.org/wiki/Open-source_license'>Open source license history</ulink> | ||
| 870 | </para></listitem> | ||
| 871 | <listitem><para> | ||
| 872 | <ulink url='http://en.wikipedia.org/wiki/Free_software_license'>Free software license history</ulink> | ||
| 873 | </para></listitem> | ||
| 874 | </itemizedlist> | ||
| 875 | </para> | ||
| 876 | |||
| 877 | <para> | ||
| 878 | In general, the Yocto Project is broadly licensed under the | ||
| 879 | Massachusetts Institute of Technology (MIT) License. | ||
| 880 | MIT licensing permits the reuse of software within proprietary | ||
| 881 | software as long as the license is distributed with that software. | ||
| 882 | MIT is also compatible with the GNU General Public License (GPL). | ||
| 883 | Patches to the Yocto Project follow the upstream licensing scheme. | ||
| 884 | You can find information on the MIT license | ||
| 885 | <ulink url='http://www.opensource.org/licenses/mit-license.php'>here</ulink>. | ||
| 886 | You can find information on the GNU GPL | ||
| 887 | <ulink url='http://www.opensource.org/licenses/LGPL-3.0'>here</ulink>. | ||
| 888 | </para> | ||
| 889 | |||
| 890 | <para> | ||
| 891 | When you build an image using the Yocto Project, the build process | ||
| 892 | uses a known list of licenses to ensure compliance. | ||
| 893 | You can find this list in the | ||
| 894 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink> | ||
| 895 | at <filename>meta/files/common-licenses</filename>. | ||
| 896 | Once the build completes, the list of all licenses found and used | ||
| 897 | during that build are kept in the | ||
| 898 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | ||
| 899 | at <filename>tmp/deploy/licenses</filename>. | ||
| 900 | </para> | ||
| 901 | |||
| 902 | <para> | ||
| 903 | If a module requires a license that is not in the base list, the | ||
| 904 | build process generates a warning during the build. | ||
| 905 | These tools make it easier for a developer to be certain of the | ||
| 906 | licenses with which their shipped products must comply. | ||
| 907 | However, even with these tools it is still up to the developer to | ||
| 908 | resolve potential licensing issues. | ||
| 909 | </para> | ||
| 910 | |||
| 911 | <para> | ||
| 912 | The base list of licenses used by the build process is a combination | ||
| 913 | of the Software Package Data Exchange (SPDX) list and the Open | ||
| 914 | Source Initiative (OSI) projects. | ||
| 915 | <ulink url='http://spdx.org'>SPDX Group</ulink> is a working group of | ||
| 916 | the Linux Foundation that maintains a specification for a standard | ||
| 917 | format for communicating the components, licenses, and copyrights | ||
| 918 | associated with a software package. | ||
| 919 | <ulink url='http://opensource.org'>OSI</ulink> is a corporation | ||
| 920 | dedicated to the Open Source Definition and the effort for reviewing | ||
| 921 | and approving licenses that conform to the Open Source Definition | ||
| 922 | (OSD). | ||
| 923 | </para> | ||
| 924 | |||
| 925 | <para> | ||
| 926 | You can find a list of the combined SPDX and OSI licenses that the | ||
| 927 | Yocto Project uses in the | ||
| 928 | <filename>meta/files/common-licenses</filename> directory in your | ||
| 929 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. | ||
| 930 | </para> | ||
| 931 | |||
| 932 | <para> | ||
| 933 | For information that can help you maintain compliance with various | ||
| 934 | open source licensing during the lifecycle of a product created using | ||
| 935 | the Yocto Project, see the | ||
| 936 | "<ulink url='&YOCTO_DOCS_DEV_URL;#maintaining-open-source-license-compliance-during-your-products-lifecycle'>Maintaining Open Source License Compliance During Your Product's Lifecycle</ulink>" | ||
| 937 | section in the Yocto Project Development Tasks Manual. | ||
| 938 | </para> | ||
| 939 | </section> | ||
| 940 | |||
| 941 | <section id='recipe-syntax'> | ||
| 942 | <title>Recipe Syntax</title> | ||
| 943 | |||
| 944 | <para> | ||
| 945 | Understanding recipe file syntax is important for | ||
| 946 | writing recipes. | ||
| 947 | The following list overviews the basic items that make up a | ||
| 948 | BitBake recipe file. | ||
| 949 | For more complete BitBake syntax descriptions, see the | ||
| 950 | "<ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink>" | ||
| 951 | chapter of the BitBake User Manual. | ||
| 952 | <itemizedlist> | ||
| 953 | <listitem><para><emphasis>Variable Assignments and Manipulations:</emphasis> | ||
| 954 | Variable assignments allow a value to be assigned to a | ||
| 955 | variable. | ||
| 956 | The assignment can be static text or might include | ||
| 957 | the contents of other variables. | ||
| 958 | In addition to the assignment, appending and prepending | ||
| 959 | operations are also supported.</para> | ||
| 960 | <para>The following example shows some of the ways | ||
| 961 | you can use variables in recipes: | ||
| 962 | <literallayout class='monospaced'> | ||
| 963 | S = "${WORKDIR}/postfix-${PV}" | ||
| 964 | CFLAGS += "-DNO_ASM" | ||
| 965 | SRC_URI_append = " file://fixup.patch" | ||
| 966 | </literallayout> | ||
| 967 | </para></listitem> | ||
| 968 | <listitem><para><emphasis>Functions:</emphasis> | ||
| 969 | Functions provide a series of actions to be performed. | ||
| 970 | You usually use functions to override the default | ||
| 971 | implementation of a task function or to complement | ||
| 972 | a default function (i.e. append or prepend to an | ||
| 973 | existing function). | ||
| 974 | Standard functions use <filename>sh</filename> shell | ||
| 975 | syntax, although access to OpenEmbedded variables and | ||
| 976 | internal methods are also available.</para> | ||
| 977 | <para>The following is an example function from the | ||
| 978 | <filename>sed</filename> recipe: | ||
| 979 | <literallayout class='monospaced'> | ||
| 980 | do_install () { | ||
| 981 | autotools_do_install | ||
| 982 | install -d ${D}${base_bindir} | ||
| 983 | mv ${D}${bindir}/sed ${D}${base_bindir}/sed | ||
| 984 | rmdir ${D}${bindir}/ | ||
| 985 | } | ||
| 986 | </literallayout> | ||
| 987 | It is also possible to implement new functions that | ||
| 988 | are called between existing tasks as long as the | ||
| 989 | new functions are not replacing or complementing the | ||
| 990 | default functions. | ||
| 991 | You can implement functions in Python | ||
| 992 | instead of shell. | ||
| 993 | Both of these options are not seen in the majority of | ||
| 994 | recipes.</para></listitem> | ||
| 995 | <listitem><para><emphasis>Keywords:</emphasis> | ||
| 996 | BitBake recipes use only a few keywords. | ||
| 997 | You use keywords to include common | ||
| 998 | functions (<filename>inherit</filename>), load parts | ||
| 999 | of a recipe from other files | ||
| 1000 | (<filename>include</filename> and | ||
| 1001 | <filename>require</filename>) and export variables | ||
| 1002 | to the environment (<filename>export</filename>).</para> | ||
| 1003 | <para>The following example shows the use of some of | ||
| 1004 | these keywords: | ||
| 1005 | <literallayout class='monospaced'> | ||
| 1006 | export POSTCONF = "${STAGING_BINDIR}/postconf" | ||
| 1007 | inherit autoconf | ||
| 1008 | require otherfile.inc | ||
| 1009 | </literallayout> | ||
| 1010 | </para></listitem> | ||
| 1011 | <listitem><para><emphasis>Comments:</emphasis> | ||
| 1012 | Any lines that begin with the hash character | ||
| 1013 | (<filename>#</filename>) are treated as comment lines | ||
| 1014 | and are ignored: | ||
| 1015 | <literallayout class='monospaced'> | ||
| 1016 | # This is a comment | ||
| 1017 | </literallayout> | ||
| 1018 | </para></listitem> | ||
| 1019 | </itemizedlist> | ||
| 1020 | </para> | ||
| 1021 | |||
| 1022 | <para> | ||
| 1023 | This next list summarizes the most important and most commonly | ||
| 1024 | used parts of the recipe syntax. | ||
| 1025 | For more information on these parts of the syntax, you can | ||
| 1026 | reference the | ||
| 1027 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual-metadata'>Syntax and Operators</ulink> | ||
| 1028 | chapter in the BitBake User Manual. | ||
| 1029 | <itemizedlist> | ||
| 1030 | <listitem><para><emphasis>Line Continuation: <filename>\</filename></emphasis> - | ||
| 1031 | Use the backward slash (<filename>\</filename>) | ||
| 1032 | character to split a statement over multiple lines. | ||
| 1033 | Place the slash character at the end of the line that | ||
| 1034 | is to be continued on the next line: | ||
| 1035 | <literallayout class='monospaced'> | ||
| 1036 | VAR = "A really long \ | ||
| 1037 | line" | ||
| 1038 | </literallayout> | ||
| 1039 | <note> | ||
| 1040 | You cannot have any characters including spaces | ||
| 1041 | or tabs after the slash character. | ||
| 1042 | </note> | ||
| 1043 | </para></listitem> | ||
| 1044 | <listitem><para> | ||
| 1045 | <emphasis>Using Variables: <filename>${...}</filename></emphasis> - | ||
| 1046 | Use the <filename>${<replaceable>VARNAME</replaceable>}</filename> syntax to | ||
| 1047 | access the contents of a variable: | ||
| 1048 | <literallayout class='monospaced'> | ||
| 1049 | SRC_URI = "${SOURCEFORGE_MIRROR}/libpng/zlib-${PV}.tar.gz" | ||
| 1050 | </literallayout> | ||
| 1051 | <note> | ||
| 1052 | It is important to understand that the value of a | ||
| 1053 | variable expressed in this form does not get | ||
| 1054 | substituted automatically. | ||
| 1055 | The expansion of these expressions happens | ||
| 1056 | on-demand later (e.g. usually when a function that | ||
| 1057 | makes reference to the variable executes). | ||
| 1058 | This behavior ensures that the values are most | ||
| 1059 | appropriate for the context in which they are | ||
| 1060 | finally used. | ||
| 1061 | On the rare occasion that you do need the variable | ||
| 1062 | expression to be expanded immediately, you can use | ||
| 1063 | the <filename>:=</filename> operator instead of | ||
| 1064 | <filename>=</filename> when you make the | ||
| 1065 | assignment, but this is not generally needed. | ||
| 1066 | </note> | ||
| 1067 | </para></listitem> | ||
| 1068 | <listitem><para><emphasis>Quote All Assignments: <filename>"<replaceable>value</replaceable>"</filename></emphasis> - | ||
| 1069 | Use double quotes around the value in all variable | ||
| 1070 | assignments. | ||
| 1071 | <literallayout class='monospaced'> | ||
| 1072 | VAR1 = "${OTHERVAR}" | ||
| 1073 | VAR2 = "The version is ${PV}" | ||
| 1074 | </literallayout> | ||
| 1075 | </para></listitem> | ||
| 1076 | <listitem><para><emphasis>Conditional Assignment: <filename>?=</filename></emphasis> - | ||
| 1077 | Conditional assignment is used to assign a value to | ||
| 1078 | a variable, but only when the variable is currently | ||
| 1079 | unset. | ||
| 1080 | Use the question mark followed by the equal sign | ||
| 1081 | (<filename>?=</filename>) to make a "soft" assignment | ||
| 1082 | used for conditional assignment. | ||
| 1083 | Typically, "soft" assignments are used in the | ||
| 1084 | <filename>local.conf</filename> file for variables | ||
| 1085 | that are allowed to come through from the external | ||
| 1086 | environment. | ||
| 1087 | </para> | ||
| 1088 | <para>Here is an example where | ||
| 1089 | <filename>VAR1</filename> is set to "New value" if | ||
| 1090 | it is currently empty. | ||
| 1091 | However, if <filename>VAR1</filename> has already been | ||
| 1092 | set, it remains unchanged: | ||
| 1093 | <literallayout class='monospaced'> | ||
| 1094 | VAR1 ?= "New value" | ||
| 1095 | </literallayout> | ||
| 1096 | In this next example, <filename>VAR1</filename> | ||
| 1097 | is left with the value "Original value": | ||
| 1098 | <literallayout class='monospaced'> | ||
| 1099 | VAR1 = "Original value" | ||
| 1100 | VAR1 ?= "New value" | ||
| 1101 | </literallayout> | ||
| 1102 | </para></listitem> | ||
| 1103 | <listitem><para><emphasis>Appending: <filename>+=</filename></emphasis> - | ||
| 1104 | Use the plus character followed by the equals sign | ||
| 1105 | (<filename>+=</filename>) to append values to existing | ||
| 1106 | variables. | ||
| 1107 | <note> | ||
| 1108 | This operator adds a space between the existing | ||
| 1109 | content of the variable and the new content. | ||
| 1110 | </note></para> | ||
| 1111 | <para>Here is an example: | ||
| 1112 | <literallayout class='monospaced'> | ||
| 1113 | SRC_URI += "file://fix-makefile.patch" | ||
| 1114 | </literallayout> | ||
| 1115 | </para></listitem> | ||
| 1116 | <listitem><para><emphasis>Prepending: <filename>=+</filename></emphasis> - | ||
| 1117 | Use the equals sign followed by the plus character | ||
| 1118 | (<filename>=+</filename>) to prepend values to existing | ||
| 1119 | variables. | ||
| 1120 | <note> | ||
| 1121 | This operator adds a space between the new content | ||
| 1122 | and the existing content of the variable. | ||
| 1123 | </note></para> | ||
| 1124 | <para>Here is an example: | ||
| 1125 | <literallayout class='monospaced'> | ||
| 1126 | VAR =+ "Starts" | ||
| 1127 | </literallayout> | ||
| 1128 | </para></listitem> | ||
| 1129 | <listitem><para><emphasis>Appending: <filename>_append</filename></emphasis> - | ||
| 1130 | Use the <filename>_append</filename> operator to | ||
| 1131 | append values to existing variables. | ||
| 1132 | This operator does not add any additional space. | ||
| 1133 | Also, the operator is applied after all the | ||
| 1134 | <filename>+=</filename>, and | ||
| 1135 | <filename>=+</filename> operators have been applied and | ||
| 1136 | after all <filename>=</filename> assignments have | ||
| 1137 | occurred. | ||
| 1138 | </para> | ||
| 1139 | <para>The following example shows the space being | ||
| 1140 | explicitly added to the start to ensure the appended | ||
| 1141 | value is not merged with the existing value: | ||
| 1142 | <literallayout class='monospaced'> | ||
| 1143 | SRC_URI_append = " file://fix-makefile.patch" | ||
| 1144 | </literallayout> | ||
| 1145 | You can also use the <filename>_append</filename> | ||
| 1146 | operator with overrides, which results in the actions | ||
| 1147 | only being performed for the specified target or | ||
| 1148 | machine: | ||
| 1149 | <literallayout class='monospaced'> | ||
| 1150 | SRC_URI_append_sh4 = " file://fix-makefile.patch" | ||
| 1151 | </literallayout> | ||
| 1152 | </para></listitem> | ||
| 1153 | <listitem><para><emphasis>Prepending: <filename>_prepend</filename></emphasis> - | ||
| 1154 | Use the <filename>_prepend</filename> operator to | ||
| 1155 | prepend values to existing variables. | ||
| 1156 | This operator does not add any additional space. | ||
| 1157 | Also, the operator is applied after all the | ||
| 1158 | <filename>+=</filename>, and | ||
| 1159 | <filename>=+</filename> operators have been applied and | ||
| 1160 | after all <filename>=</filename> assignments have | ||
| 1161 | occurred. | ||
| 1162 | </para> | ||
| 1163 | <para>The following example shows the space being | ||
| 1164 | explicitly added to the end to ensure the prepended | ||
| 1165 | value is not merged with the existing value: | ||
| 1166 | <literallayout class='monospaced'> | ||
| 1167 | CFLAGS_prepend = "-I${S}/myincludes " | ||
| 1168 | </literallayout> | ||
| 1169 | You can also use the <filename>_prepend</filename> | ||
| 1170 | operator with overrides, which results in the actions | ||
| 1171 | only being performed for the specified target or | ||
| 1172 | machine: | ||
| 1173 | <literallayout class='monospaced'> | ||
| 1174 | CFLAGS_prepend_sh4 = "-I${S}/myincludes " | ||
| 1175 | </literallayout> | ||
| 1176 | </para></listitem> | ||
| 1177 | <listitem><para><emphasis>Overrides:</emphasis> - | ||
| 1178 | You can use overrides to set a value conditionally, | ||
| 1179 | typically based on how the recipe is being built. | ||
| 1180 | For example, to set the | ||
| 1181 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KBRANCH'><filename>KBRANCH</filename></ulink> | ||
| 1182 | variable's value to "standard/base" for any target | ||
| 1183 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink>, | ||
| 1184 | except for qemuarm where it should be set to | ||
| 1185 | "standard/arm-versatile-926ejs", you would do the | ||
| 1186 | following: | ||
| 1187 | <literallayout class='monospaced'> | ||
| 1188 | KBRANCH = "standard/base" | ||
| 1189 | KBRANCH_qemuarm = "standard/arm-versatile-926ejs" | ||
| 1190 | </literallayout> | ||
| 1191 | Overrides are also used to separate alternate values | ||
| 1192 | of a variable in other situations. | ||
| 1193 | For example, when setting variables such as | ||
| 1194 | <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> | ||
| 1195 | and | ||
| 1196 | <ulink url='&YOCTO_DOCS_REF_URL;#var-RDEPENDS'><filename>RDEPENDS</filename></ulink> | ||
| 1197 | that are specific to individual packages produced by | ||
| 1198 | a recipe, you should always use an override that | ||
| 1199 | specifies the name of the package. | ||
| 1200 | </para></listitem> | ||
| 1201 | <listitem><para><emphasis>Indentation:</emphasis> | ||
| 1202 | Use spaces for indentation rather than than tabs. | ||
| 1203 | For shell functions, both currently work. | ||
| 1204 | However, it is a policy decision of the Yocto Project | ||
| 1205 | to use tabs in shell functions. | ||
| 1206 | Realize that some layers have a policy to use spaces | ||
| 1207 | for all indentation. | ||
| 1208 | </para></listitem> | ||
| 1209 | <listitem><para><emphasis>Using Python for Complex Operations: <filename>${@<replaceable>python_code</replaceable>}</filename></emphasis> - | ||
| 1210 | For more advanced processing, it is possible to use | ||
| 1211 | Python code during variable assignments (e.g. | ||
| 1212 | search and replacement on a variable).</para> | ||
| 1213 | <para>You indicate Python code using the | ||
| 1214 | <filename>${@<replaceable>python_code</replaceable>}</filename> | ||
| 1215 | syntax for the variable assignment: | ||
| 1216 | <literallayout class='monospaced'> | ||
| 1217 | SRC_URI = "ftp://ftp.info-zip.org/pub/infozip/src/zip${@d.getVar('PV',1).replace('.', '')}.tgz | ||
| 1218 | </literallayout> | ||
| 1219 | </para></listitem> | ||
| 1220 | <listitem><para><emphasis>Shell Function Syntax:</emphasis> | ||
| 1221 | Write shell functions as if you were writing a shell | ||
| 1222 | script when you describe a list of actions to take. | ||
| 1223 | You should ensure that your script works with a generic | ||
| 1224 | <filename>sh</filename> and that it does not require | ||
| 1225 | any <filename>bash</filename> or other shell-specific | ||
| 1226 | functionality. | ||
| 1227 | The same considerations apply to various system | ||
| 1228 | utilities (e.g. <filename>sed</filename>, | ||
| 1229 | <filename>grep</filename>, <filename>awk</filename>, | ||
| 1230 | and so forth) that you might wish to use. | ||
| 1231 | If in doubt, you should check with multiple | ||
| 1232 | implementations - including those from BusyBox. | ||
| 1233 | </para></listitem> | ||
| 1234 | </itemizedlist> | ||
| 1235 | </para> | ||
| 1236 | </section> | ||
| 1237 | |||
| 1238 | <section id="development-concepts"> | ||
| 1239 | <title>Development Concepts</title> | ||
| 1240 | |||
| 1241 | <para> | ||
| 1242 | This section takes a more detailed look inside the development | ||
| 1243 | process. | ||
| 1244 | The following diagram represents development at a high level. | ||
| 1245 | The remainder of this chapter expands on the fundamental input, output, | ||
| 1246 | process, and | ||
| 1247 | <ulink url='&YOCTO_DOCS_REF_URL;#metadata'>Metadata</ulink>) blocks | ||
| 1248 | that make up development in the Yocto Project environment. | ||
| 1249 | </para> | ||
| 1250 | |||
| 1251 | <para id='general-yocto-environment-figure'> | ||
| 1252 | <imagedata fileref="figures/yocto-environment-ref.png" align="center" width="8in" depth="4.25in" /> | ||
| 1253 | </para> | ||
| 1254 | |||
| 1255 | <para> | ||
| 1256 | In general, development consists of several functional areas: | ||
| 1257 | <itemizedlist> | ||
| 1258 | <listitem><para><emphasis>User Configuration:</emphasis> | ||
| 1259 | Metadata you can use to control the build process. | ||
| 1260 | </para></listitem> | ||
| 1261 | <listitem><para><emphasis>Metadata Layers:</emphasis> | ||
| 1262 | Various layers that provide software, machine, and | ||
| 1263 | distro Metadata.</para></listitem> | ||
| 1264 | <listitem><para><emphasis>Source Files:</emphasis> | ||
| 1265 | Upstream releases, local projects, and SCMs.</para></listitem> | ||
| 1266 | <listitem><para><emphasis>Build System:</emphasis> | ||
| 1267 | Processes under the control of | ||
| 1268 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink>. | ||
| 1269 | This block expands on how BitBake fetches source, applies | ||
| 1270 | patches, completes compilation, analyzes output for package | ||
| 1271 | generation, creates and tests packages, generates images, and | ||
| 1272 | generates cross-development tools.</para></listitem> | ||
| 1273 | <listitem><para><emphasis>Package Feeds:</emphasis> | ||
| 1274 | Directories containing output packages (RPM, DEB or IPK), | ||
| 1275 | which are subsequently used in the construction of an image or | ||
| 1276 | SDK, produced by the build system. | ||
| 1277 | These feeds can also be copied and shared using a web server or | ||
| 1278 | other means to facilitate extending or updating existing | ||
| 1279 | images on devices at runtime if runtime package management is | ||
| 1280 | enabled.</para></listitem> | ||
| 1281 | <listitem><para><emphasis>Images:</emphasis> | ||
| 1282 | Images produced by the development process. | ||
| 1283 | </para></listitem> | ||
| 1284 | <listitem><para><emphasis>Application Development SDK:</emphasis> | ||
| 1285 | Cross-development tools that are produced along with an image | ||
| 1286 | or separately with BitBake.</para></listitem> | ||
| 1287 | </itemizedlist> | ||
| 1288 | </para> | ||
| 1289 | |||
| 1290 | <section id="user-configuration"> | ||
| 1291 | <title>User Configuration</title> | ||
| 1292 | |||
| 1293 | <para> | ||
| 1294 | User configuration helps define the build. | ||
| 1295 | Through user configuration, you can tell BitBake the | ||
| 1296 | target architecture for which you are building the image, | ||
| 1297 | where to store downloaded source, and other build properties. | ||
| 1298 | </para> | ||
| 1299 | |||
| 1300 | <para> | ||
| 1301 | The following figure shows an expanded representation of the | ||
| 1302 | "User Configuration" box of the | ||
| 1303 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>: | ||
| 1304 | </para> | ||
| 1305 | |||
| 1306 | <para> | ||
| 1307 | <imagedata fileref="figures/user-configuration.png" align="center" width="8in" depth="4.5in" /> | ||
| 1308 | </para> | ||
| 1309 | |||
| 1310 | <para> | ||
| 1311 | BitBake needs some basic configuration files in order to complete | ||
| 1312 | a build. | ||
| 1313 | These files are <filename>*.conf</filename> files. | ||
| 1314 | The minimally necessary ones reside as example files in the | ||
| 1315 | <ulink url='&YOCTO_DOCS_REF_URL;#source-directory'>Source Directory</ulink>. | ||
| 1316 | For simplicity, this section refers to the Source Directory as | ||
| 1317 | the "Poky Directory." | ||
| 1318 | </para> | ||
| 1319 | |||
| 1320 | <para> | ||
| 1321 | When you clone the <filename>poky</filename> Git repository or you | ||
| 1322 | download and unpack a Yocto Project release, you can set up the | ||
| 1323 | Source Directory to be named anything you want. | ||
| 1324 | For this discussion, the cloned repository uses the default | ||
| 1325 | name <filename>poky</filename>. | ||
| 1326 | <note> | ||
| 1327 | The Poky repository is primarily an aggregation of existing | ||
| 1328 | repositories. | ||
| 1329 | It is not a canonical upstream source. | ||
| 1330 | </note> | ||
| 1331 | </para> | ||
| 1332 | |||
| 1333 | <para> | ||
| 1334 | The <filename>meta-poky</filename> layer inside Poky contains | ||
| 1335 | a <filename>conf</filename> directory that has example | ||
| 1336 | configuration files. | ||
| 1337 | These example files are used as a basis for creating actual | ||
| 1338 | configuration files when you source the build environment | ||
| 1339 | script | ||
| 1340 | (i.e. | ||
| 1341 | <ulink url='&YOCTO_DOCS_REF_URL;#structure-core-script'><filename>&OE_INIT_FILE;</filename></ulink>). | ||
| 1342 | </para> | ||
| 1343 | |||
| 1344 | <para> | ||
| 1345 | Sourcing the build environment script creates a | ||
| 1346 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | ||
| 1347 | if one does not already exist. | ||
| 1348 | BitBake uses the Build Directory for all its work during builds. | ||
| 1349 | The Build Directory has a <filename>conf</filename> directory that | ||
| 1350 | contains default versions of your <filename>local.conf</filename> | ||
| 1351 | and <filename>bblayers.conf</filename> configuration files. | ||
| 1352 | These default configuration files are created only if versions | ||
| 1353 | do not already exist in the Build Directory at the time you | ||
| 1354 | source the build environment setup script. | ||
| 1355 | </para> | ||
| 1356 | |||
| 1357 | <para> | ||
| 1358 | Because the Poky repository is fundamentally an aggregation of | ||
| 1359 | existing repositories, some users might be familiar with running | ||
| 1360 | the <filename>&OE_INIT_FILE;</filename> script in the context | ||
| 1361 | of separate OpenEmbedded-Core and BitBake repositories rather than a | ||
| 1362 | single Poky repository. | ||
| 1363 | This discussion assumes the script is executed from within a cloned | ||
| 1364 | or unpacked version of Poky. | ||
| 1365 | </para> | ||
| 1366 | |||
| 1367 | <para> | ||
| 1368 | Depending on where the script is sourced, different sub-scripts | ||
| 1369 | are called to set up the Build Directory (Yocto or OpenEmbedded). | ||
| 1370 | Specifically, the script | ||
| 1371 | <filename>scripts/oe-setup-builddir</filename> inside the | ||
| 1372 | poky directory sets up the Build Directory and seeds the directory | ||
| 1373 | (if necessary) with configuration files appropriate for the | ||
| 1374 | Yocto Project development environment. | ||
| 1375 | <note> | ||
| 1376 | The <filename>scripts/oe-setup-builddir</filename> script | ||
| 1377 | uses the <filename>$TEMPLATECONF</filename> variable to | ||
| 1378 | determine which sample configuration files to locate. | ||
| 1379 | </note> | ||
| 1380 | </para> | ||
| 1381 | |||
| 1382 | <para> | ||
| 1383 | The <filename>local.conf</filename> file provides many | ||
| 1384 | basic variables that define a build environment. | ||
| 1385 | Here is a list of a few. | ||
| 1386 | To see the default configurations in a <filename>local.conf</filename> | ||
| 1387 | file created by the build environment script, see the | ||
| 1388 | <filename>local.conf.sample</filename> in the | ||
| 1389 | <filename>meta-poky</filename> layer: | ||
| 1390 | <itemizedlist> | ||
| 1391 | <listitem><para><emphasis>Parallelism Options:</emphasis> | ||
| 1392 | Controlled by the | ||
| 1393 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_NUMBER_THREADS'><filename>BB_NUMBER_THREADS</filename></ulink>, | ||
| 1394 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PARALLEL_MAKE'><filename>PARALLEL_MAKE</filename></ulink>, | ||
| 1395 | and | ||
| 1396 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_NUMBER_PARSE_THREADS'><filename>BB_NUMBER_PARSE_THREADS</filename></ulink> | ||
| 1397 | variables.</para></listitem> | ||
| 1398 | <listitem><para><emphasis>Target Machine Selection:</emphasis> | ||
| 1399 | Controlled by the | ||
| 1400 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MACHINE'><filename>MACHINE</filename></ulink> | ||
| 1401 | variable.</para></listitem> | ||
| 1402 | <listitem><para><emphasis>Download Directory:</emphasis> | ||
| 1403 | Controlled by the | ||
| 1404 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> | ||
| 1405 | variable.</para></listitem> | ||
| 1406 | <listitem><para><emphasis>Shared State Directory:</emphasis> | ||
| 1407 | Controlled by the | ||
| 1408 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> | ||
| 1409 | variable.</para></listitem> | ||
| 1410 | <listitem><para><emphasis>Build Output:</emphasis> | ||
| 1411 | Controlled by the | ||
| 1412 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> | ||
| 1413 | variable.</para></listitem> | ||
| 1414 | </itemizedlist> | ||
| 1415 | <note> | ||
| 1416 | Configurations set in the <filename>conf/local.conf</filename> | ||
| 1417 | file can also be set in the | ||
| 1418 | <filename>conf/site.conf</filename> and | ||
| 1419 | <filename>conf/auto.conf</filename> configuration files. | ||
| 1420 | </note> | ||
| 1421 | </para> | ||
| 1422 | |||
| 1423 | <para> | ||
| 1424 | The <filename>bblayers.conf</filename> file tells BitBake what | ||
| 1425 | layers you want considered during the build. | ||
| 1426 | By default, the layers listed in this file include layers | ||
| 1427 | minimally needed by the build system. | ||
| 1428 | However, you must manually add any custom layers you have created. | ||
| 1429 | You can find more information on working with the | ||
| 1430 | <filename>bblayers.conf</filename> file in the | ||
| 1431 | "<ulink url='&YOCTO_DOCS_DEV_URL;#enabling-your-layer'>Enabling Your Layer</ulink>" | ||
| 1432 | section in the Yocto Project Development Tasks Manual. | ||
| 1433 | </para> | ||
| 1434 | |||
| 1435 | <para> | ||
| 1436 | The files <filename>site.conf</filename> and | ||
| 1437 | <filename>auto.conf</filename> are not created by the environment | ||
| 1438 | initialization script. | ||
| 1439 | If you want the <filename>site.conf</filename> file, you need to | ||
| 1440 | create that yourself. | ||
| 1441 | The <filename>auto.conf</filename> file is typically created by | ||
| 1442 | an autobuilder: | ||
| 1443 | <itemizedlist> | ||
| 1444 | <listitem><para><emphasis><filename>site.conf</filename>:</emphasis> | ||
| 1445 | You can use the <filename>conf/site.conf</filename> | ||
| 1446 | configuration file to configure multiple build directories. | ||
| 1447 | For example, suppose you had several build environments and | ||
| 1448 | they shared some common features. | ||
| 1449 | You can set these default build properties here. | ||
| 1450 | A good example is perhaps the packaging format to use | ||
| 1451 | through the | ||
| 1452 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> | ||
| 1453 | variable.</para> | ||
| 1454 | <para>One useful scenario for using the | ||
| 1455 | <filename>conf/site.conf</filename> file is to extend your | ||
| 1456 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BBPATH'><filename>BBPATH</filename></ulink> | ||
| 1457 | variable to include the path to a | ||
| 1458 | <filename>conf/site.conf</filename>. | ||
| 1459 | Then, when BitBake looks for Metadata using | ||
| 1460 | <filename>BBPATH</filename>, it finds the | ||
| 1461 | <filename>conf/site.conf</filename> file and applies your | ||
| 1462 | common configurations found in the file. | ||
| 1463 | To override configurations in a particular build directory, | ||
| 1464 | alter the similar configurations within that build | ||
| 1465 | directory's <filename>conf/local.conf</filename> file. | ||
| 1466 | </para></listitem> | ||
| 1467 | <listitem><para><emphasis><filename>auto.conf</filename>:</emphasis> | ||
| 1468 | The file is usually created and written to by | ||
| 1469 | an autobuilder. | ||
| 1470 | The settings put into the file are typically the same as | ||
| 1471 | you would find in the <filename>conf/local.conf</filename> | ||
| 1472 | or the <filename>conf/site.conf</filename> files. | ||
| 1473 | </para></listitem> | ||
| 1474 | </itemizedlist> | ||
| 1475 | </para> | ||
| 1476 | |||
| 1477 | <para> | ||
| 1478 | You can edit all configuration files to further define | ||
| 1479 | any particular build environment. | ||
| 1480 | This process is represented by the "User Configuration Edits" | ||
| 1481 | box in the figure. | ||
| 1482 | </para> | ||
| 1483 | |||
| 1484 | <para> | ||
| 1485 | When you launch your build with the | ||
| 1486 | <filename>bitbake <replaceable>target</replaceable></filename> | ||
| 1487 | command, BitBake sorts out the configurations to ultimately | ||
| 1488 | define your build environment. | ||
| 1489 | It is important to understand that the OpenEmbedded build system | ||
| 1490 | reads the configuration files in a specific order: | ||
| 1491 | <filename>site.conf</filename>, <filename>auto.conf</filename>, | ||
| 1492 | and <filename>local.conf</filename>. | ||
| 1493 | And, the build system applies the normal assignment statement | ||
| 1494 | rules. | ||
| 1495 | Because the files are parsed in a specific order, variable | ||
| 1496 | assignments for the same variable could be affected. | ||
| 1497 | For example, if the <filename>auto.conf</filename> file and | ||
| 1498 | the <filename>local.conf</filename> set | ||
| 1499 | <replaceable>variable1</replaceable> to different values, because | ||
| 1500 | the build system parses <filename>local.conf</filename> after | ||
| 1501 | <filename>auto.conf</filename>, | ||
| 1502 | <replaceable>variable1</replaceable> is assigned the value from | ||
| 1503 | the <filename>local.conf</filename> file. | ||
| 1504 | </para> | ||
| 1505 | </section> | ||
| 1506 | |||
| 1507 | <section id="metadata-machine-configuration-and-policy-configuration"> | ||
| 1508 | <title>Metadata, Machine Configuration, and Policy Configuration</title> | ||
| 1509 | |||
| 1510 | <para> | ||
| 1511 | The previous section described the user configurations that | ||
| 1512 | define BitBake's global behavior. | ||
| 1513 | This section takes a closer look at the layers the build system | ||
| 1514 | uses to further control the build. | ||
| 1515 | These layers provide Metadata for the software, machine, and | ||
| 1516 | policy. | ||
| 1517 | </para> | ||
| 1518 | |||
| 1519 | <para> | ||
| 1520 | In general, three types of layer input exist: | ||
| 1521 | <itemizedlist> | ||
| 1522 | <listitem><para><emphasis>Policy Configuration:</emphasis> | ||
| 1523 | Distribution Layers provide top-level or general | ||
| 1524 | policies for the image or SDK being built. | ||
| 1525 | For example, this layer would dictate whether BitBake | ||
| 1526 | produces RPM or IPK packages.</para></listitem> | ||
| 1527 | <listitem><para><emphasis>Machine Configuration:</emphasis> | ||
| 1528 | Board Support Package (BSP) layers provide machine | ||
| 1529 | configurations. | ||
| 1530 | This type of information is specific to a particular | ||
| 1531 | target architecture.</para></listitem> | ||
| 1532 | <listitem><para><emphasis>Metadata:</emphasis> | ||
| 1533 | Software layers contain user-supplied recipe files, | ||
| 1534 | patches, and append files. | ||
| 1535 | </para></listitem> | ||
| 1536 | </itemizedlist> | ||
| 1537 | </para> | ||
| 1538 | |||
| 1539 | <para> | ||
| 1540 | The following figure shows an expanded representation of the | ||
| 1541 | Metadata, Machine Configuration, and Policy Configuration input | ||
| 1542 | (layers) boxes of the | ||
| 1543 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>: | ||
| 1544 | </para> | ||
| 1545 | |||
| 1546 | <para> | ||
| 1547 | <imagedata fileref="figures/layer-input.png" align="center" width="8in" depth="7.5in" /> | ||
| 1548 | </para> | ||
| 1549 | |||
| 1550 | <para> | ||
| 1551 | In general, all layers have a similar structure. | ||
| 1552 | They all contain a licensing file | ||
| 1553 | (e.g. <filename>COPYING</filename>) if the layer is to be | ||
| 1554 | distributed, a <filename>README</filename> file as good practice | ||
| 1555 | and especially if the layer is to be distributed, a | ||
| 1556 | configuration directory, and recipe directories. | ||
| 1557 | </para> | ||
| 1558 | |||
| 1559 | <para> | ||
| 1560 | The Yocto Project has many layers that can be used. | ||
| 1561 | You can see a web-interface listing of them on the | ||
| 1562 | <ulink url="http://git.yoctoproject.org/">Source Repositories</ulink> | ||
| 1563 | page. | ||
| 1564 | The layers are shown at the bottom categorized under | ||
| 1565 | "Yocto Metadata Layers." | ||
| 1566 | These layers are fundamentally a subset of the | ||
| 1567 | <ulink url="http://layers.openembedded.org/layerindex/layers/">OpenEmbedded Metadata Index</ulink>, | ||
| 1568 | which lists all layers provided by the OpenEmbedded community. | ||
| 1569 | <note> | ||
| 1570 | Layers exist in the Yocto Project Source Repositories that | ||
| 1571 | cannot be found in the OpenEmbedded Metadata Index. | ||
| 1572 | These layers are either deprecated or experimental in nature. | ||
| 1573 | </note> | ||
| 1574 | </para> | ||
| 1575 | |||
| 1576 | <para> | ||
| 1577 | BitBake uses the <filename>conf/bblayers.conf</filename> file, | ||
| 1578 | which is part of the user configuration, to find what layers it | ||
| 1579 | should be using as part of the build. | ||
| 1580 | </para> | ||
| 1581 | |||
| 1582 | <para> | ||
| 1583 | For more information on layers, see the | ||
| 1584 | "<ulink url='&YOCTO_DOCS_DEV_URL;#understanding-and-creating-layers'>Understanding and Creating Layers</ulink>" | ||
| 1585 | section in the Yocto Project Development Tasks Manual. | ||
| 1586 | </para> | ||
| 1587 | |||
| 1588 | <section id="distro-layer"> | ||
| 1589 | <title>Distro Layer</title> | ||
| 1590 | |||
| 1591 | <para> | ||
| 1592 | The distribution layer provides policy configurations for your | ||
| 1593 | distribution. | ||
| 1594 | Best practices dictate that you isolate these types of | ||
| 1595 | configurations into their own layer. | ||
| 1596 | Settings you provide in | ||
| 1597 | <filename>conf/distro/<replaceable>distro</replaceable>.conf</filename> override | ||
| 1598 | similar | ||
| 1599 | settings that BitBake finds in your | ||
| 1600 | <filename>conf/local.conf</filename> file in the Build | ||
| 1601 | Directory. | ||
| 1602 | </para> | ||
| 1603 | |||
| 1604 | <para> | ||
| 1605 | The following list provides some explanation and references | ||
| 1606 | for what you typically find in the distribution layer: | ||
| 1607 | <itemizedlist> | ||
| 1608 | <listitem><para><emphasis>classes:</emphasis> | ||
| 1609 | Class files (<filename>.bbclass</filename>) hold | ||
| 1610 | common functionality that can be shared among | ||
| 1611 | recipes in the distribution. | ||
| 1612 | When your recipes inherit a class, they take on the | ||
| 1613 | settings and functions for that class. | ||
| 1614 | You can read more about class files in the | ||
| 1615 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes'>Classes</ulink>" | ||
| 1616 | section of the Yocto Reference Manual. | ||
| 1617 | </para></listitem> | ||
| 1618 | <listitem><para><emphasis>conf:</emphasis> | ||
| 1619 | This area holds configuration files for the | ||
| 1620 | layer (<filename>conf/layer.conf</filename>), | ||
| 1621 | the distribution | ||
| 1622 | (<filename>conf/distro/<replaceable>distro</replaceable>.conf</filename>), | ||
| 1623 | and any distribution-wide include files. | ||
| 1624 | </para></listitem> | ||
| 1625 | <listitem><para><emphasis>recipes-*:</emphasis> | ||
| 1626 | Recipes and append files that affect common | ||
| 1627 | functionality across the distribution. | ||
| 1628 | This area could include recipes and append files | ||
| 1629 | to add distribution-specific configuration, | ||
| 1630 | initialization scripts, custom image recipes, | ||
| 1631 | and so forth.</para></listitem> | ||
| 1632 | </itemizedlist> | ||
| 1633 | </para> | ||
| 1634 | </section> | ||
| 1635 | |||
| 1636 | <section id="bsp-layer"> | ||
| 1637 | <title>BSP Layer</title> | ||
| 1638 | |||
| 1639 | <para> | ||
| 1640 | The BSP Layer provides machine configurations. | ||
| 1641 | Everything in this layer is specific to the machine for which | ||
| 1642 | you are building the image or the SDK. | ||
| 1643 | A common structure or form is defined for BSP layers. | ||
| 1644 | You can learn more about this structure in the | ||
| 1645 | <ulink url='&YOCTO_DOCS_BSP_URL;'>Yocto Project Board Support Package (BSP) Developer's Guide</ulink>. | ||
| 1646 | <note> | ||
| 1647 | In order for a BSP layer to be considered compliant with the | ||
| 1648 | Yocto Project, it must meet some structural requirements. | ||
| 1649 | </note> | ||
| 1650 | </para> | ||
| 1651 | |||
| 1652 | <para> | ||
| 1653 | The BSP Layer's configuration directory contains | ||
| 1654 | configuration files for the machine | ||
| 1655 | (<filename>conf/machine/<replaceable>machine</replaceable>.conf</filename>) and, | ||
| 1656 | of course, the layer (<filename>conf/layer.conf</filename>). | ||
| 1657 | </para> | ||
| 1658 | |||
| 1659 | <para> | ||
| 1660 | The remainder of the layer is dedicated to specific recipes | ||
| 1661 | by function: <filename>recipes-bsp</filename>, | ||
| 1662 | <filename>recipes-core</filename>, | ||
| 1663 | <filename>recipes-graphics</filename>, and | ||
| 1664 | <filename>recipes-kernel</filename>. | ||
| 1665 | Metadata can exist for multiple formfactors, graphics | ||
| 1666 | support systems, and so forth. | ||
| 1667 | <note> | ||
| 1668 | While the figure shows several <filename>recipes-*</filename> | ||
| 1669 | directories, not all these directories appear in all | ||
| 1670 | BSP layers. | ||
| 1671 | </note> | ||
| 1672 | </para> | ||
| 1673 | </section> | ||
| 1674 | |||
| 1675 | <section id="software-layer"> | ||
| 1676 | <title>Software Layer</title> | ||
| 1677 | |||
| 1678 | <para> | ||
| 1679 | The software layer provides the Metadata for additional | ||
| 1680 | software packages used during the build. | ||
| 1681 | This layer does not include Metadata that is specific to the | ||
| 1682 | distribution or the machine, which are found in their | ||
| 1683 | respective layers. | ||
| 1684 | </para> | ||
| 1685 | |||
| 1686 | <para> | ||
| 1687 | This layer contains any new recipes that your project needs | ||
| 1688 | in the form of recipe files. | ||
| 1689 | </para> | ||
| 1690 | </section> | ||
| 1691 | </section> | ||
| 1692 | |||
| 1693 | <section id="sources-dev-environment"> | ||
| 1694 | <title>Sources</title> | ||
| 1695 | |||
| 1696 | <para> | ||
| 1697 | In order for the OpenEmbedded build system to create an image or | ||
| 1698 | any target, it must be able to access source files. | ||
| 1699 | The | ||
| 1700 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> | ||
| 1701 | represents source files using the "Upstream Project Releases", | ||
| 1702 | "Local Projects", and "SCMs (optional)" boxes. | ||
| 1703 | The figure represents mirrors, which also play a role in locating | ||
| 1704 | source files, with the "Source Mirror(s)" box. | ||
| 1705 | </para> | ||
| 1706 | |||
| 1707 | <para> | ||
| 1708 | The method by which source files are ultimately organized is | ||
| 1709 | a function of the project. | ||
| 1710 | For example, for released software, projects tend to use tarballs | ||
| 1711 | or other archived files that can capture the state of a release | ||
| 1712 | guaranteeing that it is statically represented. | ||
| 1713 | On the other hand, for a project that is more dynamic or | ||
| 1714 | experimental in nature, a project might keep source files in a | ||
| 1715 | repository controlled by a Source Control Manager (SCM) such as | ||
| 1716 | Git. | ||
| 1717 | Pulling source from a repository allows you to control | ||
| 1718 | the point in the repository (the revision) from which you want to | ||
| 1719 | build software. | ||
| 1720 | Finally, a combination of the two might exist, which would give the | ||
| 1721 | consumer a choice when deciding where to get source files. | ||
| 1722 | </para> | ||
| 1723 | |||
| 1724 | <para> | ||
| 1725 | BitBake uses the | ||
| 1726 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | ||
| 1727 | variable to point to source files regardless of their location. | ||
| 1728 | Each recipe must have a <filename>SRC_URI</filename> variable | ||
| 1729 | that points to the source. | ||
| 1730 | </para> | ||
| 1731 | |||
| 1732 | <para> | ||
| 1733 | Another area that plays a significant role in where source files | ||
| 1734 | come from is pointed to by the | ||
| 1735 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> | ||
| 1736 | variable. | ||
| 1737 | This area is a cache that can hold previously downloaded source. | ||
| 1738 | You can also instruct the OpenEmbedded build system to create | ||
| 1739 | tarballs from Git repositories, which is not the default behavior, | ||
| 1740 | and store them in the <filename>DL_DIR</filename> by using the | ||
| 1741 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> | ||
| 1742 | variable. | ||
| 1743 | </para> | ||
| 1744 | |||
| 1745 | <para> | ||
| 1746 | Judicious use of a <filename>DL_DIR</filename> directory can | ||
| 1747 | save the build system a trip across the Internet when looking | ||
| 1748 | for files. | ||
| 1749 | A good method for using a download directory is to have | ||
| 1750 | <filename>DL_DIR</filename> point to an area outside of your | ||
| 1751 | Build Directory. | ||
| 1752 | Doing so allows you to safely delete the Build Directory | ||
| 1753 | if needed without fear of removing any downloaded source file. | ||
| 1754 | </para> | ||
| 1755 | |||
| 1756 | <para> | ||
| 1757 | The remainder of this section provides a deeper look into the | ||
| 1758 | source files and the mirrors. | ||
| 1759 | Here is a more detailed look at the source file area of the | ||
| 1760 | base figure: | ||
| 1761 | <imagedata fileref="figures/source-input.png" align="center" width="7in" depth="7.5in" /> | ||
| 1762 | </para> | ||
| 1763 | |||
| 1764 | <section id='upstream-project-releases'> | ||
| 1765 | <title>Upstream Project Releases</title> | ||
| 1766 | |||
| 1767 | <para> | ||
| 1768 | Upstream project releases exist anywhere in the form of an | ||
| 1769 | archived file (e.g. tarball or zip file). | ||
| 1770 | These files correspond to individual recipes. | ||
| 1771 | For example, the figure uses specific releases each for | ||
| 1772 | BusyBox, Qt, and Dbus. | ||
| 1773 | An archive file can be for any released product that can be | ||
| 1774 | built using a recipe. | ||
| 1775 | </para> | ||
| 1776 | </section> | ||
| 1777 | |||
| 1778 | <section id='local-projects'> | ||
| 1779 | <title>Local Projects</title> | ||
| 1780 | |||
| 1781 | <para> | ||
| 1782 | Local projects are custom bits of software the user provides. | ||
| 1783 | These bits reside somewhere local to a project - perhaps | ||
| 1784 | a directory into which the user checks in items (e.g. | ||
| 1785 | a local directory containing a development source tree | ||
| 1786 | used by the group). | ||
| 1787 | </para> | ||
| 1788 | |||
| 1789 | <para> | ||
| 1790 | The canonical method through which to include a local project | ||
| 1791 | is to use the | ||
| 1792 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc</filename></ulink> | ||
| 1793 | class to include that local project. | ||
| 1794 | You use either the <filename>local.conf</filename> or a | ||
| 1795 | recipe's append file to override or set the | ||
| 1796 | recipe to point to the local directory on your disk to pull | ||
| 1797 | in the whole source tree. | ||
| 1798 | </para> | ||
| 1799 | |||
| 1800 | <para> | ||
| 1801 | For information on how to use the | ||
| 1802 | <filename>externalsrc</filename> class, see the | ||
| 1803 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-externalsrc'><filename>externalsrc.bbclass</filename></ulink>" | ||
| 1804 | section. | ||
| 1805 | </para> | ||
| 1806 | </section> | ||
| 1807 | |||
| 1808 | <section id='scms'> | ||
| 1809 | <title>Source Control Managers (Optional)</title> | ||
| 1810 | |||
| 1811 | <para> | ||
| 1812 | Another place the build system can get source files from is | ||
| 1813 | through an SCM such as Git or Subversion. | ||
| 1814 | In this case, a repository is cloned or checked out. | ||
| 1815 | The | ||
| 1816 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> | ||
| 1817 | task inside BitBake uses | ||
| 1818 | the <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | ||
| 1819 | variable and the argument's prefix to determine the correct | ||
| 1820 | fetcher module. | ||
| 1821 | </para> | ||
| 1822 | |||
| 1823 | <note> | ||
| 1824 | For information on how to have the OpenEmbedded build system | ||
| 1825 | generate tarballs for Git repositories and place them in the | ||
| 1826 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> | ||
| 1827 | directory, see the | ||
| 1828 | <ulink url='&YOCTO_DOCS_REF_URL;#var-BB_GENERATE_MIRROR_TARBALLS'><filename>BB_GENERATE_MIRROR_TARBALLS</filename></ulink> | ||
| 1829 | variable. | ||
| 1830 | </note> | ||
| 1831 | |||
| 1832 | <para> | ||
| 1833 | When fetching a repository, BitBake uses the | ||
| 1834 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRCREV'><filename>SRCREV</filename></ulink> | ||
| 1835 | variable to determine the specific revision from which to | ||
| 1836 | build. | ||
| 1837 | </para> | ||
| 1838 | </section> | ||
| 1839 | |||
| 1840 | <section id='source-mirrors'> | ||
| 1841 | <title>Source Mirror(s)</title> | ||
| 1842 | |||
| 1843 | <para> | ||
| 1844 | Two kinds of mirrors exist: pre-mirrors and regular mirrors. | ||
| 1845 | The | ||
| 1846 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PREMIRRORS'><filename>PREMIRRORS</filename></ulink> | ||
| 1847 | and | ||
| 1848 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MIRRORS'><filename>MIRRORS</filename></ulink> | ||
| 1849 | variables point to these, respectively. | ||
| 1850 | BitBake checks pre-mirrors before looking upstream for any | ||
| 1851 | source files. | ||
| 1852 | Pre-mirrors are appropriate when you have a shared directory | ||
| 1853 | that is not a directory defined by the | ||
| 1854 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DL_DIR'><filename>DL_DIR</filename></ulink> | ||
| 1855 | variable. | ||
| 1856 | A Pre-mirror typically points to a shared directory that is | ||
| 1857 | local to your organization. | ||
| 1858 | </para> | ||
| 1859 | |||
| 1860 | <para> | ||
| 1861 | Regular mirrors can be any site across the Internet that is | ||
| 1862 | used as an alternative location for source code should the | ||
| 1863 | primary site not be functioning for some reason or another. | ||
| 1864 | </para> | ||
| 1865 | </section> | ||
| 1866 | </section> | ||
| 1867 | |||
| 1868 | <section id="package-feeds-dev-environment"> | ||
| 1869 | <title>Package Feeds</title> | ||
| 1870 | |||
| 1871 | <para> | ||
| 1872 | When the OpenEmbedded build system generates an image or an SDK, | ||
| 1873 | it gets the packages from a package feed area located in the | ||
| 1874 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>. | ||
| 1875 | The | ||
| 1876 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> | ||
| 1877 | shows this package feeds area in the upper-right corner. | ||
| 1878 | </para> | ||
| 1879 | |||
| 1880 | <para> | ||
| 1881 | This section looks a little closer into the package feeds area used | ||
| 1882 | by the build system. | ||
| 1883 | Here is a more detailed look at the area: | ||
| 1884 | <imagedata fileref="figures/package-feeds.png" align="center" width="7in" depth="6in" /> | ||
| 1885 | </para> | ||
| 1886 | |||
| 1887 | <para> | ||
| 1888 | Package feeds are an intermediary step in the build process. | ||
| 1889 | The OpenEmbedded build system provides classes to generate | ||
| 1890 | different package types, and you specify which classes to enable | ||
| 1891 | through the | ||
| 1892 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink> | ||
| 1893 | variable. | ||
| 1894 | Before placing the packages into package feeds, | ||
| 1895 | the build process validates them with generated output quality | ||
| 1896 | assurance checks through the | ||
| 1897 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-insane'><filename>insane</filename></ulink> | ||
| 1898 | class. | ||
| 1899 | </para> | ||
| 1900 | |||
| 1901 | <para> | ||
| 1902 | The package feed area resides in the Build Directory. | ||
| 1903 | The directory the build system uses to temporarily store packages | ||
| 1904 | is determined by a combination of variables and the particular | ||
| 1905 | package manager in use. | ||
| 1906 | See the "Package Feeds" box in the illustration and note the | ||
| 1907 | information to the right of that area. | ||
| 1908 | In particular, the following defines where package files are | ||
| 1909 | kept: | ||
| 1910 | <itemizedlist> | ||
| 1911 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>: | ||
| 1912 | Defined as <filename>tmp/deploy</filename> in the Build | ||
| 1913 | Directory. | ||
| 1914 | </para></listitem> | ||
| 1915 | <listitem><para><filename>DEPLOY_DIR_*</filename>: | ||
| 1916 | Depending on the package manager used, the package type | ||
| 1917 | sub-folder. | ||
| 1918 | Given RPM, IPK, or DEB packaging and tarball creation, the | ||
| 1919 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_RPM'><filename>DEPLOY_DIR_RPM</filename></ulink>, | ||
| 1920 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IPK'><filename>DEPLOY_DIR_IPK</filename></ulink>, | ||
| 1921 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_DEB'><filename>DEPLOY_DIR_DEB</filename></ulink>, | ||
| 1922 | or | ||
| 1923 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_TAR'><filename>DEPLOY_DIR_TAR</filename></ulink>, | ||
| 1924 | variables are used, respectively. | ||
| 1925 | </para></listitem> | ||
| 1926 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink>: | ||
| 1927 | Defines architecture-specific sub-folders. | ||
| 1928 | For example, packages could exist for the i586 or qemux86 | ||
| 1929 | architectures. | ||
| 1930 | </para></listitem> | ||
| 1931 | </itemizedlist> | ||
| 1932 | </para> | ||
| 1933 | |||
| 1934 | <para> | ||
| 1935 | BitBake uses the <filename>do_package_write_*</filename> tasks to | ||
| 1936 | generate packages and place them into the package holding area (e.g. | ||
| 1937 | <filename>do_package_write_ipk</filename> for IPK packages). | ||
| 1938 | See the | ||
| 1939 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_deb'><filename>do_package_write_deb</filename></ulink>", | ||
| 1940 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_ipk'><filename>do_package_write_ipk</filename></ulink>", | ||
| 1941 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_rpm'><filename>do_package_write_rpm</filename></ulink>", | ||
| 1942 | and | ||
| 1943 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package_write_tar'><filename>do_package_write_tar</filename></ulink>" | ||
| 1944 | sections for additional information. | ||
| 1945 | As an example, consider a scenario where an IPK packaging manager | ||
| 1946 | is being used and package architecture support for both i586 | ||
| 1947 | and qemux86 exist. | ||
| 1948 | Packages for the i586 architecture are placed in | ||
| 1949 | <filename>build/tmp/deploy/ipk/i586</filename>, while packages for | ||
| 1950 | the qemux86 architecture are placed in | ||
| 1951 | <filename>build/tmp/deploy/ipk/qemux86</filename>. | ||
| 1952 | </para> | ||
| 1953 | </section> | ||
| 1954 | |||
| 1955 | <section id='bitbake-dev-environment'> | ||
| 1956 | <title>BitBake</title> | ||
| 1957 | |||
| 1958 | <para> | ||
| 1959 | The OpenEmbedded build system uses | ||
| 1960 | <ulink url='&YOCTO_DOCS_REF_URL;#bitbake-term'>BitBake</ulink> | ||
| 1961 | to produce images. | ||
| 1962 | You can see from the | ||
| 1963 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, | ||
| 1964 | the BitBake area consists of several functional areas. | ||
| 1965 | This section takes a closer look at each of those areas. | ||
| 1966 | </para> | ||
| 1967 | |||
| 1968 | <para> | ||
| 1969 | Separate documentation exists for the BitBake tool. | ||
| 1970 | See the | ||
| 1971 | <ulink url='&YOCTO_DOCS_BB_URL;#bitbake-user-manual'>BitBake User Manual</ulink> | ||
| 1972 | for reference material on BitBake. | ||
| 1973 | </para> | ||
| 1974 | |||
| 1975 | <section id='source-fetching-dev-environment'> | ||
| 1976 | <title>Source Fetching</title> | ||
| 1977 | |||
| 1978 | <para> | ||
| 1979 | The first stages of building a recipe are to fetch and unpack | ||
| 1980 | the source code: | ||
| 1981 | <imagedata fileref="figures/source-fetching.png" align="center" width="6.5in" depth="5in" /> | ||
| 1982 | </para> | ||
| 1983 | |||
| 1984 | <para> | ||
| 1985 | The | ||
| 1986 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-fetch'><filename>do_fetch</filename></ulink> | ||
| 1987 | and | ||
| 1988 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> | ||
| 1989 | tasks fetch the source files and unpack them into the work | ||
| 1990 | directory. | ||
| 1991 | <note> | ||
| 1992 | For every local file (e.g. <filename>file://</filename>) | ||
| 1993 | that is part of a recipe's | ||
| 1994 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | ||
| 1995 | statement, the OpenEmbedded build system takes a checksum | ||
| 1996 | of the file for the recipe and inserts the checksum into | ||
| 1997 | the signature for the <filename>do_fetch</filename>. | ||
| 1998 | If any local file has been modified, the | ||
| 1999 | <filename>do_fetch</filename> task and all tasks that | ||
| 2000 | depend on it are re-executed. | ||
| 2001 | </note> | ||
| 2002 | By default, everything is accomplished in the | ||
| 2003 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink>, | ||
| 2004 | which has a defined structure. | ||
| 2005 | For additional general information on the Build Directory, | ||
| 2006 | see the | ||
| 2007 | "<ulink url='&YOCTO_DOCS_REF_URL;#structure-core-build'><filename>build/</filename></ulink>" | ||
| 2008 | section in the Yocto Project Reference Manual. | ||
| 2009 | </para> | ||
| 2010 | |||
| 2011 | <para> | ||
| 2012 | Unpacked source files are pointed to by the | ||
| 2013 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> | ||
| 2014 | variable. | ||
| 2015 | Each recipe has an area in the Build Directory where the | ||
| 2016 | unpacked source code resides. | ||
| 2017 | The name of that directory for any given recipe is defined from | ||
| 2018 | several different variables. | ||
| 2019 | You can see the variables that define these directories | ||
| 2020 | by looking at the figure: | ||
| 2021 | <itemizedlist> | ||
| 2022 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> - | ||
| 2023 | The base directory where the OpenEmbedded build system | ||
| 2024 | performs all its work during the build. | ||
| 2025 | </para></listitem> | ||
| 2026 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_ARCH'><filename>PACKAGE_ARCH</filename></ulink> - | ||
| 2027 | The architecture of the built package or packages. | ||
| 2028 | </para></listitem> | ||
| 2029 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-TARGET_OS'><filename>TARGET_OS</filename></ulink> - | ||
| 2030 | The operating system of the target device. | ||
| 2031 | </para></listitem> | ||
| 2032 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PN'><filename>PN</filename></ulink> - | ||
| 2033 | The name of the built package. | ||
| 2034 | </para></listitem> | ||
| 2035 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PV'><filename>PV</filename></ulink> - | ||
| 2036 | The version of the recipe used to build the package. | ||
| 2037 | </para></listitem> | ||
| 2038 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PR'><filename>PR</filename></ulink> - | ||
| 2039 | The revision of the recipe used to build the package. | ||
| 2040 | </para></listitem> | ||
| 2041 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink> - | ||
| 2042 | The location within <filename>TMPDIR</filename> where | ||
| 2043 | a specific package is built. | ||
| 2044 | </para></listitem> | ||
| 2045 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> - | ||
| 2046 | Contains the unpacked source files for a given recipe. | ||
| 2047 | </para></listitem> | ||
| 2048 | </itemizedlist> | ||
| 2049 | </para> | ||
| 2050 | </section> | ||
| 2051 | |||
| 2052 | <section id='patching-dev-environment'> | ||
| 2053 | <title>Patching</title> | ||
| 2054 | |||
| 2055 | <para> | ||
| 2056 | Once source code is fetched and unpacked, BitBake locates | ||
| 2057 | patch files and applies them to the source files: | ||
| 2058 | <imagedata fileref="figures/patching.png" align="center" width="6in" depth="5in" /> | ||
| 2059 | </para> | ||
| 2060 | |||
| 2061 | <para> | ||
| 2062 | The | ||
| 2063 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> | ||
| 2064 | task processes recipes by | ||
| 2065 | using the | ||
| 2066 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SRC_URI'><filename>SRC_URI</filename></ulink> | ||
| 2067 | variable to locate applicable patch files, which by default | ||
| 2068 | are <filename>*.patch</filename> or | ||
| 2069 | <filename>*.diff</filename> files, or any file if | ||
| 2070 | "apply=yes" is specified for the file in | ||
| 2071 | <filename>SRC_URI</filename>. | ||
| 2072 | </para> | ||
| 2073 | |||
| 2074 | <para> | ||
| 2075 | BitBake finds and applies multiple patches for a single recipe | ||
| 2076 | in the order in which it finds the patches. | ||
| 2077 | Patches are applied to the recipe's source files located in the | ||
| 2078 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> | ||
| 2079 | directory. | ||
| 2080 | </para> | ||
| 2081 | |||
| 2082 | <para> | ||
| 2083 | For more information on how the source directories are | ||
| 2084 | created, see the | ||
| 2085 | "<link linkend='source-fetching-dev-environment'>Source Fetching</link>" | ||
| 2086 | section. | ||
| 2087 | </para> | ||
| 2088 | </section> | ||
| 2089 | |||
| 2090 | <section id='configuration-and-compilation-dev-environment'> | ||
| 2091 | <title>Configuration and Compilation</title> | ||
| 2092 | |||
| 2093 | <para> | ||
| 2094 | After source code is patched, BitBake executes tasks that | ||
| 2095 | configure and compile the source code: | ||
| 2096 | <imagedata fileref="figures/configuration-compile-autoreconf.png" align="center" width="7in" depth="5in" /> | ||
| 2097 | </para> | ||
| 2098 | |||
| 2099 | <para> | ||
| 2100 | This step in the build process consists of three tasks: | ||
| 2101 | <itemizedlist> | ||
| 2102 | <listitem><para> | ||
| 2103 | <emphasis><ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-prepare_recipe_sysroot'><filename>do_prepare_recipe_sysroot</filename></ulink>:</emphasis> | ||
| 2104 | This task sets up the two sysroots in | ||
| 2105 | <filename>${</filename><ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink><filename>}</filename> | ||
| 2106 | (i.e. <filename>recipe-sysroot</filename> and | ||
| 2107 | <filename>recipe-sysroot-native</filename>) so that | ||
| 2108 | the sysroots contain the contents of the | ||
| 2109 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink> | ||
| 2110 | tasks of the recipes on which the recipe | ||
| 2111 | containing the tasks depends. | ||
| 2112 | A sysroot exists for both the target and for the native | ||
| 2113 | binaries, which run on the host system. | ||
| 2114 | </para></listitem> | ||
| 2115 | <listitem><para><emphasis><filename>do_configure</filename>:</emphasis> | ||
| 2116 | This task configures the source by enabling and | ||
| 2117 | disabling any build-time and configuration options for | ||
| 2118 | the software being built. | ||
| 2119 | Configurations can come from the recipe itself as well | ||
| 2120 | as from an inherited class. | ||
| 2121 | Additionally, the software itself might configure itself | ||
| 2122 | depending on the target for which it is being built. | ||
| 2123 | </para> | ||
| 2124 | |||
| 2125 | <para>The configurations handled by the | ||
| 2126 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-configure'><filename>do_configure</filename></ulink> | ||
| 2127 | task are specific | ||
| 2128 | to source code configuration for the source code | ||
| 2129 | being built by the recipe.</para> | ||
| 2130 | |||
| 2131 | <para>If you are using the | ||
| 2132 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-autotools'><filename>autotools</filename></ulink> | ||
| 2133 | class, | ||
| 2134 | you can add additional configuration options by using | ||
| 2135 | the | ||
| 2136 | <ulink url='&YOCTO_DOCS_REF_URL;#var-EXTRA_OECONF'><filename>EXTRA_OECONF</filename></ulink> | ||
| 2137 | or | ||
| 2138 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGECONFIG_CONFARGS'><filename>PACKAGECONFIG_CONFARGS</filename></ulink> | ||
| 2139 | variables. | ||
| 2140 | For information on how this variable works within | ||
| 2141 | that class, see the | ||
| 2142 | <filename>meta/classes/autotools.bbclass</filename> file. | ||
| 2143 | </para></listitem> | ||
| 2144 | <listitem><para><emphasis><filename>do_compile</filename>:</emphasis> | ||
| 2145 | Once a configuration task has been satisfied, BitBake | ||
| 2146 | compiles the source using the | ||
| 2147 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-compile'><filename>do_compile</filename></ulink> | ||
| 2148 | task. | ||
| 2149 | Compilation occurs in the directory pointed to by the | ||
| 2150 | <ulink url='&YOCTO_DOCS_REF_URL;#var-B'><filename>B</filename></ulink> | ||
| 2151 | variable. | ||
| 2152 | Realize that the <filename>B</filename> directory is, by | ||
| 2153 | default, the same as the | ||
| 2154 | <ulink url='&YOCTO_DOCS_REF_URL;#var-S'><filename>S</filename></ulink> | ||
| 2155 | directory.</para></listitem> | ||
| 2156 | <listitem><para><emphasis><filename>do_install</filename>:</emphasis> | ||
| 2157 | Once compilation is done, BitBake executes the | ||
| 2158 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-install'><filename>do_install</filename></ulink> | ||
| 2159 | task. | ||
| 2160 | This task copies files from the <filename>B</filename> | ||
| 2161 | directory and places them in a holding area pointed to | ||
| 2162 | by the | ||
| 2163 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> | ||
| 2164 | variable.</para></listitem> | ||
| 2165 | </itemizedlist> | ||
| 2166 | </para> | ||
| 2167 | </section> | ||
| 2168 | |||
| 2169 | <section id='package-splitting-dev-environment'> | ||
| 2170 | <title>Package Splitting</title> | ||
| 2171 | |||
| 2172 | <para> | ||
| 2173 | After source code is configured and compiled, the | ||
| 2174 | OpenEmbedded build system analyzes | ||
| 2175 | the results and splits the output into packages: | ||
| 2176 | <imagedata fileref="figures/analysis-for-package-splitting.png" align="center" width="7in" depth="7in" /> | ||
| 2177 | </para> | ||
| 2178 | |||
| 2179 | <para> | ||
| 2180 | The | ||
| 2181 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink> | ||
| 2182 | and | ||
| 2183 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink> | ||
| 2184 | tasks combine to analyze | ||
| 2185 | the files found in the | ||
| 2186 | <ulink url='&YOCTO_DOCS_REF_URL;#var-D'><filename>D</filename></ulink> directory | ||
| 2187 | and split them into subsets based on available packages and | ||
| 2188 | files. | ||
| 2189 | The analyzing process involves the following as well as other | ||
| 2190 | items: splitting out debugging symbols, | ||
| 2191 | looking at shared library dependencies between packages, | ||
| 2192 | and looking at package relationships. | ||
| 2193 | The <filename>do_packagedata</filename> task creates package | ||
| 2194 | metadata based on the analysis such that the | ||
| 2195 | OpenEmbedded build system can generate the final packages. | ||
| 2196 | Working, staged, and intermediate results of the analysis | ||
| 2197 | and package splitting process use these areas: | ||
| 2198 | <itemizedlist> | ||
| 2199 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PKGD'><filename>PKGD</filename></ulink> - | ||
| 2200 | The destination directory for packages before they are | ||
| 2201 | split. | ||
| 2202 | </para></listitem> | ||
| 2203 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDATA_DIR'><filename>PKGDATA_DIR</filename></ulink> - | ||
| 2204 | A shared, global-state directory that holds data | ||
| 2205 | generated during the packaging process. | ||
| 2206 | </para></listitem> | ||
| 2207 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDESTWORK'><filename>PKGDESTWORK</filename></ulink> - | ||
| 2208 | A temporary work area used by the | ||
| 2209 | <filename>do_package</filename> task. | ||
| 2210 | </para></listitem> | ||
| 2211 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PKGDEST'><filename>PKGDEST</filename></ulink> - | ||
| 2212 | The parent directory for packages after they have | ||
| 2213 | been split. | ||
| 2214 | </para></listitem> | ||
| 2215 | </itemizedlist> | ||
| 2216 | The <ulink url='&YOCTO_DOCS_REF_URL;#var-FILES'><filename>FILES</filename></ulink> | ||
| 2217 | variable defines the files that go into each package in | ||
| 2218 | <ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGES'><filename>PACKAGES</filename></ulink>. | ||
| 2219 | If you want details on how this is accomplished, you can | ||
| 2220 | look at the | ||
| 2221 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-package'><filename>package</filename></ulink> | ||
| 2222 | class. | ||
| 2223 | </para> | ||
| 2224 | |||
| 2225 | <para> | ||
| 2226 | Depending on the type of packages being created (RPM, DEB, or | ||
| 2227 | IPK), the <filename>do_package_write_*</filename> task | ||
| 2228 | creates the actual packages and places them in the | ||
| 2229 | Package Feed area, which is | ||
| 2230 | <filename>${TMPDIR}/deploy</filename>. | ||
| 2231 | You can see the | ||
| 2232 | "<link linkend='package-feeds-dev-environment'>Package Feeds</link>" | ||
| 2233 | section for more detail on that part of the build process. | ||
| 2234 | <note> | ||
| 2235 | Support for creating feeds directly from the | ||
| 2236 | <filename>deploy/*</filename> directories does not exist. | ||
| 2237 | Creating such feeds usually requires some kind of feed | ||
| 2238 | maintenance mechanism that would upload the new packages | ||
| 2239 | into an official package feed (e.g. the | ||
| 2240 | Ångström distribution). | ||
| 2241 | This functionality is highly distribution-specific | ||
| 2242 | and thus is not provided out of the box. | ||
| 2243 | </note> | ||
| 2244 | </para> | ||
| 2245 | </section> | ||
| 2246 | |||
| 2247 | <section id='image-generation-dev-environment'> | ||
| 2248 | <title>Image Generation</title> | ||
| 2249 | |||
| 2250 | <para> | ||
| 2251 | Once packages are split and stored in the Package Feeds area, | ||
| 2252 | the OpenEmbedded build system uses BitBake to generate the | ||
| 2253 | root filesystem image: | ||
| 2254 | <imagedata fileref="figures/image-generation.png" align="center" width="6in" depth="7in" /> | ||
| 2255 | </para> | ||
| 2256 | |||
| 2257 | <para> | ||
| 2258 | The image generation process consists of several stages and | ||
| 2259 | depends on several tasks and variables. | ||
| 2260 | The | ||
| 2261 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-rootfs'><filename>do_rootfs</filename></ulink> | ||
| 2262 | task creates the root filesystem (file and directory structure) | ||
| 2263 | for an image. | ||
| 2264 | This task uses several key variables to help create the list | ||
| 2265 | of packages to actually install: | ||
| 2266 | <itemizedlist> | ||
| 2267 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_INSTALL'><filename>IMAGE_INSTALL</filename></ulink>: | ||
| 2268 | Lists out the base set of packages to install from | ||
| 2269 | the Package Feeds area.</para></listitem> | ||
| 2270 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_EXCLUDE'><filename>PACKAGE_EXCLUDE</filename></ulink>: | ||
| 2271 | Specifies packages that should not be installed. | ||
| 2272 | </para></listitem> | ||
| 2273 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FEATURES'><filename>IMAGE_FEATURES</filename></ulink>: | ||
| 2274 | Specifies features to include in the image. | ||
| 2275 | Most of these features map to additional packages for | ||
| 2276 | installation.</para></listitem> | ||
| 2277 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_CLASSES'><filename>PACKAGE_CLASSES</filename></ulink>: | ||
| 2278 | Specifies the package backend to use and consequently | ||
| 2279 | helps determine where to locate packages within the | ||
| 2280 | Package Feeds area.</para></listitem> | ||
| 2281 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_LINGUAS'><filename>IMAGE_LINGUAS</filename></ulink>: | ||
| 2282 | Determines the language(s) for which additional | ||
| 2283 | language support packages are installed. | ||
| 2284 | </para></listitem> | ||
| 2285 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-PACKAGE_INSTALL'><filename>PACKAGE_INSTALL</filename></ulink>: | ||
| 2286 | The final list of packages passed to the package manager | ||
| 2287 | for installation into the image. | ||
| 2288 | </para></listitem> | ||
| 2289 | </itemizedlist> | ||
| 2290 | </para> | ||
| 2291 | |||
| 2292 | <para> | ||
| 2293 | With | ||
| 2294 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_ROOTFS'><filename>IMAGE_ROOTFS</filename></ulink> | ||
| 2295 | pointing to the location of the filesystem under construction and | ||
| 2296 | the <filename>PACKAGE_INSTALL</filename> variable providing the | ||
| 2297 | final list of packages to install, the root file system is | ||
| 2298 | created. | ||
| 2299 | </para> | ||
| 2300 | |||
| 2301 | <para> | ||
| 2302 | Package installation is under control of the package manager | ||
| 2303 | (e.g. dnf/rpm, opkg, or apt/dpkg) regardless of whether or | ||
| 2304 | not package management is enabled for the target. | ||
| 2305 | At the end of the process, if package management is not | ||
| 2306 | enabled for the target, the package manager's data files | ||
| 2307 | are deleted from the root filesystem. | ||
| 2308 | As part of the final stage of package installation, postinstall | ||
| 2309 | scripts that are part of the packages are run. | ||
| 2310 | Any scripts that fail to run | ||
| 2311 | on the build host are run on the target when the target system | ||
| 2312 | is first booted. | ||
| 2313 | If you are using a | ||
| 2314 | <ulink url='&YOCTO_DOCS_DEV_URL;#creating-a-read-only-root-filesystem'>read-only root filesystem</ulink>, | ||
| 2315 | all the post installation scripts must succeed during the | ||
| 2316 | package installation phase since the root filesystem is | ||
| 2317 | read-only. | ||
| 2318 | </para> | ||
| 2319 | |||
| 2320 | <para> | ||
| 2321 | The final stages of the <filename>do_rootfs</filename> task | ||
| 2322 | handle post processing. | ||
| 2323 | Post processing includes creation of a manifest file and | ||
| 2324 | optimizations. | ||
| 2325 | </para> | ||
| 2326 | |||
| 2327 | <para> | ||
| 2328 | The manifest file (<filename>.manifest</filename>) resides | ||
| 2329 | in the same directory as the root filesystem image. | ||
| 2330 | This file lists out, line-by-line, the installed packages. | ||
| 2331 | The manifest file is useful for the | ||
| 2332 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-classes-testimage*'><filename>testimage</filename></ulink> | ||
| 2333 | class, for example, to determine whether or not to run | ||
| 2334 | specific tests. | ||
| 2335 | See the | ||
| 2336 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_MANIFEST'><filename>IMAGE_MANIFEST</filename></ulink> | ||
| 2337 | variable for additional information. | ||
| 2338 | </para> | ||
| 2339 | |||
| 2340 | <para> | ||
| 2341 | Optimizing processes run across the image include | ||
| 2342 | <filename>mklibs</filename>, <filename>prelink</filename>, | ||
| 2343 | and any other post-processing commands as defined by the | ||
| 2344 | <ulink url='&YOCTO_DOCS_REF_URL;#var-ROOTFS_POSTPROCESS_COMMAND'><filename>ROOTFS_POSTPROCESS_COMMAND</filename></ulink> | ||
| 2345 | variable. | ||
| 2346 | The <filename>mklibs</filename> process optimizes the size | ||
| 2347 | of the libraries, while the | ||
| 2348 | <filename>prelink</filename> process optimizes the dynamic | ||
| 2349 | linking of shared libraries to reduce start up time of | ||
| 2350 | executables. | ||
| 2351 | </para> | ||
| 2352 | |||
| 2353 | <para> | ||
| 2354 | After the root filesystem is built, processing begins on | ||
| 2355 | the image through the | ||
| 2356 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image'><filename>do_image</filename></ulink> | ||
| 2357 | task. | ||
| 2358 | The build system runs any pre-processing commands as defined | ||
| 2359 | by the | ||
| 2360 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_PREPROCESS_COMMAND'><filename>IMAGE_PREPROCESS_COMMAND</filename></ulink> | ||
| 2361 | variable. | ||
| 2362 | This variable specifies a list of functions to call before | ||
| 2363 | the OpenEmbedded build system creates the final image output | ||
| 2364 | files. | ||
| 2365 | </para> | ||
| 2366 | |||
| 2367 | <para> | ||
| 2368 | The OpenEmbedded build system dynamically creates | ||
| 2369 | <filename>do_image_*</filename> tasks as needed, based | ||
| 2370 | on the image types specified in the | ||
| 2371 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> | ||
| 2372 | variable. | ||
| 2373 | The process turns everything into an image file or a set of | ||
| 2374 | image files and compresses the root filesystem image to reduce | ||
| 2375 | the overall size of the image. | ||
| 2376 | The formats used for the root filesystem depend on the | ||
| 2377 | <filename>IMAGE_FSTYPES</filename> variable. | ||
| 2378 | </para> | ||
| 2379 | |||
| 2380 | <para> | ||
| 2381 | As an example, a dynamically created task when creating a | ||
| 2382 | particular image <replaceable>type</replaceable> would take the | ||
| 2383 | following form: | ||
| 2384 | <literallayout class='monospaced'> | ||
| 2385 | do_image_<replaceable>type</replaceable>[depends] | ||
| 2386 | </literallayout> | ||
| 2387 | So, if the <replaceable>type</replaceable> as specified by the | ||
| 2388 | <filename>IMAGE_FSTYPES</filename> were | ||
| 2389 | <filename>ext4</filename>, the dynamically generated task | ||
| 2390 | would be as follows: | ||
| 2391 | <literallayout class='monospaced'> | ||
| 2392 | do_image_ext4[depends] | ||
| 2393 | </literallayout> | ||
| 2394 | </para> | ||
| 2395 | |||
| 2396 | <para> | ||
| 2397 | The final task involved in image creation is the | ||
| 2398 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-image-complete'><filename>do_image_complete</filename></ulink> | ||
| 2399 | task. | ||
| 2400 | This task completes the image by applying any image | ||
| 2401 | post processing as defined through the | ||
| 2402 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_POSTPROCESS_COMMAND'><filename>IMAGE_POSTPROCESS_COMMAND</filename></ulink> | ||
| 2403 | variable. | ||
| 2404 | The variable specifies a list of functions to call once the | ||
| 2405 | OpenEmbedded build system has created the final image output | ||
| 2406 | files. | ||
| 2407 | </para> | ||
| 2408 | |||
| 2409 | <note> | ||
| 2410 | The entire image generation process is run under Pseudo. | ||
| 2411 | Running under Pseudo ensures that the files in the root | ||
| 2412 | filesystem have correct ownership. | ||
| 2413 | </note> | ||
| 2414 | </section> | ||
| 2415 | |||
| 2416 | <section id='sdk-generation-dev-environment'> | ||
| 2417 | <title>SDK Generation</title> | ||
| 2418 | |||
| 2419 | <para> | ||
| 2420 | The OpenEmbedded build system uses BitBake to generate the | ||
| 2421 | Software Development Kit (SDK) installer script for both the | ||
| 2422 | standard and extensible SDKs: | ||
| 2423 | <imagedata fileref="figures/sdk-generation.png" align="center" /> | ||
| 2424 | </para> | ||
| 2425 | |||
| 2426 | <note> | ||
| 2427 | For more information on the cross-development toolchain | ||
| 2428 | generation, see the | ||
| 2429 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" | ||
| 2430 | section. | ||
| 2431 | For information on advantages gained when building a | ||
| 2432 | cross-development toolchain using the | ||
| 2433 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sdk'><filename>do_populate_sdk</filename></ulink> | ||
| 2434 | task, see the | ||
| 2435 | "<ulink url='&YOCTO_DOCS_SDK_URL;#sdk-building-an-sdk-installer'>Building an SDK Installer</ulink>" | ||
| 2436 | section in the Yocto Project Application Development and the | ||
| 2437 | Extensible Software Development Kit (SDK) manual. | ||
| 2438 | </note> | ||
| 2439 | |||
| 2440 | <para> | ||
| 2441 | Like image generation, the SDK script process consists of | ||
| 2442 | several stages and depends on many variables. | ||
| 2443 | The <filename>do_populate_sdk</filename> and | ||
| 2444 | <filename>do_populate_sdk_ext</filename> tasks use these | ||
| 2445 | key variables to help create the list of packages to actually | ||
| 2446 | install. | ||
| 2447 | For information on the variables listed in the figure, see the | ||
| 2448 | "<link linkend='sdk-dev-environment'>Application Development SDK</link>" | ||
| 2449 | section. | ||
| 2450 | </para> | ||
| 2451 | |||
| 2452 | <para> | ||
| 2453 | The <filename>do_populate_sdk</filename> task helps create | ||
| 2454 | the standard SDK and handles two parts: a target part and a | ||
| 2455 | host part. | ||
| 2456 | The target part is the part built for the target hardware and | ||
| 2457 | includes libraries and headers. | ||
| 2458 | The host part is the part of the SDK that runs on the | ||
| 2459 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>. | ||
| 2460 | </para> | ||
| 2461 | |||
| 2462 | <para> | ||
| 2463 | The <filename>do_populate_sdk_ext</filename> task helps create | ||
| 2464 | the extensible SDK and handles host and target parts | ||
| 2465 | differently than its counter part does for the standard SDK. | ||
| 2466 | For the extensible SDK, the task encapsulates the build system, | ||
| 2467 | which includes everything needed (host and target) for the SDK. | ||
| 2468 | </para> | ||
| 2469 | |||
| 2470 | <para> | ||
| 2471 | Regardless of the type of SDK being constructed, the | ||
| 2472 | tasks perform some cleanup after which a cross-development | ||
| 2473 | environment setup script and any needed configuration files | ||
| 2474 | are created. | ||
| 2475 | The final output is the Cross-development | ||
| 2476 | toolchain installation script (<filename>.sh</filename> file), | ||
| 2477 | which includes the environment setup script. | ||
| 2478 | </para> | ||
| 2479 | </section> | ||
| 2480 | |||
| 2481 | <section id='stamp-files-and-the-rerunning-of-tasks'> | ||
| 2482 | <title>Stamp Files and the Rerunning of Tasks</title> | ||
| 2483 | |||
| 2484 | <para> | ||
| 2485 | For each task that completes successfully, BitBake writes a | ||
| 2486 | stamp file into the | ||
| 2487 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMPS_DIR'><filename>STAMPS_DIR</filename></ulink> | ||
| 2488 | directory. | ||
| 2489 | The beginning of the stamp file's filename is determined by the | ||
| 2490 | <ulink url='&YOCTO_DOCS_REF_URL;#var-STAMP'><filename>STAMP</filename></ulink> | ||
| 2491 | variable, and the end of the name consists of the task's name | ||
| 2492 | and current | ||
| 2493 | <link linkend='overview-checksums'>input checksum</link>. | ||
| 2494 | <note> | ||
| 2495 | This naming scheme assumes that | ||
| 2496 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SIGNATURE_HANDLER'><filename>BB_SIGNATURE_HANDLER</filename></ulink> | ||
| 2497 | is "OEBasicHash", which is almost always the case in | ||
| 2498 | current OpenEmbedded. | ||
| 2499 | </note> | ||
| 2500 | To determine if a task needs to be rerun, BitBake checks if a | ||
| 2501 | stamp file with a matching input checksum exists for the task. | ||
| 2502 | If such a stamp file exists, the task's output is assumed to | ||
| 2503 | exist and still be valid. | ||
| 2504 | If the file does not exist, the task is rerun. | ||
| 2505 | <note> | ||
| 2506 | <para>The stamp mechanism is more general than the shared | ||
| 2507 | state (sstate) cache mechanism described in the | ||
| 2508 | "<link linkend='setscene-tasks-and-shared-state'>Setscene Tasks and Shared State</link>" | ||
| 2509 | section. | ||
| 2510 | BitBake avoids rerunning any task that has a valid | ||
| 2511 | stamp file, not just tasks that can be accelerated through | ||
| 2512 | the sstate cache.</para> | ||
| 2513 | <para>However, you should realize that stamp files only | ||
| 2514 | serve as a marker that some work has been done and that | ||
| 2515 | these files do not record task output. | ||
| 2516 | The actual task output would usually be somewhere in | ||
| 2517 | <ulink url='&YOCTO_DOCS_REF_URL;#var-TMPDIR'><filename>TMPDIR</filename></ulink> | ||
| 2518 | (e.g. in some recipe's | ||
| 2519 | <ulink url='&YOCTO_DOCS_REF_URL;#var-WORKDIR'><filename>WORKDIR</filename></ulink>.) | ||
| 2520 | What the sstate cache mechanism adds is a way to cache task | ||
| 2521 | output that can then be shared between build machines. | ||
| 2522 | </para> | ||
| 2523 | </note> | ||
| 2524 | Since <filename>STAMPS_DIR</filename> is usually a subdirectory | ||
| 2525 | of <filename>TMPDIR</filename>, removing | ||
| 2526 | <filename>TMPDIR</filename> will also remove | ||
| 2527 | <filename>STAMPS_DIR</filename>, which means tasks will | ||
| 2528 | properly be rerun to repopulate <filename>TMPDIR</filename>. | ||
| 2529 | </para> | ||
| 2530 | |||
| 2531 | <para> | ||
| 2532 | If you want some task to always be considered "out of date", | ||
| 2533 | you can mark it with the | ||
| 2534 | <ulink url='&YOCTO_DOCS_BB_URL;#variable-flags'><filename>nostamp</filename></ulink> | ||
| 2535 | varflag. | ||
| 2536 | If some other task depends on such a task, then that task will | ||
| 2537 | also always be considered out of date, which might not be what | ||
| 2538 | you want. | ||
| 2539 | </para> | ||
| 2540 | |||
| 2541 | <para> | ||
| 2542 | For details on how to view information about a task's | ||
| 2543 | signature, see the | ||
| 2544 | "<ulink url='&YOCTO_DOCS_DEV_URL;#dev-viewing-task-variable-dependencies'>Viewing Task Variable Dependencies</ulink>" | ||
| 2545 | section in the Yocto Project Development Tasks Manual. | ||
| 2546 | </para> | ||
| 2547 | </section> | ||
| 2548 | |||
| 2549 | <section id='setscene-tasks-and-shared-state'> | ||
| 2550 | <title>Setscene Tasks and Shared State</title> | ||
| 2551 | |||
| 2552 | <para> | ||
| 2553 | The description of tasks so far assumes that BitBake needs to | ||
| 2554 | build everything and there are no prebuilt objects available. | ||
| 2555 | BitBake does support skipping tasks if prebuilt objects are | ||
| 2556 | available. | ||
| 2557 | These objects are usually made available in the form of a | ||
| 2558 | shared state (sstate) cache. | ||
| 2559 | <note> | ||
| 2560 | For information on variables affecting sstate, see the | ||
| 2561 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_DIR'><filename>SSTATE_DIR</filename></ulink> | ||
| 2562 | and | ||
| 2563 | <ulink url='&YOCTO_DOCS_REF_URL;#var-SSTATE_MIRRORS'><filename>SSTATE_MIRRORS</filename></ulink> | ||
| 2564 | variables. | ||
| 2565 | </note> | ||
| 2566 | </para> | ||
| 2567 | |||
| 2568 | <para> | ||
| 2569 | The idea of a setscene task (i.e | ||
| 2570 | <filename>do_</filename><replaceable>taskname</replaceable><filename>_setscene</filename>) | ||
| 2571 | is a version of the task where | ||
| 2572 | instead of building something, BitBake can skip to the end | ||
| 2573 | result and simply place a set of files into specific locations | ||
| 2574 | as needed. | ||
| 2575 | In some cases, it makes sense to have a setscene task variant | ||
| 2576 | (e.g. generating package files in the | ||
| 2577 | <filename>do_package_write_*</filename> task). | ||
| 2578 | In other cases, it does not make sense, (e.g. a | ||
| 2579 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-patch'><filename>do_patch</filename></ulink> | ||
| 2580 | task or | ||
| 2581 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-unpack'><filename>do_unpack</filename></ulink> | ||
| 2582 | task) since the work involved would be equal to or greater than | ||
| 2583 | the underlying task. | ||
| 2584 | </para> | ||
| 2585 | |||
| 2586 | <para> | ||
| 2587 | In the OpenEmbedded build system, the common tasks that have | ||
| 2588 | setscene variants are | ||
| 2589 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-package'><filename>do_package</filename></ulink>, | ||
| 2590 | <filename>do_package_write_*</filename>, | ||
| 2591 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-deploy'><filename>do_deploy</filename></ulink>, | ||
| 2592 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-packagedata'><filename>do_packagedata</filename></ulink>, | ||
| 2593 | and | ||
| 2594 | <ulink url='&YOCTO_DOCS_REF_URL;#ref-tasks-populate_sysroot'><filename>do_populate_sysroot</filename></ulink>. | ||
| 2595 | Notice that these are most of the tasks whose output is an | ||
| 2596 | end result. | ||
| 2597 | </para> | ||
| 2598 | |||
| 2599 | <para> | ||
| 2600 | The OpenEmbedded build system has knowledge of the relationship | ||
| 2601 | between these tasks and other tasks that precede them. | ||
| 2602 | For example, if BitBake runs | ||
| 2603 | <filename>do_populate_sysroot_setscene</filename> for | ||
| 2604 | something, there is little point in running any of the | ||
| 2605 | <filename>do_fetch</filename>, <filename>do_unpack</filename>, | ||
| 2606 | <filename>do_patch</filename>, | ||
| 2607 | <filename>do_configure</filename>, | ||
| 2608 | <filename>do_compile</filename>, and | ||
| 2609 | <filename>do_install</filename> tasks. | ||
| 2610 | However, if <filename>do_package</filename> needs to be run, | ||
| 2611 | BitBake would need to run those other tasks. | ||
| 2612 | </para> | ||
| 2613 | |||
| 2614 | <para> | ||
| 2615 | It becomes more complicated if everything can come from an | ||
| 2616 | sstate cache because some objects are simply not required at | ||
| 2617 | all. | ||
| 2618 | For example, you do not need a compiler or native tools, such | ||
| 2619 | as quilt, if there is nothing to compile or patch. | ||
| 2620 | If the <filename>do_package_write_*</filename> packages are | ||
| 2621 | available from sstate, BitBake does not need the | ||
| 2622 | <filename>do_package</filename> task data. | ||
| 2623 | </para> | ||
| 2624 | |||
| 2625 | <para> | ||
| 2626 | To handle all these complexities, BitBake runs in two phases. | ||
| 2627 | The first is the "setscene" stage. | ||
| 2628 | During this stage, BitBake first checks the sstate cache for | ||
| 2629 | any targets it is planning to build. | ||
| 2630 | BitBake does a fast check to see if the object exists rather | ||
| 2631 | than a complete download. | ||
| 2632 | If nothing exists, the second phase, which is the setscene | ||
| 2633 | stage, completes and the main build proceeds. | ||
| 2634 | </para> | ||
| 2635 | |||
| 2636 | <para> | ||
| 2637 | If objects are found in the sstate cache, the OpenEmbedded | ||
| 2638 | build system works backwards from the end targets specified | ||
| 2639 | by the user. | ||
| 2640 | For example, if an image is being built, the OpenEmbedded build | ||
| 2641 | system first looks for the packages needed for that image and | ||
| 2642 | the tools needed to construct an image. | ||
| 2643 | If those are available, the compiler is not needed. | ||
| 2644 | Thus, the compiler is not even downloaded. | ||
| 2645 | If something was found to be unavailable, or the download or | ||
| 2646 | setscene task fails, the OpenEmbedded build system then tries | ||
| 2647 | to install dependencies, such as the compiler, from the cache. | ||
| 2648 | </para> | ||
| 2649 | |||
| 2650 | <para> | ||
| 2651 | The availability of objects in the sstate cache is handled by | ||
| 2652 | the function specified by the | ||
| 2653 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_HASHCHECK_FUNCTION'><filename>BB_HASHCHECK_FUNCTION</filename></ulink> | ||
| 2654 | variable and returns a list of the objects that are available. | ||
| 2655 | The function specified by the | ||
| 2656 | <ulink url='&YOCTO_DOCS_BB_URL;#var-BB_SETSCENE_DEPVALID'><filename>BB_SETSCENE_DEPVALID</filename></ulink> | ||
| 2657 | variable is the function that determines whether a given | ||
| 2658 | dependency needs to be followed, and whether for any given | ||
| 2659 | relationship the function needs to be passed. | ||
| 2660 | The function returns a True or False value. | ||
| 2661 | </para> | ||
| 2662 | </section> | ||
| 2663 | </section> | ||
| 2664 | |||
| 2665 | <section id='images-dev-environment'> | ||
| 2666 | <title>Images</title> | ||
| 2667 | |||
| 2668 | <para> | ||
| 2669 | The images produced by the OpenEmbedded build system | ||
| 2670 | are compressed forms of the | ||
| 2671 | root filesystem that are ready to boot on a target device. | ||
| 2672 | You can see from the | ||
| 2673 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link> | ||
| 2674 | that BitBake output, in part, consists of images. | ||
| 2675 | This section is going to look more closely at this output: | ||
| 2676 | <imagedata fileref="figures/images.png" align="center" width="5.5in" depth="5.5in" /> | ||
| 2677 | </para> | ||
| 2678 | |||
| 2679 | <para> | ||
| 2680 | For a list of example images that the Yocto Project provides, | ||
| 2681 | see the | ||
| 2682 | "<ulink url='&YOCTO_DOCS_REF_URL;#ref-images'>Images</ulink>" | ||
| 2683 | chapter in the Yocto Project Reference Manual. | ||
| 2684 | </para> | ||
| 2685 | |||
| 2686 | <para> | ||
| 2687 | Images are written out to the | ||
| 2688 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | ||
| 2689 | inside the | ||
| 2690 | <filename>tmp/deploy/images/<replaceable>machine</replaceable>/</filename> | ||
| 2691 | folder as shown in the figure. | ||
| 2692 | This folder contains any files expected to be loaded on the | ||
| 2693 | target device. | ||
| 2694 | The | ||
| 2695 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink> | ||
| 2696 | variable points to the <filename>deploy</filename> directory, | ||
| 2697 | while the | ||
| 2698 | <ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR_IMAGE'><filename>DEPLOY_DIR_IMAGE</filename></ulink> | ||
| 2699 | variable points to the appropriate directory containing images for | ||
| 2700 | the current configuration. | ||
| 2701 | <itemizedlist> | ||
| 2702 | <listitem><para><filename><replaceable>kernel-image</replaceable></filename>: | ||
| 2703 | A kernel binary file. | ||
| 2704 | The | ||
| 2705 | <ulink url='&YOCTO_DOCS_REF_URL;#var-KERNEL_IMAGETYPE'><filename>KERNEL_IMAGETYPE</filename></ulink> | ||
| 2706 | variable setting determines the naming scheme for the | ||
| 2707 | kernel image file. | ||
| 2708 | Depending on that variable, the file could begin with | ||
| 2709 | a variety of naming strings. | ||
| 2710 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> | ||
| 2711 | directory can contain multiple image files for the | ||
| 2712 | machine.</para></listitem> | ||
| 2713 | <listitem><para><filename><replaceable>root-filesystem-image</replaceable></filename>: | ||
| 2714 | Root filesystems for the target device (e.g. | ||
| 2715 | <filename>*.ext3</filename> or <filename>*.bz2</filename> | ||
| 2716 | files). | ||
| 2717 | The | ||
| 2718 | <ulink url='&YOCTO_DOCS_REF_URL;#var-IMAGE_FSTYPES'><filename>IMAGE_FSTYPES</filename></ulink> | ||
| 2719 | variable setting determines the root filesystem image | ||
| 2720 | type. | ||
| 2721 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> | ||
| 2722 | directory can contain multiple root filesystems for the | ||
| 2723 | machine.</para></listitem> | ||
| 2724 | <listitem><para><filename><replaceable>kernel-modules</replaceable></filename>: | ||
| 2725 | Tarballs that contain all the modules built for the kernel. | ||
| 2726 | Kernel module tarballs exist for legacy purposes and | ||
| 2727 | can be suppressed by setting the | ||
| 2728 | <ulink url='&YOCTO_DOCS_REF_URL;#var-MODULE_TARBALL_DEPLOY'><filename>MODULE_TARBALL_DEPLOY</filename></ulink> | ||
| 2729 | variable to "0". | ||
| 2730 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> | ||
| 2731 | directory can contain multiple kernel module tarballs | ||
| 2732 | for the machine.</para></listitem> | ||
| 2733 | <listitem><para><filename><replaceable>bootloaders</replaceable></filename>: | ||
| 2734 | Bootloaders supporting the image, if applicable to the | ||
| 2735 | target machine. | ||
| 2736 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> | ||
| 2737 | directory can contain multiple bootloaders for the | ||
| 2738 | machine.</para></listitem> | ||
| 2739 | <listitem><para><filename><replaceable>symlinks</replaceable></filename>: | ||
| 2740 | The <filename>deploy/images/<replaceable>machine</replaceable></filename> | ||
| 2741 | folder contains | ||
| 2742 | a symbolic link that points to the most recently built file | ||
| 2743 | for each machine. | ||
| 2744 | These links might be useful for external scripts that | ||
| 2745 | need to obtain the latest version of each file. | ||
| 2746 | </para></listitem> | ||
| 2747 | </itemizedlist> | ||
| 2748 | </para> | ||
| 2749 | </section> | ||
| 2750 | |||
| 2751 | <section id='sdk-dev-environment'> | ||
| 2752 | <title>Application Development SDK</title> | ||
| 2753 | |||
| 2754 | <para> | ||
| 2755 | In the | ||
| 2756 | <link linkend='general-yocto-environment-figure'>general Yocto Project Development Environment figure</link>, | ||
| 2757 | the output labeled "Application Development SDK" represents an | ||
| 2758 | SDK. | ||
| 2759 | The SDK generation process differs depending on whether you build | ||
| 2760 | a standard SDK | ||
| 2761 | (e.g. <filename>bitbake -c populate_sdk</filename> <replaceable>imagename</replaceable>) | ||
| 2762 | or an extensible SDK | ||
| 2763 | (e.g. <filename>bitbake -c populate_sdk_ext</filename> <replaceable>imagename</replaceable>). | ||
| 2764 | This section is going to take a closer look at this output: | ||
| 2765 | <imagedata fileref="figures/sdk.png" align="center" width="9in" depth="7.25in" /> | ||
| 2766 | </para> | ||
| 2767 | |||
| 2768 | <para> | ||
| 2769 | The specific form of this output is a self-extracting | ||
| 2770 | SDK installer (<filename>*.sh</filename>) that, when run, | ||
| 2771 | installs the SDK, which consists of a cross-development | ||
| 2772 | toolchain, a set of libraries and headers, and an SDK | ||
| 2773 | environment setup script. | ||
| 2774 | Running this installer essentially sets up your | ||
| 2775 | cross-development environment. | ||
| 2776 | You can think of the cross-toolchain as the "host" | ||
| 2777 | part because it runs on the SDK machine. | ||
| 2778 | You can think of the libraries and headers as the "target" | ||
| 2779 | part because they are built for the target hardware. | ||
| 2780 | The environment setup script is added so that you can initialize | ||
| 2781 | the environment before using the tools. | ||
| 2782 | </para> | ||
| 2783 | |||
| 2784 | <note><title>Notes</title> | ||
| 2785 | <itemizedlist> | ||
| 2786 | <listitem><para> | ||
| 2787 | The Yocto Project supports several methods by which you can | ||
| 2788 | set up this cross-development environment. | ||
| 2789 | These methods include downloading pre-built SDK installers | ||
| 2790 | or building and installing your own SDK installer. | ||
| 2791 | </para></listitem> | ||
| 2792 | <listitem><para> | ||
| 2793 | For background information on cross-development toolchains | ||
| 2794 | in the Yocto Project development environment, see the | ||
| 2795 | "<link linkend='cross-development-toolchain-generation'>Cross-Development Toolchain Generation</link>" | ||
| 2796 | section. | ||
| 2797 | </para></listitem> | ||
| 2798 | <listitem><para> | ||
| 2799 | For information on setting up a cross-development | ||
| 2800 | environment, see the | ||
| 2801 | <ulink url='&YOCTO_DOCS_SDK_URL;'>Yocto Project Application Development and the Extensible Software Development Kit (eSDK)</ulink> | ||
| 2802 | manual. | ||
| 2803 | </para></listitem> | ||
| 2804 | </itemizedlist> | ||
| 2805 | </note> | ||
| 2806 | |||
| 2807 | <para> | ||
| 2808 | Once built, the SDK installers are written out to the | ||
| 2809 | <filename>deploy/sdk</filename> folder inside the | ||
| 2810 | <ulink url='&YOCTO_DOCS_REF_URL;#build-directory'>Build Directory</ulink> | ||
| 2811 | as shown in the figure at the beginning of this section. | ||
| 2812 | Depending on the type of SDK, several variables exist that help | ||
| 2813 | configure these files. | ||
| 2814 | The following list shows the variables associated with a standard | ||
| 2815 | SDK: | ||
| 2816 | <itemizedlist> | ||
| 2817 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>: | ||
| 2818 | Points to the <filename>deploy</filename> | ||
| 2819 | directory.</para></listitem> | ||
| 2820 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDKMACHINE'><filename>SDKMACHINE</filename></ulink>: | ||
| 2821 | Specifies the architecture of the machine | ||
| 2822 | on which the cross-development tools are run to | ||
| 2823 | create packages for the target hardware. | ||
| 2824 | </para></listitem> | ||
| 2825 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDKIMAGE_FEATURES'><filename>SDKIMAGE_FEATURES</filename></ulink>: | ||
| 2826 | Lists the features to include in the "target" part | ||
| 2827 | of the SDK. | ||
| 2828 | </para></listitem> | ||
| 2829 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_HOST_TASK'><filename>TOOLCHAIN_HOST_TASK</filename></ulink>: | ||
| 2830 | Lists packages that make up the host | ||
| 2831 | part of the SDK (i.e. the part that runs on | ||
| 2832 | the <filename>SDKMACHINE</filename>). | ||
| 2833 | When you use | ||
| 2834 | <filename>bitbake -c populate_sdk <replaceable>imagename</replaceable></filename> | ||
| 2835 | to create the SDK, a set of default packages | ||
| 2836 | apply. | ||
| 2837 | This variable allows you to add more packages. | ||
| 2838 | </para></listitem> | ||
| 2839 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-TOOLCHAIN_TARGET_TASK'><filename>TOOLCHAIN_TARGET_TASK</filename></ulink>: | ||
| 2840 | Lists packages that make up the target part | ||
| 2841 | of the SDK (i.e. the part built for the | ||
| 2842 | target hardware). | ||
| 2843 | </para></listitem> | ||
| 2844 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDKPATH'><filename>SDKPATH</filename></ulink>: | ||
| 2845 | Defines the default SDK installation path offered by the | ||
| 2846 | installation script. | ||
| 2847 | </para></listitem> | ||
| 2848 | </itemizedlist> | ||
| 2849 | This next list, shows the variables associated with an extensible | ||
| 2850 | SDK: | ||
| 2851 | <itemizedlist> | ||
| 2852 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-DEPLOY_DIR'><filename>DEPLOY_DIR</filename></ulink>: | ||
| 2853 | Points to the <filename>deploy</filename> directory. | ||
| 2854 | </para></listitem> | ||
| 2855 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_EXT_TYPE'><filename>SDK_EXT_TYPE</filename></ulink>: | ||
| 2856 | Controls whether or not shared state artifacts are copied | ||
| 2857 | into the extensible SDK. | ||
| 2858 | By default, all required shared state artifacts are copied | ||
| 2859 | into the SDK. | ||
| 2860 | </para></listitem> | ||
| 2861 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_PKGDATA'><filename>SDK_INCLUDE_PKGDATA</filename></ulink>: | ||
| 2862 | Specifies whether or not packagedata will be included in | ||
| 2863 | the extensible SDK for all recipes in the "world" target. | ||
| 2864 | </para></listitem> | ||
| 2865 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INCLUDE_TOOLCHAIN'><filename>SDK_INCLUDE_TOOLCHAIN</filename></ulink>: | ||
| 2866 | Specifies whether or not the toolchain will be included | ||
| 2867 | when building the extensible SDK. | ||
| 2868 | </para></listitem> | ||
| 2869 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_WHITELIST'><filename>SDK_LOCAL_CONF_WHITELIST</filename></ulink>: | ||
| 2870 | A list of variables allowed through from the build system | ||
| 2871 | configuration into the extensible SDK configuration. | ||
| 2872 | </para></listitem> | ||
| 2873 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_LOCAL_CONF_BLACKLIST'><filename>SDK_LOCAL_CONF_BLACKLIST</filename></ulink>: | ||
| 2874 | A list of variables not allowed through from the build | ||
| 2875 | system configuration into the extensible SDK configuration. | ||
| 2876 | </para></listitem> | ||
| 2877 | <listitem><para><ulink url='&YOCTO_DOCS_REF_URL;#var-SDK_INHERIT_BLACKLIST'><filename>SDK_INHERIT_BLACKLIST</filename></ulink>: | ||
| 2878 | A list of classes to remove from the | ||
| 2879 | <ulink url='&YOCTO_DOCS_REF_URL;#var-INHERIT'><filename>INHERIT</filename></ulink> | ||
| 2880 | value globally within the extensible SDK configuration. | ||
| 2881 | </para></listitem> | ||
| 2882 | </itemizedlist> | ||
| 2883 | </para> | ||
| 2884 | </section> | ||
| 2885 | </section> | ||
| 2886 | |||
| 2887 | </chapter> | ||
| 2888 | <!-- | ||
| 2889 | vim: expandtab tw=80 ts=4 | ||
| 2890 | --> | ||
