xref: /OK3568_Linux_fs/yocto/poky/bitbake/doc/bitbake-user-manual/bitbake-user-manual-execution.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: CC-BY-2.5
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=========
4*4882a593SmuzhiyunExecution
5*4882a593Smuzhiyun=========
6*4882a593Smuzhiyun
7*4882a593Smuzhiyun|
8*4882a593Smuzhiyun
9*4882a593SmuzhiyunThe primary purpose for running BitBake is to produce some kind of
10*4882a593Smuzhiyunoutput such as a single installable package, a kernel, a software
11*4882a593Smuzhiyundevelopment kit, or even a full, board-specific bootable Linux image,
12*4882a593Smuzhiyuncomplete with bootloader, kernel, and root filesystem. Of course, you
13*4882a593Smuzhiyuncan execute the ``bitbake`` command with options that cause it to
14*4882a593Smuzhiyunexecute single tasks, compile single recipe files, capture or clear
15*4882a593Smuzhiyundata, or simply return information about the execution environment.
16*4882a593Smuzhiyun
17*4882a593SmuzhiyunThis chapter describes BitBake's execution process from start to finish
18*4882a593Smuzhiyunwhen you use it to create an image. The execution process is launched
19*4882a593Smuzhiyunusing the following command form::
20*4882a593Smuzhiyun
21*4882a593Smuzhiyun  $ bitbake target
22*4882a593Smuzhiyun
23*4882a593SmuzhiyunFor information on
24*4882a593Smuzhiyunthe BitBake command and its options, see ":ref:`The BitBake Command
25*4882a593Smuzhiyun<bitbake-user-manual-command>`" section.
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun.. note::
28*4882a593Smuzhiyun
29*4882a593Smuzhiyun   Prior to executing BitBake, you should take advantage of available
30*4882a593Smuzhiyun   parallel thread execution on your build host by setting the
31*4882a593Smuzhiyun   :term:`BB_NUMBER_THREADS` variable in
32*4882a593Smuzhiyun   your project's ``local.conf`` configuration file.
33*4882a593Smuzhiyun
34*4882a593Smuzhiyun   A common method to determine this value for your build host is to run
35*4882a593Smuzhiyun   the following::
36*4882a593Smuzhiyun
37*4882a593Smuzhiyun     $ grep processor /proc/cpuinfo
38*4882a593Smuzhiyun
39*4882a593Smuzhiyun   This command returns
40*4882a593Smuzhiyun   the number of processors, which takes into account hyper-threading.
41*4882a593Smuzhiyun   Thus, a quad-core build host with hyper-threading most likely shows
42*4882a593Smuzhiyun   eight processors, which is the value you would then assign to
43*4882a593Smuzhiyun   :term:`BB_NUMBER_THREADS`.
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun   A possibly simpler solution is that some Linux distributions (e.g.
46*4882a593Smuzhiyun   Debian and Ubuntu) provide the ``ncpus`` command.
47*4882a593Smuzhiyun
48*4882a593SmuzhiyunParsing the Base Configuration Metadata
49*4882a593Smuzhiyun=======================================
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunThe first thing BitBake does is parse base configuration metadata. Base
52*4882a593Smuzhiyunconfiguration metadata consists of your project's ``bblayers.conf`` file
53*4882a593Smuzhiyunto determine what layers BitBake needs to recognize, all necessary
54*4882a593Smuzhiyun``layer.conf`` files (one from each layer), and ``bitbake.conf``. The
55*4882a593Smuzhiyundata itself is of various types:
56*4882a593Smuzhiyun
57*4882a593Smuzhiyun-  **Recipes:** Details about particular pieces of software.
58*4882a593Smuzhiyun
59*4882a593Smuzhiyun-  **Class Data:** An abstraction of common build information (e.g. how to
60*4882a593Smuzhiyun   build a Linux kernel).
61*4882a593Smuzhiyun
62*4882a593Smuzhiyun-  **Configuration Data:** Machine-specific settings, policy decisions,
63*4882a593Smuzhiyun   and so forth. Configuration data acts as the glue to bind everything
64*4882a593Smuzhiyun   together.
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunThe ``layer.conf`` files are used to construct key variables such as
67*4882a593Smuzhiyun:term:`BBPATH` and :term:`BBFILES`.
68*4882a593Smuzhiyun:term:`BBPATH` is used to search for configuration and class files under the
69*4882a593Smuzhiyun``conf`` and ``classes`` directories, respectively. :term:`BBFILES` is used
70*4882a593Smuzhiyunto locate both recipe and recipe append files (``.bb`` and
71*4882a593Smuzhiyun``.bbappend``). If there is no ``bblayers.conf`` file, it is assumed the
72*4882a593Smuzhiyunuser has set the :term:`BBPATH` and :term:`BBFILES` directly in the environment.
73*4882a593Smuzhiyun
74*4882a593SmuzhiyunNext, the ``bitbake.conf`` file is located using the :term:`BBPATH` variable
75*4882a593Smuzhiyunthat was just constructed. The ``bitbake.conf`` file may also include
76*4882a593Smuzhiyunother configuration files using the ``include`` or ``require``
77*4882a593Smuzhiyundirectives.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunPrior to parsing configuration files, BitBake looks at certain
80*4882a593Smuzhiyunvariables, including:
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun-  :term:`BB_ENV_PASSTHROUGH`
83*4882a593Smuzhiyun-  :term:`BB_ENV_PASSTHROUGH_ADDITIONS`
84*4882a593Smuzhiyun-  :term:`BB_PRESERVE_ENV`
85*4882a593Smuzhiyun-  :term:`BB_ORIGENV`
86*4882a593Smuzhiyun-  :term:`BITBAKE_UI`
87*4882a593Smuzhiyun
88*4882a593SmuzhiyunThe first four variables in this list relate to how BitBake treats shell
89*4882a593Smuzhiyunenvironment variables during task execution. By default, BitBake cleans
90*4882a593Smuzhiyunthe environment variables and provides tight control over the shell
91*4882a593Smuzhiyunexecution environment. However, through the use of these first four
92*4882a593Smuzhiyunvariables, you can apply your control regarding the environment
93*4882a593Smuzhiyunvariables allowed to be used by BitBake in the shell during execution of
94*4882a593Smuzhiyuntasks. See the
95*4882a593Smuzhiyun":ref:`bitbake-user-manual/bitbake-user-manual-metadata:Passing Information Into the Build Task Environment`"
96*4882a593Smuzhiyunsection and the information about these variables in the variable
97*4882a593Smuzhiyunglossary for more information on how they work and on how to use them.
98*4882a593Smuzhiyun
99*4882a593SmuzhiyunThe base configuration metadata is global and therefore affects all
100*4882a593Smuzhiyunrecipes and tasks that are executed.
101*4882a593Smuzhiyun
102*4882a593SmuzhiyunBitBake first searches the current working directory for an optional
103*4882a593Smuzhiyun``conf/bblayers.conf`` configuration file. This file is expected to
104*4882a593Smuzhiyuncontain a :term:`BBLAYERS` variable that is a
105*4882a593Smuzhiyunspace-delimited list of 'layer' directories. Recall that if BitBake
106*4882a593Smuzhiyuncannot find a ``bblayers.conf`` file, then it is assumed the user has
107*4882a593Smuzhiyunset the :term:`BBPATH` and :term:`BBFILES` variables directly in the
108*4882a593Smuzhiyunenvironment.
109*4882a593Smuzhiyun
110*4882a593SmuzhiyunFor each directory (layer) in this list, a ``conf/layer.conf`` file is
111*4882a593Smuzhiyunlocated and parsed with the :term:`LAYERDIR` variable
112*4882a593Smuzhiyunbeing set to the directory where the layer was found. The idea is these
113*4882a593Smuzhiyunfiles automatically set up :term:`BBPATH` and other
114*4882a593Smuzhiyunvariables correctly for a given build directory.
115*4882a593Smuzhiyun
116*4882a593SmuzhiyunBitBake then expects to find the ``conf/bitbake.conf`` file somewhere in
117*4882a593Smuzhiyunthe user-specified :term:`BBPATH`. That configuration file generally has
118*4882a593Smuzhiyuninclude directives to pull in any other metadata such as files specific
119*4882a593Smuzhiyunto the architecture, the machine, the local environment, and so forth.
120*4882a593Smuzhiyun
121*4882a593SmuzhiyunOnly variable definitions and include directives are allowed in BitBake
122*4882a593Smuzhiyun``.conf`` files. Some variables directly influence BitBake's behavior.
123*4882a593SmuzhiyunThese variables might have been set from the environment depending on
124*4882a593Smuzhiyunthe environment variables previously mentioned or set in the
125*4882a593Smuzhiyunconfiguration files. The ":ref:`bitbake-user-manual/bitbake-user-manual-ref-variables:Variables Glossary`"
126*4882a593Smuzhiyunchapter presents a full list of
127*4882a593Smuzhiyunvariables.
128*4882a593Smuzhiyun
129*4882a593SmuzhiyunAfter parsing configuration files, BitBake uses its rudimentary
130*4882a593Smuzhiyuninheritance mechanism, which is through class files, to inherit some
131*4882a593Smuzhiyunstandard classes. BitBake parses a class when the inherit directive
132*4882a593Smuzhiyunresponsible for getting that class is encountered.
133*4882a593Smuzhiyun
134*4882a593SmuzhiyunThe ``base.bbclass`` file is always included. Other classes that are
135*4882a593Smuzhiyunspecified in the configuration using the
136*4882a593Smuzhiyun:term:`INHERIT` variable are also included. BitBake
137*4882a593Smuzhiyunsearches for class files in a ``classes`` subdirectory under the paths
138*4882a593Smuzhiyunin :term:`BBPATH` in the same way as configuration files.
139*4882a593Smuzhiyun
140*4882a593SmuzhiyunA good way to get an idea of the configuration files and the class files
141*4882a593Smuzhiyunused in your execution environment is to run the following BitBake
142*4882a593Smuzhiyuncommand::
143*4882a593Smuzhiyun
144*4882a593Smuzhiyun  $ bitbake -e > mybb.log
145*4882a593Smuzhiyun
146*4882a593SmuzhiyunExamining the top of the ``mybb.log``
147*4882a593Smuzhiyunshows you the many configuration files and class files used in your
148*4882a593Smuzhiyunexecution environment.
149*4882a593Smuzhiyun
150*4882a593Smuzhiyun.. note::
151*4882a593Smuzhiyun
152*4882a593Smuzhiyun   You need to be aware of how BitBake parses curly braces. If a recipe
153*4882a593Smuzhiyun   uses a closing curly brace within the function and the character has
154*4882a593Smuzhiyun   no leading spaces, BitBake produces a parsing error. If you use a
155*4882a593Smuzhiyun   pair of curly braces in a shell function, the closing curly brace
156*4882a593Smuzhiyun   must not be located at the start of the line without leading spaces.
157*4882a593Smuzhiyun
158*4882a593Smuzhiyun   Here is an example that causes BitBake to produce a parsing error::
159*4882a593Smuzhiyun
160*4882a593Smuzhiyun      fakeroot create_shar() {
161*4882a593Smuzhiyun         cat << "EOF" > ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
162*4882a593Smuzhiyun      usage()
163*4882a593Smuzhiyun      {
164*4882a593Smuzhiyun         echo "test"
165*4882a593Smuzhiyun         ######  The following "}" at the start of the line causes a parsing error ######
166*4882a593Smuzhiyun      }
167*4882a593Smuzhiyun      EOF
168*4882a593Smuzhiyun      }
169*4882a593Smuzhiyun
170*4882a593Smuzhiyun      Writing the recipe this way avoids the error:
171*4882a593Smuzhiyun      fakeroot create_shar() {
172*4882a593Smuzhiyun         cat << "EOF" > ${SDK_DEPLOY}/${TOOLCHAIN_OUTPUTNAME}.sh
173*4882a593Smuzhiyun      usage()
174*4882a593Smuzhiyun      {
175*4882a593Smuzhiyun         echo "test"
176*4882a593Smuzhiyun         ###### The following "}" with a leading space at the start of the line avoids the error ######
177*4882a593Smuzhiyun       }
178*4882a593Smuzhiyun      EOF
179*4882a593Smuzhiyun      }
180*4882a593Smuzhiyun
181*4882a593SmuzhiyunLocating and Parsing Recipes
182*4882a593Smuzhiyun============================
183*4882a593Smuzhiyun
184*4882a593SmuzhiyunDuring the configuration phase, BitBake will have set
185*4882a593Smuzhiyun:term:`BBFILES`. BitBake now uses it to construct a
186*4882a593Smuzhiyunlist of recipes to parse, along with any append files (``.bbappend``) to
187*4882a593Smuzhiyunapply. :term:`BBFILES` is a space-separated list of available files and
188*4882a593Smuzhiyunsupports wildcards. An example would be::
189*4882a593Smuzhiyun
190*4882a593Smuzhiyun  BBFILES = "/path/to/bbfiles/*.bb /path/to/appends/*.bbappend"
191*4882a593Smuzhiyun
192*4882a593SmuzhiyunBitBake parses each
193*4882a593Smuzhiyunrecipe and append file located with :term:`BBFILES` and stores the values of
194*4882a593Smuzhiyunvarious variables into the datastore.
195*4882a593Smuzhiyun
196*4882a593Smuzhiyun.. note::
197*4882a593Smuzhiyun
198*4882a593Smuzhiyun   Append files are applied in the order they are encountered in BBFILES.
199*4882a593Smuzhiyun
200*4882a593SmuzhiyunFor each file, a fresh copy of the base configuration is made, then the
201*4882a593Smuzhiyunrecipe is parsed line by line. Any inherit statements cause BitBake to
202*4882a593Smuzhiyunfind and then parse class files (``.bbclass``) using
203*4882a593Smuzhiyun:term:`BBPATH` as the search path. Finally, BitBake
204*4882a593Smuzhiyunparses in order any append files found in :term:`BBFILES`.
205*4882a593Smuzhiyun
206*4882a593SmuzhiyunOne common convention is to use the recipe filename to define pieces of
207*4882a593Smuzhiyunmetadata. For example, in ``bitbake.conf`` the recipe name and version
208*4882a593Smuzhiyunare used to set the variables :term:`PN` and
209*4882a593Smuzhiyun:term:`PV`::
210*4882a593Smuzhiyun
211*4882a593Smuzhiyun   PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
212*4882a593Smuzhiyun   PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
213*4882a593Smuzhiyun
214*4882a593SmuzhiyunIn this example, a recipe called "something_1.2.3.bb" would set
215*4882a593Smuzhiyun:term:`PN` to "something" and :term:`PV` to "1.2.3".
216*4882a593Smuzhiyun
217*4882a593SmuzhiyunBy the time parsing is complete for a recipe, BitBake has a list of
218*4882a593Smuzhiyuntasks that the recipe defines and a set of data consisting of keys and
219*4882a593Smuzhiyunvalues as well as dependency information about the tasks.
220*4882a593Smuzhiyun
221*4882a593SmuzhiyunBitBake does not need all of this information. It only needs a small
222*4882a593Smuzhiyunsubset of the information to make decisions about the recipe.
223*4882a593SmuzhiyunConsequently, BitBake caches the values in which it is interested and
224*4882a593Smuzhiyundoes not store the rest of the information. Experience has shown it is
225*4882a593Smuzhiyunfaster to re-parse the metadata than to try and write it out to the disk
226*4882a593Smuzhiyunand then reload it.
227*4882a593Smuzhiyun
228*4882a593SmuzhiyunWhere possible, subsequent BitBake commands reuse this cache of recipe
229*4882a593Smuzhiyuninformation. The validity of this cache is determined by first computing
230*4882a593Smuzhiyuna checksum of the base configuration data (see
231*4882a593Smuzhiyun:term:`BB_HASHCONFIG_IGNORE_VARS`) and
232*4882a593Smuzhiyunthen checking if the checksum matches. If that checksum matches what is
233*4882a593Smuzhiyunin the cache and the recipe and class files have not changed, BitBake is
234*4882a593Smuzhiyunable to use the cache. BitBake then reloads the cached information about
235*4882a593Smuzhiyunthe recipe instead of reparsing it from scratch.
236*4882a593Smuzhiyun
237*4882a593SmuzhiyunRecipe file collections exist to allow the user to have multiple
238*4882a593Smuzhiyunrepositories of ``.bb`` files that contain the same exact package. For
239*4882a593Smuzhiyunexample, one could easily use them to make one's own local copy of an
240*4882a593Smuzhiyunupstream repository, but with custom modifications that one does not
241*4882a593Smuzhiyunwant upstream. Here is an example::
242*4882a593Smuzhiyun
243*4882a593Smuzhiyun  BBFILES = "/stuff/openembedded/*/*.bb /stuff/openembedded.modified/*/*.bb"
244*4882a593Smuzhiyun  BBFILE_COLLECTIONS = "upstream local"
245*4882a593Smuzhiyun  BBFILE_PATTERN_upstream = "^/stuff/openembedded/"
246*4882a593Smuzhiyun  BBFILE_PATTERN_local = "^/stuff/openembedded.modified/"
247*4882a593Smuzhiyun  BBFILE_PRIORITY_upstream = "5"
248*4882a593Smuzhiyun  BBFILE_PRIORITY_local = "10"
249*4882a593Smuzhiyun
250*4882a593Smuzhiyun.. note::
251*4882a593Smuzhiyun
252*4882a593Smuzhiyun   The layers mechanism is now the preferred method of collecting code.
253*4882a593Smuzhiyun   While the collections code remains, its main use is to set layer
254*4882a593Smuzhiyun   priorities and to deal with overlap (conflicts) between layers.
255*4882a593Smuzhiyun
256*4882a593Smuzhiyun.. _bb-bitbake-providers:
257*4882a593Smuzhiyun
258*4882a593SmuzhiyunProviders
259*4882a593Smuzhiyun=========
260*4882a593Smuzhiyun
261*4882a593SmuzhiyunAssuming BitBake has been instructed to execute a target and that all
262*4882a593Smuzhiyunthe recipe files have been parsed, BitBake starts to figure out how to
263*4882a593Smuzhiyunbuild the target. BitBake looks through the :term:`PROVIDES` list for each
264*4882a593Smuzhiyunof the recipes. A :term:`PROVIDES` list is the list of names by which the
265*4882a593Smuzhiyunrecipe can be known. Each recipe's :term:`PROVIDES` list is created
266*4882a593Smuzhiyunimplicitly through the recipe's :term:`PN` variable and
267*4882a593Smuzhiyunexplicitly through the recipe's :term:`PROVIDES`
268*4882a593Smuzhiyunvariable, which is optional.
269*4882a593Smuzhiyun
270*4882a593SmuzhiyunWhen a recipe uses :term:`PROVIDES`, that recipe's functionality can be
271*4882a593Smuzhiyunfound under an alternative name or names other than the implicit :term:`PN`
272*4882a593Smuzhiyunname. As an example, suppose a recipe named ``keyboard_1.0.bb``
273*4882a593Smuzhiyuncontained the following::
274*4882a593Smuzhiyun
275*4882a593Smuzhiyun  PROVIDES += "fullkeyboard"
276*4882a593Smuzhiyun
277*4882a593SmuzhiyunThe :term:`PROVIDES`
278*4882a593Smuzhiyunlist for this recipe becomes "keyboard", which is implicit, and
279*4882a593Smuzhiyun"fullkeyboard", which is explicit. Consequently, the functionality found
280*4882a593Smuzhiyunin ``keyboard_1.0.bb`` can be found under two different names.
281*4882a593Smuzhiyun
282*4882a593Smuzhiyun.. _bb-bitbake-preferences:
283*4882a593Smuzhiyun
284*4882a593SmuzhiyunPreferences
285*4882a593Smuzhiyun===========
286*4882a593Smuzhiyun
287*4882a593SmuzhiyunThe :term:`PROVIDES` list is only part of the solution for figuring out a
288*4882a593Smuzhiyuntarget's recipes. Because targets might have multiple providers, BitBake
289*4882a593Smuzhiyunneeds to prioritize providers by determining provider preferences.
290*4882a593Smuzhiyun
291*4882a593SmuzhiyunA common example in which a target has multiple providers is
292*4882a593Smuzhiyun"virtual/kernel", which is on the :term:`PROVIDES` list for each kernel
293*4882a593Smuzhiyunrecipe. Each machine often selects the best kernel provider by using a
294*4882a593Smuzhiyunline similar to the following in the machine configuration file::
295*4882a593Smuzhiyun
296*4882a593Smuzhiyun  PREFERRED_PROVIDER_virtual/kernel = "linux-yocto"
297*4882a593Smuzhiyun
298*4882a593SmuzhiyunThe default :term:`PREFERRED_PROVIDER` is the provider
299*4882a593Smuzhiyunwith the same name as the target. BitBake iterates through each target
300*4882a593Smuzhiyunit needs to build and resolves them and their dependencies using this
301*4882a593Smuzhiyunprocess.
302*4882a593Smuzhiyun
303*4882a593SmuzhiyunUnderstanding how providers are chosen is made complicated by the fact
304*4882a593Smuzhiyunthat multiple versions might exist for a given provider. BitBake
305*4882a593Smuzhiyundefaults to the highest version of a provider. Version comparisons are
306*4882a593Smuzhiyunmade using the same method as Debian. You can use the
307*4882a593Smuzhiyun:term:`PREFERRED_VERSION` variable to
308*4882a593Smuzhiyunspecify a particular version. You can influence the order by using the
309*4882a593Smuzhiyun:term:`DEFAULT_PREFERENCE` variable.
310*4882a593Smuzhiyun
311*4882a593SmuzhiyunBy default, files have a preference of "0". Setting
312*4882a593Smuzhiyun:term:`DEFAULT_PREFERENCE` to "-1" makes the recipe unlikely to be used
313*4882a593Smuzhiyununless it is explicitly referenced. Setting :term:`DEFAULT_PREFERENCE` to
314*4882a593Smuzhiyun"1" makes it likely the recipe is used. :term:`PREFERRED_VERSION` overrides
315*4882a593Smuzhiyunany :term:`DEFAULT_PREFERENCE` setting. :term:`DEFAULT_PREFERENCE` is often used
316*4882a593Smuzhiyunto mark newer and more experimental recipe versions until they have
317*4882a593Smuzhiyunundergone sufficient testing to be considered stable.
318*4882a593Smuzhiyun
319*4882a593SmuzhiyunWhen there are multiple "versions" of a given recipe, BitBake defaults
320*4882a593Smuzhiyunto selecting the most recent version, unless otherwise specified. If the
321*4882a593Smuzhiyunrecipe in question has a
322*4882a593Smuzhiyun:term:`DEFAULT_PREFERENCE` set lower than
323*4882a593Smuzhiyunthe other recipes (default is 0), then it will not be selected. This
324*4882a593Smuzhiyunallows the person or persons maintaining the repository of recipe files
325*4882a593Smuzhiyunto specify their preference for the default selected version.
326*4882a593SmuzhiyunAdditionally, the user can specify their preferred version.
327*4882a593Smuzhiyun
328*4882a593SmuzhiyunIf the first recipe is named ``a_1.1.bb``, then the
329*4882a593Smuzhiyun:term:`PN` variable will be set to "a", and the
330*4882a593Smuzhiyun:term:`PV` variable will be set to 1.1.
331*4882a593Smuzhiyun
332*4882a593SmuzhiyunThus, if a recipe named ``a_1.2.bb`` exists, BitBake will choose 1.2 by
333*4882a593Smuzhiyundefault. However, if you define the following variable in a ``.conf``
334*4882a593Smuzhiyunfile that BitBake parses, you can change that preference::
335*4882a593Smuzhiyun
336*4882a593Smuzhiyun  PREFERRED_VERSION_a = "1.1"
337*4882a593Smuzhiyun
338*4882a593Smuzhiyun.. note::
339*4882a593Smuzhiyun
340*4882a593Smuzhiyun   It is common for a recipe to provide two versions -- a stable,
341*4882a593Smuzhiyun   numbered (and preferred) version, and a version that is automatically
342*4882a593Smuzhiyun   checked out from a source code repository that is considered more
343*4882a593Smuzhiyun   "bleeding edge" but can be selected only explicitly.
344*4882a593Smuzhiyun
345*4882a593Smuzhiyun   For example, in the OpenEmbedded codebase, there is a standard,
346*4882a593Smuzhiyun   versioned recipe file for BusyBox, ``busybox_1.22.1.bb``, but there
347*4882a593Smuzhiyun   is also a Git-based version, ``busybox_git.bb``, which explicitly
348*4882a593Smuzhiyun   contains the line ::
349*4882a593Smuzhiyun
350*4882a593Smuzhiyun     DEFAULT_PREFERENCE = "-1"
351*4882a593Smuzhiyun
352*4882a593Smuzhiyun   to ensure that the
353*4882a593Smuzhiyun   numbered, stable version is always preferred unless the developer
354*4882a593Smuzhiyun   selects otherwise.
355*4882a593Smuzhiyun
356*4882a593Smuzhiyun.. _bb-bitbake-dependencies:
357*4882a593Smuzhiyun
358*4882a593SmuzhiyunDependencies
359*4882a593Smuzhiyun============
360*4882a593Smuzhiyun
361*4882a593SmuzhiyunEach target BitBake builds consists of multiple tasks such as ``fetch``,
362*4882a593Smuzhiyun``unpack``, ``patch``, ``configure``, and ``compile``. For best
363*4882a593Smuzhiyunperformance on multi-core systems, BitBake considers each task as an
364*4882a593Smuzhiyunindependent entity with its own set of dependencies.
365*4882a593Smuzhiyun
366*4882a593SmuzhiyunDependencies are defined through several variables. You can find
367*4882a593Smuzhiyuninformation about variables BitBake uses in the
368*4882a593Smuzhiyun:doc:`bitbake-user-manual-ref-variables` near the end of this manual. At a
369*4882a593Smuzhiyunbasic level, it is sufficient to know that BitBake uses the
370*4882a593Smuzhiyun:term:`DEPENDS` and
371*4882a593Smuzhiyun:term:`RDEPENDS` variables when calculating
372*4882a593Smuzhiyundependencies.
373*4882a593Smuzhiyun
374*4882a593SmuzhiyunFor more information on how BitBake handles dependencies, see the
375*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-metadata:Dependencies`
376*4882a593Smuzhiyunsection.
377*4882a593Smuzhiyun
378*4882a593Smuzhiyun.. _ref-bitbake-tasklist:
379*4882a593Smuzhiyun
380*4882a593SmuzhiyunThe Task List
381*4882a593Smuzhiyun=============
382*4882a593Smuzhiyun
383*4882a593SmuzhiyunBased on the generated list of providers and the dependency information,
384*4882a593SmuzhiyunBitBake can now calculate exactly what tasks it needs to run and in what
385*4882a593Smuzhiyunorder it needs to run them. The
386*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-execution:executing tasks`
387*4882a593Smuzhiyunsection has more information on how BitBake chooses which task to
388*4882a593Smuzhiyunexecute next.
389*4882a593Smuzhiyun
390*4882a593SmuzhiyunThe build now starts with BitBake forking off threads up to the limit
391*4882a593Smuzhiyunset in the :term:`BB_NUMBER_THREADS`
392*4882a593Smuzhiyunvariable. BitBake continues to fork threads as long as there are tasks
393*4882a593Smuzhiyunready to run, those tasks have all their dependencies met, and the
394*4882a593Smuzhiyunthread threshold has not been exceeded.
395*4882a593Smuzhiyun
396*4882a593SmuzhiyunIt is worth noting that you can greatly speed up the build time by
397*4882a593Smuzhiyunproperly setting the :term:`BB_NUMBER_THREADS` variable.
398*4882a593Smuzhiyun
399*4882a593SmuzhiyunAs each task completes, a timestamp is written to the directory
400*4882a593Smuzhiyunspecified by the :term:`STAMP` variable. On subsequent
401*4882a593Smuzhiyunruns, BitBake looks in the build directory within ``tmp/stamps`` and
402*4882a593Smuzhiyundoes not rerun tasks that are already completed unless a timestamp is
403*4882a593Smuzhiyunfound to be invalid. Currently, invalid timestamps are only considered
404*4882a593Smuzhiyunon a per recipe file basis. So, for example, if the configure stamp has
405*4882a593Smuzhiyuna timestamp greater than the compile timestamp for a given target, then
406*4882a593Smuzhiyunthe compile task would rerun. Running the compile task again, however,
407*4882a593Smuzhiyunhas no effect on other providers that depend on that target.
408*4882a593Smuzhiyun
409*4882a593SmuzhiyunThe exact format of the stamps is partly configurable. In modern
410*4882a593Smuzhiyunversions of BitBake, a hash is appended to the stamp so that if the
411*4882a593Smuzhiyunconfiguration changes, the stamp becomes invalid and the task is
412*4882a593Smuzhiyunautomatically rerun. This hash, or signature used, is governed by the
413*4882a593Smuzhiyunsignature policy that is configured (see the
414*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-execution:checksums (signatures)`
415*4882a593Smuzhiyunsection for information). It is also
416*4882a593Smuzhiyunpossible to append extra metadata to the stamp using the
417*4882a593Smuzhiyun``[stamp-extra-info]`` task flag. For example, OpenEmbedded uses this
418*4882a593Smuzhiyunflag to make some tasks machine-specific.
419*4882a593Smuzhiyun
420*4882a593Smuzhiyun.. note::
421*4882a593Smuzhiyun
422*4882a593Smuzhiyun   Some tasks are marked as "nostamp" tasks. No timestamp file is
423*4882a593Smuzhiyun   created when these tasks are run. Consequently, "nostamp" tasks are
424*4882a593Smuzhiyun   always rerun.
425*4882a593Smuzhiyun
426*4882a593SmuzhiyunFor more information on tasks, see the
427*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-metadata:tasks` section.
428*4882a593Smuzhiyun
429*4882a593SmuzhiyunExecuting Tasks
430*4882a593Smuzhiyun===============
431*4882a593Smuzhiyun
432*4882a593SmuzhiyunTasks can be either a shell task or a Python task. For shell tasks,
433*4882a593SmuzhiyunBitBake writes a shell script to
434*4882a593Smuzhiyun``${``\ :term:`T`\ ``}/run.do_taskname.pid`` and then
435*4882a593Smuzhiyunexecutes the script. The generated shell script contains all the
436*4882a593Smuzhiyunexported variables, and the shell functions with all variables expanded.
437*4882a593SmuzhiyunOutput from the shell script goes to the file
438*4882a593Smuzhiyun``${``\ :term:`T`\ ``}/log.do_taskname.pid``. Looking at the expanded shell functions in
439*4882a593Smuzhiyunthe run file and the output in the log files is a useful debugging
440*4882a593Smuzhiyuntechnique.
441*4882a593Smuzhiyun
442*4882a593SmuzhiyunFor Python tasks, BitBake executes the task internally and logs
443*4882a593Smuzhiyuninformation to the controlling terminal. Future versions of BitBake will
444*4882a593Smuzhiyunwrite the functions to files similar to the way shell tasks are handled.
445*4882a593SmuzhiyunLogging will be handled in a way similar to shell tasks as well.
446*4882a593Smuzhiyun
447*4882a593SmuzhiyunThe order in which BitBake runs the tasks is controlled by its task
448*4882a593Smuzhiyunscheduler. It is possible to configure the scheduler and define custom
449*4882a593Smuzhiyunimplementations for specific use cases. For more information, see these
450*4882a593Smuzhiyunvariables that control the behavior:
451*4882a593Smuzhiyun
452*4882a593Smuzhiyun-  :term:`BB_SCHEDULER`
453*4882a593Smuzhiyun
454*4882a593Smuzhiyun-  :term:`BB_SCHEDULERS`
455*4882a593Smuzhiyun
456*4882a593SmuzhiyunIt is possible to have functions run before and after a task's main
457*4882a593Smuzhiyunfunction. This is done using the ``[prefuncs]`` and ``[postfuncs]``
458*4882a593Smuzhiyunflags of the task that lists the functions to run.
459*4882a593Smuzhiyun
460*4882a593Smuzhiyun.. _checksums:
461*4882a593Smuzhiyun
462*4882a593SmuzhiyunChecksums (Signatures)
463*4882a593Smuzhiyun======================
464*4882a593Smuzhiyun
465*4882a593SmuzhiyunA checksum is a unique signature of a task's inputs. The signature of a
466*4882a593Smuzhiyuntask can be used to determine if a task needs to be run. Because it is a
467*4882a593Smuzhiyunchange in a task's inputs that triggers running the task, BitBake needs
468*4882a593Smuzhiyunto detect all the inputs to a given task. For shell tasks, this turns
469*4882a593Smuzhiyunout to be fairly easy because BitBake generates a "run" shell script for
470*4882a593Smuzhiyuneach task and it is possible to create a checksum that gives you a good
471*4882a593Smuzhiyunidea of when the task's data changes.
472*4882a593Smuzhiyun
473*4882a593SmuzhiyunTo complicate the problem, some things should not be included in the
474*4882a593Smuzhiyunchecksum. First, there is the actual specific build path of a given task
475*4882a593Smuzhiyun- the working directory. It does not matter if the working directory
476*4882a593Smuzhiyunchanges because it should not affect the output for target packages. The
477*4882a593Smuzhiyunsimplistic approach for excluding the working directory is to set it to
478*4882a593Smuzhiyunsome fixed value and create the checksum for the "run" script. BitBake
479*4882a593Smuzhiyungoes one step better and uses the
480*4882a593Smuzhiyun:term:`BB_BASEHASH_IGNORE_VARS` variable
481*4882a593Smuzhiyunto define a list of variables that should never be included when
482*4882a593Smuzhiyungenerating the signatures.
483*4882a593Smuzhiyun
484*4882a593SmuzhiyunAnother problem results from the "run" scripts containing functions that
485*4882a593Smuzhiyunmight or might not get called. The incremental build solution contains
486*4882a593Smuzhiyuncode that figures out dependencies between shell functions. This code is
487*4882a593Smuzhiyunused to prune the "run" scripts down to the minimum set, thereby
488*4882a593Smuzhiyunalleviating this problem and making the "run" scripts much more readable
489*4882a593Smuzhiyunas a bonus.
490*4882a593Smuzhiyun
491*4882a593SmuzhiyunSo far we have solutions for shell scripts. What about Python tasks? The
492*4882a593Smuzhiyunsame approach applies even though these tasks are more difficult. The
493*4882a593Smuzhiyunprocess needs to figure out what variables a Python function accesses
494*4882a593Smuzhiyunand what functions it calls. Again, the incremental build solution
495*4882a593Smuzhiyuncontains code that first figures out the variable and function
496*4882a593Smuzhiyundependencies, and then creates a checksum for the data used as the input
497*4882a593Smuzhiyunto the task.
498*4882a593Smuzhiyun
499*4882a593SmuzhiyunLike the working directory case, situations exist where dependencies
500*4882a593Smuzhiyunshould be ignored. For these cases, you can instruct the build process
501*4882a593Smuzhiyunto ignore a dependency by using a line like the following::
502*4882a593Smuzhiyun
503*4882a593Smuzhiyun  PACKAGE_ARCHS[vardepsexclude] = "MACHINE"
504*4882a593Smuzhiyun
505*4882a593SmuzhiyunThis example ensures that the
506*4882a593Smuzhiyun``PACKAGE_ARCHS`` variable does not depend on the value of ``MACHINE``,
507*4882a593Smuzhiyuneven if it does reference it.
508*4882a593Smuzhiyun
509*4882a593SmuzhiyunEqually, there are cases where we need to add dependencies BitBake is
510*4882a593Smuzhiyunnot able to find. You can accomplish this by using a line like the
511*4882a593Smuzhiyunfollowing::
512*4882a593Smuzhiyun
513*4882a593Smuzhiyun  PACKAGE_ARCHS[vardeps] = "MACHINE"
514*4882a593Smuzhiyun
515*4882a593SmuzhiyunThis example explicitly
516*4882a593Smuzhiyunadds the ``MACHINE`` variable as a dependency for ``PACKAGE_ARCHS``.
517*4882a593Smuzhiyun
518*4882a593SmuzhiyunConsider a case with in-line Python, for example, where BitBake is not
519*4882a593Smuzhiyunable to figure out dependencies. When running in debug mode (i.e. using
520*4882a593Smuzhiyun``-DDD``), BitBake produces output when it discovers something for which
521*4882a593Smuzhiyunit cannot figure out dependencies.
522*4882a593Smuzhiyun
523*4882a593SmuzhiyunThus far, this section has limited discussion to the direct inputs into
524*4882a593Smuzhiyuna task. Information based on direct inputs is referred to as the
525*4882a593Smuzhiyun"basehash" in the code. However, there is still the question of a task's
526*4882a593Smuzhiyunindirect inputs --- the things that were already built and present in the
527*4882a593Smuzhiyunbuild directory. The checksum (or signature) for a particular task needs
528*4882a593Smuzhiyunto add the hashes of all the tasks on which the particular task depends.
529*4882a593SmuzhiyunChoosing which dependencies to add is a policy decision. However, the
530*4882a593Smuzhiyuneffect is to generate a master checksum that combines the basehash and
531*4882a593Smuzhiyunthe hashes of the task's dependencies.
532*4882a593Smuzhiyun
533*4882a593SmuzhiyunAt the code level, there are a variety of ways both the basehash and the
534*4882a593Smuzhiyundependent task hashes can be influenced. Within the BitBake
535*4882a593Smuzhiyunconfiguration file, we can give BitBake some extra information to help
536*4882a593Smuzhiyunit construct the basehash. The following statement effectively results
537*4882a593Smuzhiyunin a list of global variable dependency excludes --- variables never
538*4882a593Smuzhiyunincluded in any checksum. This example uses variables from OpenEmbedded
539*4882a593Smuzhiyunto help illustrate the concept::
540*4882a593Smuzhiyun
541*4882a593Smuzhiyun   BB_BASEHASH_IGNORE_VARS ?= "TMPDIR FILE PATH PWD BB_TASKHASH BBPATH DL_DIR \
542*4882a593Smuzhiyun       SSTATE_DIR THISDIR FILESEXTRAPATHS FILE_DIRNAME HOME LOGNAME SHELL \
543*4882a593Smuzhiyun       USER FILESPATH STAGING_DIR_HOST STAGING_DIR_TARGET COREBASE PRSERV_HOST \
544*4882a593Smuzhiyun       PRSERV_DUMPDIR PRSERV_DUMPFILE PRSERV_LOCKDOWN PARALLEL_MAKE \
545*4882a593Smuzhiyun       CCACHE_DIR EXTERNAL_TOOLCHAIN CCACHE CCACHE_DISABLE LICENSE_PATH SDKPKGSUFFIX"
546*4882a593Smuzhiyun
547*4882a593SmuzhiyunThe previous example excludes the work directory, which is part of
548*4882a593Smuzhiyun``TMPDIR``.
549*4882a593Smuzhiyun
550*4882a593SmuzhiyunThe rules for deciding which hashes of dependent tasks to include
551*4882a593Smuzhiyunthrough dependency chains are more complex and are generally
552*4882a593Smuzhiyunaccomplished with a Python function. The code in
553*4882a593Smuzhiyun``meta/lib/oe/sstatesig.py`` shows two examples of this and also
554*4882a593Smuzhiyunillustrates how you can insert your own policy into the system if so
555*4882a593Smuzhiyundesired. This file defines the two basic signature generators
556*4882a593SmuzhiyunOpenEmbedded-Core uses: "OEBasic" and "OEBasicHash". By default, there
557*4882a593Smuzhiyunis a dummy "noop" signature handler enabled in BitBake. This means that
558*4882a593Smuzhiyunbehavior is unchanged from previous versions. ``OE-Core`` uses the
559*4882a593Smuzhiyun"OEBasicHash" signature handler by default through this setting in the
560*4882a593Smuzhiyun``bitbake.conf`` file::
561*4882a593Smuzhiyun
562*4882a593Smuzhiyun  BB_SIGNATURE_HANDLER ?= "OEBasicHash"
563*4882a593Smuzhiyun
564*4882a593SmuzhiyunThe "OEBasicHash" :term:`BB_SIGNATURE_HANDLER` is the same as the "OEBasic"
565*4882a593Smuzhiyunversion but adds the task hash to the stamp files. This results in any
566*4882a593Smuzhiyunmetadata change that changes the task hash, automatically causing the
567*4882a593Smuzhiyuntask to be run again. This removes the need to bump
568*4882a593Smuzhiyun:term:`PR` values, and changes to metadata automatically
569*4882a593Smuzhiyunripple across the build.
570*4882a593Smuzhiyun
571*4882a593SmuzhiyunIt is also worth noting that the end result of these signature
572*4882a593Smuzhiyungenerators is to make some dependency and hash information available to
573*4882a593Smuzhiyunthe build. This information includes:
574*4882a593Smuzhiyun
575*4882a593Smuzhiyun-  ``BB_BASEHASH_task-``\ *taskname*: The base hashes for each task in the
576*4882a593Smuzhiyun   recipe.
577*4882a593Smuzhiyun
578*4882a593Smuzhiyun-  ``BB_BASEHASH_``\ *filename:taskname*: The base hashes for each
579*4882a593Smuzhiyun   dependent task.
580*4882a593Smuzhiyun
581*4882a593Smuzhiyun-  :term:`BB_TASKHASH`: The hash of the currently running task.
582*4882a593Smuzhiyun
583*4882a593SmuzhiyunIt is worth noting that BitBake's "-S" option lets you debug BitBake's
584*4882a593Smuzhiyunprocessing of signatures. The options passed to -S allow different
585*4882a593Smuzhiyundebugging modes to be used, either using BitBake's own debug functions
586*4882a593Smuzhiyunor possibly those defined in the metadata/signature handler itself. The
587*4882a593Smuzhiyunsimplest parameter to pass is "none", which causes a set of signature
588*4882a593Smuzhiyuninformation to be written out into ``STAMPS_DIR`` corresponding to the
589*4882a593Smuzhiyuntargets specified. The other currently available parameter is
590*4882a593Smuzhiyun"printdiff", which causes BitBake to try to establish the closest
591*4882a593Smuzhiyunsignature match it can (e.g. in the sstate cache) and then run
592*4882a593Smuzhiyun``bitbake-diffsigs`` over the matches to determine the stamps and delta
593*4882a593Smuzhiyunwhere these two stamp trees diverge.
594*4882a593Smuzhiyun
595*4882a593Smuzhiyun.. note::
596*4882a593Smuzhiyun
597*4882a593Smuzhiyun   It is likely that future versions of BitBake will provide other
598*4882a593Smuzhiyun   signature handlers triggered through additional "-S" parameters.
599*4882a593Smuzhiyun
600*4882a593SmuzhiyunYou can find more information on checksum metadata in the
601*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-metadata:task checksums and setscene`
602*4882a593Smuzhiyunsection.
603*4882a593Smuzhiyun
604*4882a593SmuzhiyunSetscene
605*4882a593Smuzhiyun========
606*4882a593Smuzhiyun
607*4882a593SmuzhiyunThe setscene process enables BitBake to handle "pre-built" artifacts.
608*4882a593SmuzhiyunThe ability to handle and reuse these artifacts allows BitBake the
609*4882a593Smuzhiyunluxury of not having to build something from scratch every time.
610*4882a593SmuzhiyunInstead, BitBake can use, when possible, existing build artifacts.
611*4882a593Smuzhiyun
612*4882a593SmuzhiyunBitBake needs to have reliable data indicating whether or not an
613*4882a593Smuzhiyunartifact is compatible. Signatures, described in the previous section,
614*4882a593Smuzhiyunprovide an ideal way of representing whether an artifact is compatible.
615*4882a593SmuzhiyunIf a signature is the same, an object can be reused.
616*4882a593Smuzhiyun
617*4882a593SmuzhiyunIf an object can be reused, the problem then becomes how to replace a
618*4882a593Smuzhiyungiven task or set of tasks with the pre-built artifact. BitBake solves
619*4882a593Smuzhiyunthe problem with the "setscene" process.
620*4882a593Smuzhiyun
621*4882a593SmuzhiyunWhen BitBake is asked to build a given target, before building anything,
622*4882a593Smuzhiyunit first asks whether cached information is available for any of the
623*4882a593Smuzhiyuntargets it's building, or any of the intermediate targets. If cached
624*4882a593Smuzhiyuninformation is available, BitBake uses this information instead of
625*4882a593Smuzhiyunrunning the main tasks.
626*4882a593Smuzhiyun
627*4882a593SmuzhiyunBitBake first calls the function defined by the
628*4882a593Smuzhiyun:term:`BB_HASHCHECK_FUNCTION` variable
629*4882a593Smuzhiyunwith a list of tasks and corresponding hashes it wants to build. This
630*4882a593Smuzhiyunfunction is designed to be fast and returns a list of the tasks for
631*4882a593Smuzhiyunwhich it believes in can obtain artifacts.
632*4882a593Smuzhiyun
633*4882a593SmuzhiyunNext, for each of the tasks that were returned as possibilities, BitBake
634*4882a593Smuzhiyunexecutes a setscene version of the task that the possible artifact
635*4882a593Smuzhiyuncovers. Setscene versions of a task have the string "_setscene" appended
636*4882a593Smuzhiyunto the task name. So, for example, the task with the name ``xxx`` has a
637*4882a593Smuzhiyunsetscene task named ``xxx_setscene``. The setscene version of the task
638*4882a593Smuzhiyunexecutes and provides the necessary artifacts returning either success
639*4882a593Smuzhiyunor failure.
640*4882a593Smuzhiyun
641*4882a593SmuzhiyunAs previously mentioned, an artifact can cover more than one task. For
642*4882a593Smuzhiyunexample, it is pointless to obtain a compiler if you already have the
643*4882a593Smuzhiyuncompiled binary. To handle this, BitBake calls the
644*4882a593Smuzhiyun:term:`BB_SETSCENE_DEPVALID` function for
645*4882a593Smuzhiyuneach successful setscene task to know whether or not it needs to obtain
646*4882a593Smuzhiyunthe dependencies of that task.
647*4882a593Smuzhiyun
648*4882a593SmuzhiyunYou can find more information on setscene metadata in the
649*4882a593Smuzhiyun:ref:`bitbake-user-manual/bitbake-user-manual-metadata:task checksums and setscene`
650*4882a593Smuzhiyunsection.
651*4882a593Smuzhiyun
652*4882a593SmuzhiyunLogging
653*4882a593Smuzhiyun=======
654*4882a593Smuzhiyun
655*4882a593SmuzhiyunIn addition to the standard command line option to control how verbose
656*4882a593Smuzhiyunbuilds are when execute, bitbake also supports user defined
657*4882a593Smuzhiyunconfiguration of the `Python
658*4882a593Smuzhiyunlogging <https://docs.python.org/3/library/logging.html>`__ facilities
659*4882a593Smuzhiyunthrough the :term:`BB_LOGCONFIG` variable. This
660*4882a593Smuzhiyunvariable defines a json or yaml `logging
661*4882a593Smuzhiyunconfiguration <https://docs.python.org/3/library/logging.config.html>`__
662*4882a593Smuzhiyunthat will be intelligently merged into the default configuration. The
663*4882a593Smuzhiyunlogging configuration is merged using the following rules:
664*4882a593Smuzhiyun
665*4882a593Smuzhiyun-  The user defined configuration will completely replace the default
666*4882a593Smuzhiyun   configuration if top level key ``bitbake_merge`` is set to the value
667*4882a593Smuzhiyun   ``False``. In this case, all other rules are ignored.
668*4882a593Smuzhiyun
669*4882a593Smuzhiyun-  The user configuration must have a top level ``version`` which must
670*4882a593Smuzhiyun   match the value of the default configuration.
671*4882a593Smuzhiyun
672*4882a593Smuzhiyun-  Any keys defined in the ``handlers``, ``formatters``, or ``filters``,
673*4882a593Smuzhiyun   will be merged into the same section in the default configuration,
674*4882a593Smuzhiyun   with the user specified keys taking replacing a default one if there
675*4882a593Smuzhiyun   is a conflict. In practice, this means that if both the default
676*4882a593Smuzhiyun   configuration and user configuration specify a handler named
677*4882a593Smuzhiyun   ``myhandler``, the user defined one will replace the default. To
678*4882a593Smuzhiyun   prevent the user from inadvertently replacing a default handler,
679*4882a593Smuzhiyun   formatter, or filter, all of the default ones are named with a prefix
680*4882a593Smuzhiyun   of "``BitBake.``"
681*4882a593Smuzhiyun
682*4882a593Smuzhiyun-  If a logger is defined by the user with the key ``bitbake_merge`` set
683*4882a593Smuzhiyun   to ``False``, that logger will be completely replaced by user
684*4882a593Smuzhiyun   configuration. In this case, no other rules will apply to that
685*4882a593Smuzhiyun   logger.
686*4882a593Smuzhiyun
687*4882a593Smuzhiyun-  All user defined ``filter`` and ``handlers`` properties for a given
688*4882a593Smuzhiyun   logger will be merged with corresponding properties from the default
689*4882a593Smuzhiyun   logger. For example, if the user configuration adds a filter called
690*4882a593Smuzhiyun   ``myFilter`` to the ``BitBake.SigGen``, and the default configuration
691*4882a593Smuzhiyun   adds a filter called ``BitBake.defaultFilter``, both filters will be
692*4882a593Smuzhiyun   applied to the logger
693*4882a593Smuzhiyun
694*4882a593SmuzhiyunAs an example, consider the following user logging configuration file
695*4882a593Smuzhiyunwhich logs all Hash Equivalence related messages of VERBOSE or higher to
696*4882a593Smuzhiyuna file called ``hashequiv.log`` ::
697*4882a593Smuzhiyun
698*4882a593Smuzhiyun   {
699*4882a593Smuzhiyun       "version": 1,
700*4882a593Smuzhiyun       "handlers": {
701*4882a593Smuzhiyun           "autobuilderlog": {
702*4882a593Smuzhiyun               "class": "logging.FileHandler",
703*4882a593Smuzhiyun               "formatter": "logfileFormatter",
704*4882a593Smuzhiyun               "level": "DEBUG",
705*4882a593Smuzhiyun               "filename": "hashequiv.log",
706*4882a593Smuzhiyun               "mode": "w"
707*4882a593Smuzhiyun           }
708*4882a593Smuzhiyun       },
709*4882a593Smuzhiyun       "formatters": {
710*4882a593Smuzhiyun               "logfileFormatter": {
711*4882a593Smuzhiyun                   "format": "%(name)s: %(levelname)s: %(message)s"
712*4882a593Smuzhiyun               }
713*4882a593Smuzhiyun       },
714*4882a593Smuzhiyun       "loggers": {
715*4882a593Smuzhiyun           "BitBake.SigGen.HashEquiv": {
716*4882a593Smuzhiyun               "level": "VERBOSE",
717*4882a593Smuzhiyun               "handlers": ["autobuilderlog"]
718*4882a593Smuzhiyun           },
719*4882a593Smuzhiyun           "BitBake.RunQueue.HashEquiv": {
720*4882a593Smuzhiyun               "level": "VERBOSE",
721*4882a593Smuzhiyun               "handlers": ["autobuilderlog"]
722*4882a593Smuzhiyun           }
723*4882a593Smuzhiyun       }
724*4882a593Smuzhiyun   }
725