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