A common example in which a target has multiple providers is "virtual/kernel", which is on the PROVIDES
list for each kernel recipe. Each machine often selects the best kernel provider by using a line similar to the
following in the machine configuration file:
PREFERRED_PROVIDER_virtual/kernel = "linux-yocto"
The default PREFERRED_PROVIDER is the provider with the same name as the target. Bitbake iterates
through each target it needs to build and resolves them and their dependencies using this process.
Understanding how providers are chosen is made complicated by the fact that multiple versions might exist for
a given provider. BitBake defaults to the highest version of a provider. Version comparisons are made using
the same method as Debian. You can use the PREFERRED_VERSION variable to specify a particular
version. You can influence the order by using the DEFAULT_PREFERENCE variable.
By default, files have a preference of "0". Setting DEFAULT_PREFERENCE to "-1" makes the recipe
unlikely to be used unless it is explicitly referenced. Setting DEFAULT_PREFERENCE to "1" makes it likely
the recipe is used. PREFERRED_VERSION overrides any DEFAULT_PREFERENCE setting.
DEFAULT_PREFERENCE is often used to mark newer and more experimental recipe versions until they
have undergone sufficient testing to be considered stable.
When there are multiple “versions” of a given recipe, BitBake defaults to selecting the most recent version,
unless otherwise specified. If the recipe in question has a DEFAULT_PREFERENCE set lower than the
other recipes (default is 0), then it will not be selected. This allows the person or persons maintaining the
repository of recipe files to specify their preference for the default selected version. Additionally, the user can
specify their preferred version.
If the first recipe is named a_1.1.bb, then the PN variable will be set to “a”, and the PV variable will be
set to 1.1.
Thus, if a recipe named a_1.2.bb exists, BitBake will choose 1.2 by default. However, if you define the
following variable in a .conf file that BitBake parses, you can change that preference:
PREFERRED_VERSION_a = "1.1"
Note
It is common for a recipe to provide two versions -- a stable, numbered (and
preferred) version, and a version that is automatically checked out from a source code
repository that is considered more "bleeding edge" but can be selected only explicitly.
For example, in the OpenEmbedded codebase, there is a standard, versioned recipe
file for BusyBox, busybox_1.22.1.bb, but there is also a Git-based version,
busybox_git.bb, which explicitly contains the line
DEFAULT_PREFERENCE = "-1"
to ensure that the numbered, stable version is always preferred unless the developer
selects otherwise.
2.5. Dependencies¶
Each target BitBake builds consists of multiple tasks such as fetch, unpack, patch, configure, and
compile. For best performance on multi-core systems, BitBake considers each task as an independent
entity with its own set of dependencies.
Dependencies are defined through several variables. You can find information about variables BitBake uses in
the Variables Glossary near the end of this manual. At a basic level, it is sufficient to know that BitBake uses
the DEPENDS and RDEPENDS variables when calculating dependencies.
For more information on how BitBake handles dependencies, see the "Dependencies" section.
2.6. The Task List¶
Based on the generated list of providers and the dependency information, BitBake can now calculate exactly
what tasks it needs to run and in what order it needs to run them. The "Executing Tasks" section has more
information on how BitBake chooses which task to execute next.
The build now starts with BitBake forking off threads up to the limit set in the BB_NUMBER_THREADS
variable. BitBake continues to fork threads as long as there are tasks ready to run, those tasks have all their
dependencies met, and the thread threshold has not been exceeded.
It is worth noting that you can greatly speed up the build time by properly setting the
BB_NUMBER_THREADS variable.