summaryrefslogtreecommitdiffstats
path: root/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst571
1 files changed, 571 insertions, 0 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
new file mode 100644
index 0000000000..3c24e4e2cc
--- /dev/null
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-intro.rst
@@ -0,0 +1,571 @@
1========
2Overview
3========
4
5Welcome to the BitBake User Manual. This manual provides information on
6the BitBake tool. The information attempts to be as independent as
7possible regarding systems that use BitBake, such as OpenEmbedded and
8the Yocto Project. In some cases, scenarios or examples within the
9context of a build system are used in the manual to help with
10understanding. For these cases, the manual clearly states the context.
11
12.. _intro:
13
14Introduction
15============
16
17Fundamentally, BitBake is a generic task execution engine that allows
18shell and Python tasks to be run efficiently and in parallel while
19working within complex inter-task dependency constraints. One of
20BitBake's main users, OpenEmbedded, takes this core and builds embedded
21Linux software stacks using a task-oriented approach.
22
23Conceptually, BitBake is similar to GNU Make in some regards but has
24significant differences:
25
26- BitBake executes tasks according to provided metadata that builds up
27 the tasks. Metadata is stored in recipe (``.bb``) and related recipe
28 "append" (``.bbappend``) files, configuration (``.conf``) and
29 underlying include (``.inc``) files, and in class (``.bbclass``)
30 files. The metadata provides BitBake with instructions on what tasks
31 to run and the dependencies between those tasks.
32
33- BitBake includes a fetcher library for obtaining source code from
34 various places such as local files, source control systems, or
35 websites.
36
37- The instructions for each unit to be built (e.g. a piece of software)
38 are known as "recipe" files and contain all the information about the
39 unit (dependencies, source file locations, checksums, description and
40 so on).
41
42- BitBake includes a client/server abstraction and can be used from a
43 command line or used as a service over XML-RPC and has several
44 different user interfaces.
45
46History and Goals
47=================
48
49BitBake was originally a part of the OpenEmbedded project. It was
50inspired by the Portage package management system used by the Gentoo
51Linux distribution. On December 7, 2004, OpenEmbedded project team
52member Chris Larson split the project into two distinct pieces:
53
54- BitBake, a generic task executor
55
56- OpenEmbedded, a metadata set utilized by BitBake
57
58Today, BitBake is the primary basis of the
59`OpenEmbedded <http://www.openembedded.org/>`__ project, which is being
60used to build and maintain Linux distributions such as the `Angstrom
61Distribution <http://www.angstrom-distribution.org/>`__, and which is
62also being used as the build tool for Linux projects such as the `Yocto
63Project <http://www.yoctoproject.org>`__.
64
65Prior to BitBake, no other build tool adequately met the needs of an
66aspiring embedded Linux distribution. All of the build systems used by
67traditional desktop Linux distributions lacked important functionality,
68and none of the ad hoc Buildroot-based systems, prevalent in the
69embedded space, were scalable or maintainable.
70
71Some important original goals for BitBake were:
72
73- Handle cross-compilation.
74
75- Handle inter-package dependencies (build time on target architecture,
76 build time on native architecture, and runtime).
77
78- Support running any number of tasks within a given package,
79 including, but not limited to, fetching upstream sources, unpacking
80 them, patching them, configuring them, and so forth.
81
82- Be Linux distribution agnostic for both build and target systems.
83
84- Be architecture agnostic.
85
86- Support multiple build and target operating systems (e.g. Cygwin, the
87 BSDs, and so forth).
88
89- Be self-contained, rather than tightly integrated into the build
90 machine's root filesystem.
91
92- Handle conditional metadata on the target architecture, operating
93 system, distribution, and machine.
94
95- Be easy to use the tools to supply local metadata and packages
96 against which to operate.
97
98- Be easy to use BitBake to collaborate between multiple projects for
99 their builds.
100
101- Provide an inheritance mechanism to share common metadata between
102 many packages.
103
104Over time it became apparent that some further requirements were
105necessary:
106
107- Handle variants of a base recipe (e.g. native, sdk, and multilib).
108
109- Split metadata into layers and allow layers to enhance or override
110 other layers.
111
112- Allow representation of a given set of input variables to a task as a
113 checksum. Based on that checksum, allow acceleration of builds with
114 prebuilt components.
115
116BitBake satisfies all the original requirements and many more with
117extensions being made to the basic functionality to reflect the
118additional requirements. Flexibility and power have always been the
119priorities. BitBake is highly extensible and supports embedded Python
120code and execution of any arbitrary tasks.
121
122.. _Concepts:
123
124Concepts
125========
126
127BitBake is a program written in the Python language. At the highest
128level, BitBake interprets metadata, decides what tasks are required to
129run, and executes those tasks. Similar to GNU Make, BitBake controls how
130software is built. GNU Make achieves its control through "makefiles",
131while BitBake uses "recipes".
132
133BitBake extends the capabilities of a simple tool like GNU Make by
134allowing for the definition of much more complex tasks, such as
135assembling entire embedded Linux distributions.
136
137The remainder of this section introduces several concepts that should be
138understood in order to better leverage the power of BitBake.
139
140Recipes
141-------
142
143BitBake Recipes, which are denoted by the file extension ``.bb``, are
144the most basic metadata files. These recipe files provide BitBake with
145the following:
146
147- Descriptive information about the package (author, homepage, license,
148 and so on)
149
150- The version of the recipe
151
152- Existing dependencies (both build and runtime dependencies)
153
154- Where the source code resides and how to fetch it
155
156- Whether the source code requires any patches, where to find them, and
157 how to apply them
158
159- How to configure and compile the source code
160
161- How to assemble the generated artifacts into one or more installable
162 packages
163
164- Where on the target machine to install the package or packages
165 created
166
167Within the context of BitBake, or any project utilizing BitBake as its
168build system, files with the ``.bb`` extension are referred to as
169recipes.
170
171.. note::
172
173 The term "package" is also commonly used to describe recipes.
174 However, since the same word is used to describe packaged output from
175 a project, it is best to maintain a single descriptive term -
176 "recipes". Put another way, a single "recipe" file is quite capable
177 of generating a number of related but separately installable
178 "packages". In fact, that ability is fairly common.
179
180Configuration Files
181-------------------
182
183Configuration files, which are denoted by the ``.conf`` extension,
184define various configuration variables that govern the project's build
185process. These files fall into several areas that define machine
186configuration, distribution configuration, possible compiler tuning,
187general common configuration, and user configuration. The main
188configuration file is the sample ``bitbake.conf`` file, which is located
189within the BitBake source tree ``conf`` directory.
190
191Classes
192-------
193
194Class files, which are denoted by the ``.bbclass`` extension, contain
195information that is useful to share between metadata files. The BitBake
196source tree currently comes with one class metadata file called
197``base.bbclass``. You can find this file in the ``classes`` directory.
198The ``base.bbclass`` class files is special since it is always included
199automatically for all recipes and classes. This class contains
200definitions for standard basic tasks such as fetching, unpacking,
201configuring (empty by default), compiling (runs any Makefile present),
202installing (empty by default) and packaging (empty by default). These
203tasks are often overridden or extended by other classes added during the
204project development process.
205
206Layers
207------
208
209Layers allow you to isolate different types of customizations from each
210other. While you might find it tempting to keep everything in one layer
211when working on a single project, the more modular your metadata, the
212easier it is to cope with future changes.
213
214To illustrate how you can use layers to keep things modular, consider
215customizations you might make to support a specific target machine.
216These types of customizations typically reside in a special layer,
217rather than a general layer, called a Board Support Package (BSP) layer.
218Furthermore, the machine customizations should be isolated from recipes
219and metadata that support a new GUI environment, for example. This
220situation gives you a couple of layers: one for the machine
221configurations and one for the GUI environment. It is important to
222understand, however, that the BSP layer can still make machine-specific
223additions to recipes within the GUI environment layer without polluting
224the GUI layer itself with those machine-specific changes. You can
225accomplish this through a recipe that is a BitBake append
226(``.bbappend``) file.
227
228.. _append-bbappend-files:
229
230Append Files
231------------
232
233Append files, which are files that have the ``.bbappend`` file
234extension, extend or override information in an existing recipe file.
235
236BitBake expects every append file to have a corresponding recipe file.
237Furthermore, the append file and corresponding recipe file must use the
238same root filename. The filenames can differ only in the file type
239suffix used (e.g. ``formfactor_0.0.bb`` and
240``formfactor_0.0.bbappend``).
241
242Information in append files extends or overrides the information in the
243underlying, similarly-named recipe files.
244
245When you name an append file, you can use the "``%``" wildcard character
246to allow for matching recipe names. For example, suppose you have an
247append file named as follows: busybox_1.21.%.bbappend That append file
248would match any ``busybox_1.21.``\ x\ ``.bb`` version of the recipe. So,
249the append file would match the following recipe names:
250busybox_1.21.1.bb busybox_1.21.2.bb busybox_1.21.3.bb
251
252.. note::
253
254 The use of the "
255 %
256 " character is limited in that it only works directly in front of the
257 .bbappend
258 portion of the append file's name. You cannot use the wildcard
259 character in any other location of the name.
260
261If the ``busybox`` recipe was updated to ``busybox_1.3.0.bb``, the
262append name would not match. However, if you named the append file
263``busybox_1.%.bbappend``, then you would have a match.
264
265In the most general case, you could name the append file something as
266simple as ``busybox_%.bbappend`` to be entirely version independent.
267
268Obtaining BitBake
269=================
270
271You can obtain BitBake several different ways:
272
273- *Cloning BitBake:* Using Git to clone the BitBake source code
274 repository is the recommended method for obtaining BitBake. Cloning
275 the repository makes it easy to get bug fixes and have access to
276 stable branches and the master branch. Once you have cloned BitBake,
277 you should use the latest stable branch for development since the
278 master branch is for BitBake development and might contain less
279 stable changes.
280
281 You usually need a version of BitBake that matches the metadata you
282 are using. The metadata is generally backwards compatible but not
283 forward compatible.
284
285 Here is an example that clones the BitBake repository: $ git clone
286 git://git.openembedded.org/bitbake This command clones the BitBake
287 Git repository into a directory called ``bitbake``. Alternatively,
288 you can designate a directory after the ``git clone`` command if you
289 want to call the new directory something other than ``bitbake``. Here
290 is an example that names the directory ``bbdev``: $ git clone
291 git://git.openembedded.org/bitbake bbdev
292
293- *Installation using your Distribution Package Management System:*
294 This method is not recommended because the BitBake version that is
295 provided by your distribution, in most cases, is several releases
296 behind a snapshot of the BitBake repository.
297
298- *Taking a snapshot of BitBake:* Downloading a snapshot of BitBake
299 from the source code repository gives you access to a known branch or
300 release of BitBake.
301
302 .. note::
303
304 Cloning the Git repository, as described earlier, is the preferred
305 method for getting BitBake. Cloning the repository makes it easier
306 to update as patches are added to the stable branches.
307
308 The following example downloads a snapshot of BitBake version 1.17.0:
309 $ wget
310 http://git.openembedded.org/bitbake/snapshot/bitbake-1.17.0.tar.gz $
311 tar zxpvf bitbake-1.17.0.tar.gz After extraction of the tarball using
312 the tar utility, you have a directory entitled ``bitbake-1.17.0``.
313
314- *Using the BitBake that Comes With Your Build Checkout:* A final
315 possibility for getting a copy of BitBake is that it already comes
316 with your checkout of a larger BitBake-based build system, such as
317 Poky. Rather than manually checking out individual layers and gluing
318 them together yourself, you can check out an entire build system. The
319 checkout will already include a version of BitBake that has been
320 thoroughly tested for compatibility with the other components. For
321 information on how to check out a particular BitBake-based build
322 system, consult that build system's supporting documentation.
323
324.. _bitbake-user-manual-command:
325
326The BitBake Command
327===================
328
329The ``bitbake`` command is the primary interface to the BitBake tool.
330This section presents the BitBake command syntax and provides several
331execution examples.
332
333Usage and syntax
334----------------
335
336Following is the usage and syntax for BitBake: $ bitbake -h Usage:
337bitbake [options] [recipename/target recipe:do_task ...] Executes the
338specified task (default is 'build') for a given set of target recipes
339(.bb files). It is assumed there is a conf/bblayers.conf available in
340cwd or in BBPATH which will provide the layer, BBFILES and other
341configuration information. Options: --version show program's version
342number and exit -h, --help show this help message and exit -b BUILDFILE,
343--buildfile=BUILDFILE Execute tasks from a specific .bb recipe directly.
344WARNING: Does not handle any dependencies from other recipes. -k,
345--continue Continue as much as possible after an error. While the target
346that failed and anything depending on it cannot be built, as much as
347possible will be built before stopping. -f, --force Force the specified
348targets/task to run (invalidating any existing stamp file). -c CMD,
349--cmd=CMD Specify the task to execute. The exact options available
350depend on the metadata. Some examples might be 'compile' or
351'populate_sysroot' or 'listtasks' may give a list of the tasks
352available. -C INVALIDATE_STAMP, --clear-stamp=INVALIDATE_STAMP
353Invalidate the stamp for the specified task such as 'compile' and then
354run the default task for the specified target(s). -r PREFILE,
355--read=PREFILE Read the specified file before bitbake.conf. -R POSTFILE,
356--postread=POSTFILE Read the specified file after bitbake.conf. -v,
357--verbose Enable tracing of shell tasks (with 'set -x'). Also print
358bb.note(...) messages to stdout (in addition to writing them to
359${T}/log.do_<task>). -D, --debug Increase the debug level. You can
360specify this more than once. -D sets the debug level to 1, where only
361bb.debug(1, ...) messages are printed to stdout; -DD sets the debug
362level to 2, where both bb.debug(1, ...) and bb.debug(2, ...) messages
363are printed; etc. Without -D, no debug messages are printed. Note that
364-D only affects output to stdout. All debug messages are written to
365${T}/log.do_taskname, regardless of the debug level. -q, --quiet Output
366less log message data to the terminal. You can specify this more than
367once. -n, --dry-run Don't execute, just go through the motions. -S
368SIGNATURE_HANDLER, --dump-signatures=SIGNATURE_HANDLER Dump out the
369signature construction information, with no task execution. The
370SIGNATURE_HANDLER parameter is passed to the handler. Two common values
371are none and printdiff but the handler may define more/less. none means
372only dump the signature, printdiff means compare the dumped signature
373with the cached one. -p, --parse-only Quit after parsing the BB recipes.
374-s, --show-versions Show current and preferred versions of all recipes.
375-e, --environment Show the global or per-recipe environment complete
376with information about where variables were set/changed. -g, --graphviz
377Save dependency tree information for the specified targets in the dot
378syntax. -I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED
379Assume these dependencies don't exist and are already provided
380(equivalent to ASSUME_PROVIDED). Useful to make dependency graphs more
381appealing -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS Show debug
382logging for the specified logging domains -P, --profile Profile the
383command and save reports. -u UI, --ui=UI The user interface to use
384(knotty, ncurses or taskexp - default knotty). --token=XMLRPCTOKEN
385Specify the connection token to be used when connecting to a remote
386server. --revisions-changed Set the exit code depending on whether
387upstream floating revisions have changed or not. --server-only Run
388bitbake without a UI, only starting a server (cooker) process. -B BIND,
389--bind=BIND The name/address for the bitbake xmlrpc server to bind to.
390-T SERVER_TIMEOUT, --idle-timeout=SERVER_TIMEOUT Set timeout to unload
391bitbake server due to inactivity, set to -1 means no unload, default:
392Environment variable BB_SERVER_TIMEOUT. --no-setscene Do not run any
393setscene tasks. sstate will be ignored and everything needed, built.
394--setscene-only Only run setscene tasks, don't run any real tasks.
395--remote-server=REMOTE_SERVER Connect to the specified server. -m,
396--kill-server Terminate any running bitbake server. --observe-only
397Connect to a server as an observing-only client. --status-only Check the
398status of the remote bitbake server. -w WRITEEVENTLOG,
399--write-log=WRITEEVENTLOG Writes the event log of the build to a bitbake
400event json file. Use '' (empty string) to assign the name automatically.
401--runall=RUNALL Run the specified task for any recipe in the taskgraph
402of the specified target (even if it wouldn't otherwise have run).
403--runonly=RUNONLY Run only the specified task within the taskgraph of
404the specified targets (and any task dependencies those tasks may have).
405
406.. _bitbake-examples:
407
408Examples
409--------
410
411This section presents some examples showing how to use BitBake.
412
413.. _example-executing-a-task-against-a-single-recipe:
414
415Executing a Task Against a Single Recipe
416~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
417
418Executing tasks for a single recipe file is relatively simple. You
419specify the file in question, and BitBake parses it and executes the
420specified task. If you do not specify a task, BitBake executes the
421default task, which is "build”. BitBake obeys inter-task dependencies
422when doing so.
423
424The following command runs the build task, which is the default task, on
425the ``foo_1.0.bb`` recipe file: $ bitbake -b foo_1.0.bb The following
426command runs the clean task on the ``foo.bb`` recipe file: $ bitbake -b
427foo.bb -c clean
428
429.. note::
430
431 The "-b" option explicitly does not handle recipe dependencies. Other
432 than for debugging purposes, it is instead recommended that you use
433 the syntax presented in the next section.
434
435Executing Tasks Against a Set of Recipe Files
436~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
437
438There are a number of additional complexities introduced when one wants
439to manage multiple ``.bb`` files. Clearly there needs to be a way to
440tell BitBake what files are available and, of those, which you want to
441execute. There also needs to be a way for each recipe to express its
442dependencies, both for build-time and runtime. There must be a way for
443you to express recipe preferences when multiple recipes provide the same
444functionality, or when there are multiple versions of a recipe.
445
446The ``bitbake`` command, when not using "--buildfile" or "-b" only
447accepts a "PROVIDES". You cannot provide anything else. By default, a
448recipe file generally "PROVIDES" its "packagename" as shown in the
449following example: $ bitbake foo This next example "PROVIDES" the
450package name and also uses the "-c" option to tell BitBake to just
451execute the ``do_clean`` task: $ bitbake -c clean foo
452
453Executing a List of Task and Recipe Combinations
454~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
455
456The BitBake command line supports specifying different tasks for
457individual targets when you specify multiple targets. For example,
458suppose you had two targets (or recipes) ``myfirstrecipe`` and
459``mysecondrecipe`` and you needed BitBake to run ``taskA`` for the first
460recipe and ``taskB`` for the second recipe: $ bitbake
461myfirstrecipe:do_taskA mysecondrecipe:do_taskB
462
463Generating Dependency Graphs
464~~~~~~~~~~~~~~~~~~~~~~~~~~~~
465
466BitBake is able to generate dependency graphs using the ``dot`` syntax.
467You can convert these graphs into images using the ``dot`` tool from
468`Graphviz <http://www.graphviz.org>`__.
469
470When you generate a dependency graph, BitBake writes two files to the
471current working directory:
472
473- *``task-depends.dot``:* Shows dependencies between tasks. These
474 dependencies match BitBake's internal task execution list.
475
476- *``pn-buildlist``:* Shows a simple list of targets that are to be
477 built.
478
479To stop depending on common depends, use the "-I" depend option and
480BitBake omits them from the graph. Leaving this information out can
481produce more readable graphs. This way, you can remove from the graph
482``DEPENDS`` from inherited classes such as ``base.bbclass``.
483
484Here are two examples that create dependency graphs. The second example
485omits depends common in OpenEmbedded from the graph: $ bitbake -g foo $
486bitbake -g -I virtual/kernel -I eglibc foo
487
488Executing a Multiple Configuration Build
489~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
490
491BitBake is able to build multiple images or packages using a single
492command where the different targets require different configurations
493(multiple configuration builds). Each target, in this scenario, is
494referred to as a "multiconfig".
495
496To accomplish a multiple configuration build, you must define each
497target's configuration separately using a parallel configuration file in
498the build directory. The location for these multiconfig configuration
499files is specific. They must reside in the current build directory in a
500sub-directory of ``conf`` named ``multiconfig``. Following is an example
501for two separate targets:
502
503The reason for this required file hierarchy is because the ``BBPATH``
504variable is not constructed until the layers are parsed. Consequently,
505using the configuration file as a pre-configuration file is not possible
506unless it is located in the current working directory.
507
508Minimally, each configuration file must define the machine and the
509temporary directory BitBake uses for the build. Suggested practice
510dictates that you do not overlap the temporary directories used during
511the builds.
512
513Aside from separate configuration files for each target, you must also
514enable BitBake to perform multiple configuration builds. Enabling is
515accomplished by setting the
516```BBMULTICONFIG`` <#var-bb-BBMULTICONFIG>`__ variable in the
517``local.conf`` configuration file. As an example, suppose you had
518configuration files for ``target1`` and ``target2`` defined in the build
519directory. The following statement in the ``local.conf`` file both
520enables BitBake to perform multiple configuration builds and specifies
521the two extra multiconfigs: BBMULTICONFIG = "target1 target2"
522
523Once the target configuration files are in place and BitBake has been
524enabled to perform multiple configuration builds, use the following
525command form to start the builds: $ bitbake [mc:multiconfigname:]target
526[[[mc:multiconfigname:]target] ... ] Here is an example for two extra
527multiconfigs: ``target1`` and ``target2``: $ bitbake mc::target
528mc:target1:target mc:target2:target
529
530.. _bb-enabling-multiple-configuration-build-dependencies:
531
532Enabling Multiple Configuration Build Dependencies
533~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
534
535Sometimes dependencies can exist between targets (multiconfigs) in a
536multiple configuration build. For example, suppose that in order to
537build an image for a particular architecture, the root filesystem of
538another build for a different architecture needs to exist. In other
539words, the image for the first multiconfig depends on the root
540filesystem of the second multiconfig. This dependency is essentially
541that the task in the recipe that builds one multiconfig is dependent on
542the completion of the task in the recipe that builds another
543multiconfig.
544
545To enable dependencies in a multiple configuration build, you must
546declare the dependencies in the recipe using the following statement
547form: task_or_package[mcdepends] =
548"mc:from_multiconfig:to_multiconfig:recipe_name:task_on_which_to_depend"
549To better show how to use this statement, consider an example with two
550multiconfigs: ``target1`` and ``target2``: image_task[mcdepends] =
551"mc:target1:target2:image2:rootfs_task" In this example, the
552from_multiconfig is "target1" and the to_multiconfig is "target2". The
553task on which the image whose recipe contains image_task depends on the
554completion of the rootfs_task used to build out image2, which is
555associated with the "target2" multiconfig.
556
557Once you set up this dependency, you can build the "target1" multiconfig
558using a BitBake command as follows: $ bitbake mc:target1:image1 This
559command executes all the tasks needed to create image1 for the "target1"
560multiconfig. Because of the dependency, BitBake also executes through
561the rootfs_task for the "target2" multiconfig build.
562
563Having a recipe depend on the root filesystem of another build might not
564seem that useful. Consider this change to the statement in the image1
565recipe: image_task[mcdepends] = "mc:target1:target2:image2:image_task"
566In this case, BitBake must create image2 for the "target2" build since
567the "target1" build depends on it.
568
569Because "target1" and "target2" are enabled for multiple configuration
570builds and have separate configuration files, BitBake places the
571artifacts for each build in the respective temporary build directories.