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