diff options
| author | Richard Purdie <rpurdie@linux.intel.com> | 2010-10-15 11:55:59 +0100 |
|---|---|---|
| committer | Richard Purdie <rpurdie@linux.intel.com> | 2010-10-15 11:55:59 +0100 |
| commit | 22083287912ebd552e33b79f7c567bc966376d43 (patch) | |
| tree | a16fa012a97a249e25a405d4092b0a89321bfaf6 /documentation/poky-ref-manual/ref-bitbake.xml | |
| parent | 13a702e9e572a2dc9f6b52a1531a2237d4d98ff1 (diff) | |
| download | poky-22083287912ebd552e33b79f7c567bc966376d43.tar.gz | |
handbook: Move into documentation directory
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'documentation/poky-ref-manual/ref-bitbake.xml')
| -rw-r--r-- | documentation/poky-ref-manual/ref-bitbake.xml | 348 |
1 files changed, 348 insertions, 0 deletions
diff --git a/documentation/poky-ref-manual/ref-bitbake.xml b/documentation/poky-ref-manual/ref-bitbake.xml new file mode 100644 index 0000000000..eaf9467950 --- /dev/null +++ b/documentation/poky-ref-manual/ref-bitbake.xml | |||
| @@ -0,0 +1,348 @@ | |||
| 1 | <!DOCTYPE appendix PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN" | ||
| 2 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd"> | ||
| 3 | |||
| 4 | <appendix id='ref-bitbake'> | ||
| 5 | |||
| 6 | <title>Reference: Bitbake</title> | ||
| 7 | |||
| 8 | <para> | ||
| 9 | Bitbake is a program written in Python that interprets the metadata | ||
| 10 | that makes up Poky. At some point, people wonder what actually happens | ||
| 11 | when you type <command>bitbake poky-image-sato</command>. This section | ||
| 12 | aims to give an overview of what happens behind the scenes from a | ||
| 13 | BitBake perspective. | ||
| 14 | </para> | ||
| 15 | |||
| 16 | <para> | ||
| 17 | It is worth noting that bitbake aims to be a generic "task" executor | ||
| 18 | capable of handling complex dependency relationships. As such it has no | ||
| 19 | real knowledge of what the tasks it is executing actually do. It just | ||
| 20 | considers a list of tasks with dependencies and handles metadata | ||
| 21 | consisting of variables in a certain format which get passed to the | ||
| 22 | tasks. | ||
| 23 | </para> | ||
| 24 | |||
| 25 | <section id='ref-bitbake-parsing'> | ||
| 26 | <title>Parsing</title> | ||
| 27 | |||
| 28 | <para> | ||
| 29 | The first thing BitBake does is that work out its configuration by | ||
| 30 | looking for a file called <filename>bitbake.conf</filename>. | ||
| 31 | Bitbake searches through the <varname>BBPATH</varname> environment | ||
| 32 | variable looking for a <filename class="directory">conf/</filename> | ||
| 33 | directory containing a <filename>bitbake.conf</filename> file and | ||
| 34 | adds the first <filename>bitbake.conf</filename> file found in | ||
| 35 | <varname>BBPATH</varname> (similar to the PATH environment variable). | ||
| 36 | For Poky, <filename>bitbake.conf</filename> is found in <filename | ||
| 37 | class="directory">meta/conf/</filename>. | ||
| 38 | </para> | ||
| 39 | |||
| 40 | <para> | ||
| 41 | In Poky, <filename>bitbake.conf</filename> lists other configuration | ||
| 42 | files to include from a <filename class="directory">conf/</filename> | ||
| 43 | directory below the directories listed in <varname>BBPATH</varname>. | ||
| 44 | In general the most important configuration file from a user's perspective | ||
| 45 | is <filename>local.conf</filename>, which contains a users customized | ||
| 46 | settings for Poky. Other notable configuration files are the distribution | ||
| 47 | configuration file (set by the <glossterm><link linkend='var-DISTRO'> | ||
| 48 | DISTRO</link></glossterm> variable) and the machine configuration file | ||
| 49 | (set by the <glossterm><link linkend='var-MACHINE'>MACHINE</link> | ||
| 50 | </glossterm> variable). The <glossterm><link linkend='var-DISTRO'> | ||
| 51 | DISTRO</link></glossterm> and <glossterm><link linkend='var-MACHINE'> | ||
| 52 | MACHINE</link></glossterm> environment variables are both usually set in | ||
| 53 | the <filename>local.conf</filename> file. Valid distribution | ||
| 54 | configuration files are available in the <filename class="directory"> | ||
| 55 | meta/conf/distro/</filename> directory and valid machine configuration | ||
| 56 | files in the <filename class="directory">meta/conf/machine/</filename> | ||
| 57 | directory. Within the <filename class="directory"> | ||
| 58 | meta/conf/machine/include/</filename> directory are various <filename> | ||
| 59 | tune-*.inc</filename> configuration files which provide common | ||
| 60 | "tuning" settings specific to and shared between particular | ||
| 61 | architectures and machines. | ||
| 62 | </para> | ||
| 63 | |||
| 64 | <para> | ||
| 65 | After the parsing of the configuration files some standard classes | ||
| 66 | are included. In particular, <filename>base.bbclass</filename> is | ||
| 67 | always included, as will any other classes | ||
| 68 | specified in the configuration using the <glossterm><link | ||
| 69 | linkend='var-INHERIT'>INHERIT</link></glossterm> | ||
| 70 | variable. Class files are searched for in a classes subdirectory | ||
| 71 | under the paths in <varname>BBPATH</varname> in the same way as | ||
| 72 | configuration files. | ||
| 73 | </para> | ||
| 74 | |||
| 75 | <para> | ||
| 76 | After the parsing of the configuration files is complete, the | ||
| 77 | variable <glossterm><link linkend='var-BBFILES'>BBFILES</link></glossterm> | ||
| 78 | is set, usually in | ||
| 79 | <filename>local.conf</filename>, and defines the list of places to search for | ||
| 80 | <filename class="extension">.bb</filename> files. By | ||
| 81 | default this specifies the <filename class="directory">meta/packages/ | ||
| 82 | </filename> directory within Poky, but other directories such as | ||
| 83 | <filename class="directory">meta-extras/</filename> can be included | ||
| 84 | too. Adding extra content to | ||
| 85 | <glossterm><link linkend='var-BBFILES'>BBFILES</link></glossterm> is best | ||
| 86 | acheived through the use of Bitbake | ||
| 87 | <link linkend='usingpoky-changes-layers'>"layers"</link>. | ||
| 88 | </para> | ||
| 89 | |||
| 90 | <para> | ||
| 91 | Bitbake parses each <filename class="extension">.bb</filename> file in | ||
| 92 | <glossterm><link linkend='var-BBFILES'>BBFILES</link></glossterm> and | ||
| 93 | stores the values of various variables. In summary, for each | ||
| 94 | <filename class="extension">.bb</filename> | ||
| 95 | file the configuration + base class of variables are set, followed | ||
| 96 | by the data in the <filename class="extension">.bb</filename> file | ||
| 97 | itself, followed by any inherit commands that | ||
| 98 | <filename class="extension">.bb</filename> file might contain. | ||
| 99 | </para> | ||
| 100 | |||
| 101 | <para> | ||
| 102 | Parsing <filename class="extension">.bb</filename> files is a time | ||
| 103 | consuming process, so a cache is kept to speed up subsequent parsing. | ||
| 104 | This cache is invalid if the timestamp of the <filename class="extension">.bb</filename> | ||
| 105 | file itself has changed, or if the timestamps of any of the include, | ||
| 106 | configuration or class files the <filename class="extension">.bb</filename> | ||
| 107 | file depends on have changed. | ||
| 108 | </para> | ||
| 109 | </section> | ||
| 110 | |||
| 111 | <section id='ref-bitbake-providers'> | ||
| 112 | <title>Preferences and Providers</title> | ||
| 113 | |||
| 114 | <para> | ||
| 115 | Once all the <filename class="extension">.bb</filename> files have been | ||
| 116 | parsed, BitBake will proceed to build "poky-image-sato" (or whatever was | ||
| 117 | specified on the commandline) and looks for providers of that target. | ||
| 118 | Once a provider is selected, BitBake resolves all the dependencies for | ||
| 119 | the target. In the case of "poky-image-sato", it would lead to | ||
| 120 | <filename>task-base.bb</filename> | ||
| 121 | which in turn would lead to packages like <application>Contacts</application>, | ||
| 122 | <application>Dates</application>, <application>BusyBox</application> | ||
| 123 | and these in turn depend on glibc and the toolchain. | ||
| 124 | </para> | ||
| 125 | |||
| 126 | <para> | ||
| 127 | Sometimes a target might have multiple providers and a common example | ||
| 128 | is "virtual/kernel" that is provided by each kernel package. Each machine | ||
| 129 | will often elect the best provider of its kernel with a line like the | ||
| 130 | following in the machine configuration file: | ||
| 131 | </para> | ||
| 132 | <programlisting><glossterm><link linkend='var-PREFERRED_PROVIDER'>PREFERRED_PROVIDER</link></glossterm>_virtual/kernel = "linux-rp"</programlisting> | ||
| 133 | <para> | ||
| 134 | The default <glossterm><link linkend='var-PREFERRED_PROVIDER'> | ||
| 135 | PREFERRED_PROVIDER</link></glossterm> is the provider with the same name as | ||
| 136 | the target. | ||
| 137 | </para> | ||
| 138 | |||
| 139 | <para> | ||
| 140 | Understanding how providers are chosen is complicated by the fact | ||
| 141 | multiple versions might be present. Bitbake defaults to the highest | ||
| 142 | version of a provider by default. Version comparisons are made using | ||
| 143 | the same method as Debian. The <glossterm><link | ||
| 144 | linkend='var-PREFERRED_VERSION'>PREFERRED_VERSION</link></glossterm> | ||
| 145 | variable can be used to specify a particular version | ||
| 146 | (usually in the distro configuration) but the order can | ||
| 147 | also be influenced by the <glossterm><link | ||
| 148 | linkend='var-DEFAULT_PREFERENCE'>DEFAULT_PREFERENCE</link></glossterm> | ||
| 149 | variable. By default files | ||
| 150 | have a preference of "0". Setting the | ||
| 151 | <glossterm><link | ||
| 152 | linkend='var-DEFAULT_PREFERENCE'>DEFAULT_PREFERENCE</link></glossterm> to "-1" will | ||
| 153 | make a package unlikely to be used unless it was explicitly referenced and | ||
| 154 | "1" makes it likely the package will be used. | ||
| 155 | <glossterm><link | ||
| 156 | linkend='var-PREFERRED_VERSION'>PREFERRED_VERSION</link></glossterm> overrides | ||
| 157 | any <glossterm><link | ||
| 158 | linkend='var-DEFAULT_PREFERENCE'>DEFAULT_PREFERENCE</link></glossterm>. <glossterm><link | ||
| 159 | linkend='var-DEFAULT_PREFERENCE'>DEFAULT_PREFERENCE</link></glossterm> | ||
| 160 | is often used to mark more | ||
| 161 | experimental new versions of packages until they've undergone sufficient | ||
| 162 | testing to be considered stable. | ||
| 163 | </para> | ||
| 164 | |||
| 165 | <para> | ||
| 166 | The end result is that internally, BitBake has now built a list of | ||
| 167 | providers for each target it needs in order of priority. | ||
| 168 | </para> | ||
| 169 | </section> | ||
| 170 | |||
| 171 | <section id='ref-bitbake-dependencies'> | ||
| 172 | <title>Dependencies</title> | ||
| 173 | |||
| 174 | <para> | ||
| 175 | Each target BitBake builds consists of multiple tasks (e.g. fetch, | ||
| 176 | unpack, patch, configure, compile etc.). For best performance on | ||
| 177 | multi-core systems, BitBake considers each task as an independent | ||
| 178 | entity with a set of dependencies. There are many variables that | ||
| 179 | are used to signify these dependencies and more information can be found | ||
| 180 | about these in the <ulink url='http://bitbake.berlios.de/manual/'> | ||
| 181 | BitBake manual</ulink>. At a basic level it is sufficient to know | ||
| 182 | that BitBake uses the <glossterm><link | ||
| 183 | linkend='var-DEPENDS'>DEPENDS</link></glossterm> and | ||
| 184 | <glossterm><link linkend='var-RDEPENDS'>RDEPENDS</link></glossterm> variables when | ||
| 185 | calculating dependencies and descriptions of these variables are | ||
| 186 | available through the links. | ||
| 187 | </para> | ||
| 188 | |||
| 189 | </section> | ||
| 190 | |||
| 191 | <section id='ref-bitbake-tasklist'> | ||
| 192 | <title>The Task List</title> | ||
| 193 | |||
| 194 | <para> | ||
| 195 | Based on the generated list of providers and the dependency information, | ||
| 196 | BitBake can now calculate exactly which tasks it needs to run and in what | ||
| 197 | order. The build now starts with BitBake forking off threads up to | ||
| 198 | the limit set in the <glossterm><link | ||
| 199 | linkend='var-BB_NUMBER_THREADS'>BB_NUMBER_THREADS</link></glossterm> variable | ||
| 200 | as long as there are tasks ready to run, i.e. tasks with all their | ||
| 201 | dependencies met. | ||
| 202 | </para> | ||
| 203 | |||
| 204 | <para> | ||
| 205 | As each task completes, a timestamp is written to the directory | ||
| 206 | specified by the <glossterm><link | ||
| 207 | linkend='var-STAMPS'>STAMPS</link></glossterm> variable (usually | ||
| 208 | <filename class="directory">build/tmp/stamps/*/</filename>). On | ||
| 209 | subsequent runs, BitBake looks at the <glossterm><link | ||
| 210 | linkend='var-STAMPS'>STAMPS</link></glossterm> | ||
| 211 | directory and will not rerun | ||
| 212 | tasks its already completed unless a timestamp is found to be invalid. | ||
| 213 | Currently, invalid timestamps are only considered on a per <filename | ||
| 214 | class="extension">.bb</filename> file basis so if for example the configure stamp has a timestamp greater than the | ||
| 215 | compile timestamp for a given target the compile task would rerun but this | ||
| 216 | has no effect on other providers depending on that target. This could | ||
| 217 | change or become configurable in future versions of BitBake. Some tasks | ||
| 218 | are marked as "nostamp" tasks which means no timestamp file will be written | ||
| 219 | and the task will always rerun. | ||
| 220 | </para> | ||
| 221 | |||
| 222 | <para>Once all the tasks have been completed BitBake exits.</para> | ||
| 223 | |||
| 224 | </section> | ||
| 225 | |||
| 226 | <section id='ref-bitbake-runtask'> | ||
| 227 | <title>Running a Task</title> | ||
| 228 | |||
| 229 | <para> | ||
| 230 | It's worth noting what BitBake does to run a task. A task can either | ||
| 231 | be a shell task or a python task. For shell tasks, BitBake writes a | ||
| 232 | shell script to <filename>${WORKDIR}/temp/run.do_taskname.pid</filename> | ||
| 233 | and then executes the script. The generated | ||
| 234 | shell script contains all the exported variables, and the shell functions | ||
| 235 | with all variables expanded. Output from the shell script is | ||
| 236 | sent to the file <filename>${WORKDIR}/temp/log.do_taskname.pid</filename>. | ||
| 237 | Looking at the | ||
| 238 | expanded shell functions in the run file and the output in the log files | ||
| 239 | is a useful debugging technique. | ||
| 240 | </para> | ||
| 241 | |||
| 242 | <para> | ||
| 243 | Python functions are executed internally to BitBake itself and | ||
| 244 | logging goes to the controlling terminal. Future versions of BitBake will | ||
| 245 | write the functions to files in a similar way to shell functions and | ||
| 246 | logging will also go to the log files in a similar way. | ||
| 247 | </para> | ||
| 248 | </section> | ||
| 249 | |||
| 250 | |||
| 251 | <section id='ref-bitbake-commandline'> | ||
| 252 | <title>Commandline</title> | ||
| 253 | |||
| 254 | <para> | ||
| 255 | To quote from "bitbake --help": | ||
| 256 | </para> | ||
| 257 | |||
| 258 | <screen>Usage: bitbake [options] [package ...] | ||
| 259 | |||
| 260 | Executes the specified task (default is 'build') for a given set of BitBake files. | ||
| 261 | It expects that BBFILES is defined, which is a space separated list of files to | ||
| 262 | be executed. BBFILES does support wildcards. | ||
| 263 | Default BBFILES are the .bb files in the current directory. | ||
| 264 | |||
| 265 | Options: | ||
| 266 | --version show program's version number and exit | ||
| 267 | -h, --help show this help message and exit | ||
| 268 | -b BUILDFILE, --buildfile=BUILDFILE | ||
| 269 | execute the task against this .bb file, rather than a | ||
| 270 | package from BBFILES. | ||
| 271 | -k, --continue continue as much as possible after an error. While the | ||
| 272 | target that failed, and those that depend on it, | ||
| 273 | cannot be remade, the other dependencies of these | ||
| 274 | targets can be processed all the same. | ||
| 275 | -a, --tryaltconfigs continue with builds by trying to use alternative | ||
| 276 | providers where possible. | ||
| 277 | -f, --force force run of specified cmd, regardless of stamp status | ||
| 278 | -c CMD, --cmd=CMD Specify task to execute. Note that this only executes | ||
| 279 | the specified task for the providee and the packages | ||
| 280 | it depends on, i.e. 'compile' does not implicitly call | ||
| 281 | stage for the dependencies (IOW: use only if you know | ||
| 282 | what you are doing). Depending on the base.bbclass a | ||
| 283 | listtasks tasks is defined and will show available | ||
| 284 | tasks | ||
| 285 | -r FILE, --read=FILE read the specified file before bitbake.conf | ||
| 286 | -v, --verbose output more chit-chat to the terminal | ||
| 287 | -D, --debug Increase the debug level. You can specify this more | ||
| 288 | than once. | ||
| 289 | -n, --dry-run don't execute, just go through the motions | ||
| 290 | -S, --dump-signatures | ||
| 291 | don't execute, just dump out the signature | ||
| 292 | construction information | ||
| 293 | -p, --parse-only quit after parsing the BB files (developers only) | ||
| 294 | -d, --disable-psyco disable using the psyco just-in-time compiler (not | ||
| 295 | recommended) | ||
| 296 | -s, --show-versions show current and preferred versions of all packages | ||
| 297 | -e, --environment show the global or per-package environment (this is | ||
| 298 | what used to be bbread) | ||
| 299 | -g, --graphviz emit the dependency trees of the specified packages in | ||
| 300 | the dot syntax | ||
| 301 | -I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED | ||
| 302 | Assume these dependencies don't exist and are already | ||
| 303 | provided (equivalent to ASSUME_PROVIDED). Useful to | ||
| 304 | make dependency graphs more appealing | ||
| 305 | -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS | ||
| 306 | Show debug logging for the specified logging domains | ||
| 307 | -P, --profile profile the command and print a report | ||
| 308 | -u UI, --ui=UI userinterface to use | ||
| 309 | --revisions-changed Set the exit code depending on whether upstream | ||
| 310 | floating revisions have changed or not</screen> | ||
| 311 | |||
| 312 | </section> | ||
| 313 | |||
| 314 | <section id='ref-bitbake-fetchers'> | ||
| 315 | <title>Fetchers</title> | ||
| 316 | |||
| 317 | <para> | ||
| 318 | As well as the containing the parsing and task/dependency handling | ||
| 319 | code, bitbake also contains a set of "fetcher" modules which allow | ||
| 320 | fetching of source code from various types of sources. Example | ||
| 321 | sources might be from disk with the metadata, from websites, from | ||
| 322 | remote shell accounts or from SCM systems like cvs/subversion/git. | ||
| 323 | </para> | ||
| 324 | |||
| 325 | <para> | ||
| 326 | The fetchers are usually triggered by entries in | ||
| 327 | <glossterm><link linkend='var-SRC_URI'>SRC_URI</link></glossterm>. Information about the | ||
| 328 | options and formats of entries for specific fetchers can be found in the | ||
| 329 | <ulink url='http://bitbake.berlios.de/manual/'>BitBake manual</ulink>. | ||
| 330 | </para> | ||
| 331 | |||
| 332 | <para> | ||
| 333 | One useful feature for certain SCM fetchers is the ability to | ||
| 334 | "auto-update" when the upstream SCM changes version. Since this | ||
| 335 | requires certain functionality from the SCM only certain systems | ||
| 336 | support it, currently Subversion, Bazaar and to a limited extent, Git. It | ||
| 337 | works using the <glossterm><link linkend='var-SRCREV'>SRCREV</link> | ||
| 338 | </glossterm> variable. See the <link linkend='platdev-appdev-srcrev'> | ||
| 339 | developing with an external SCM based project</link> section for more | ||
| 340 | information. | ||
| 341 | </para> | ||
| 342 | |||
| 343 | </section> | ||
| 344 | |||
| 345 | </appendix> | ||
| 346 | <!-- | ||
| 347 | vim: expandtab tw=80 ts=4 spell spelllang=en_gb | ||
| 348 | --> | ||
