The BitBake command
Introduction bitbake is the primary command in the system. It facilitates executing tasks in a single .bb file, or executing a given task on a set of multiple .bb files, accounting for interdependencies amongst them.
Usage and syntax $ bitbake --help usage: bitbake [options] [package ...] Executes the specified task (default is 'build') for a given set of BitBake files. It expects that BBFILES is defined, which is a space separated list of files to be executed. BBFILES does support wildcards. Default BBFILES are the .bb files in the current directory. options: --version show program's version number and exit -h, --help show this help message and exit -b BUILDFILE, --buildfile=BUILDFILE execute the task against this .bb file, rather than a package from BBFILES. -k, --continue continue as much as possible after an error. While the target that failed, and those that depend on it, cannot be remade, the other dependencies of these targets can be processed all the same. -f, --force force run of specified cmd, regardless of stamp status -i, --interactive drop into the interactive mode also called the BitBake shell. -c CMD, --cmd=CMD Specify task to execute. Note that this only executes the specified task for the providee and the packages it depends on, i.e. 'compile' does not implicitly call stage for the dependencies (IOW: use only if you know what you are doing). Depending on the base.bbclass a listtasks task is defined and will show available tasks -r FILE, --read=FILE read the specified file before bitbake.conf -v, --verbose output more chit-chat to the terminal -D, --debug Increase the debug level. You can specify this more than once. -n, --dry-run don't execute, just go through the motions -p, --parse-only quit after parsing the BB files (developers only) -s, --show-versions show current and preferred versions of all packages -e, --environment show the global or per-package environment (this is what used to be bbread) -g, --graphviz emit the dependency trees of the specified packages in the dot syntax -I IGNORED_DOT_DEPS, --ignore-deps=IGNORED_DOT_DEPS Stop processing at the given list of dependencies when generating dependency graphs. This can help to make the graph more appealing -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS Show debug logging for the specified logging domains -P, --profile profile the command and print a report Executing a task against a single .bb Executing tasks for a single file is relatively simple. You specify the file in question, and BitBake parses it and executes the specified task (or build by default). It obeys intertask dependencies when doing so. clean task: $ bitbake -b blah_1.0.bb -c clean build task: $ bitbake -b blah_1.0.bb Executing tasks against a set of .bb files There are a number of additional complexities introduced when one wants to manage multiple .bb files. Clearly there needs to be a way to tell BitBake what files are available, and of those, which we want to execute at this time. There also needs to be a way for each .bb to express its dependencies, both for build time and runtime. There must be a way for the user to express their preferences when multiple .bb's provide the same functionality, or when there are multiple versions of a .bb. The next section, Metadata, outlines how to specify such things. Note that the bitbake command, when not using --buildfile, accepts a PROVIDER, not a filename or anything else. By default, a .bb generally PROVIDES its packagename, packagename-version, and packagename-version-revision. $ bitbake blah $ bitbake blah-1.0 $ bitbake blah-1.0-r0 $ bitbake -c clean blah $ bitbake virtual/whatever $ bitbake -c clean virtual/whatever Generating dependency graphs BitBake is able to generate dependency graphs using the dot syntax. These graphs can be converted to images using the dot application from Graphviz. Two files will be written into the current working directory, depends.dot containing dependency information at the package level and task-depends.dot containing a breakdown of the dependencies at the task level. To stop depending on common depends, one can use the -I depend to omit these from the graph. This can lead to more readable graphs. This way, DEPENDS from inherited classes such as base.bbclass can be removed from the graph. $ bitbake -g blah $ bitbake -g -I virtual/whatever -I bloom blah
Special variables Certain variables affect BitBake operation:
<varname>BB_NUMBER_THREADS</varname> The number of threads BitBake should run at once (default: 1).
Metadata As you may have seen in the usage information, or in the information about .bb files, the BBFILES variable is how the BitBake tool locates its files. This variable is a space separated list of files that are available, and supports wildcards. Setting BBFILES BBFILES = "/path/to/bbfiles/*.bb" With regard to dependencies, it expects the .bb to define a DEPENDS variable, which contains a space separated list of package names, which themselves are the PN variable. The PN variable is, in general, set to a component of the .bb filename by default. Depending on another .bb a.bb: PN = "package-a" DEPENDS += "package-b" b.bb: PN = "package-b" Using PROVIDES This example shows the usage of the PROVIDES variable, which allows a given .bb to specify what functionality it provides. package1.bb: PROVIDES += "virtual/package" package2.bb: DEPENDS += "virtual/package" package3.bb: PROVIDES += "virtual/package" As you can see, we have two different .bb's that provide the same functionality (virtual/package). Clearly, there needs to be a way for the person running BitBake to control which of those providers gets used. There is, indeed, such a way. The following would go into a .conf file, to select package1: PREFERRED_PROVIDER_virtual/package = "package1" Specifying version preference When there are multiple versions of a given package, BitBake defaults to selecting the most recent version, unless otherwise specified. If the .bb in question has a DEFAULT_PREFERENCE set lower than the other .bb's (default is 0), then it will not be selected. This allows the person or persons maintaining the repository of .bb files to specify their preference for the default selected version. In addition, the user can specify their preferred version. If the first .bb 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. If we then have an a_1.2.bb, BitBake will choose 1.2 by default. However, if we define the following variable in a .conf that BitBake parses, we can change that. PREFERRED_VERSION_a = "1.1" Using <quote>bbfile collections</quote> bbfile collections exist to allow the user to have multiple repositories of bbfiles that contain the same exact package. For example, one could easily use them to make one's own local copy of an upstream repository, but with custom modifications that one does not want upstream. Usage: BBFILES = "/stuff/openembedded/*/*.bb /stuff/openembedded.modified/*/*.bb" BBFILE_COLLECTIONS = "upstream local" BBFILE_PATTERN_upstream = "^/stuff/openembedded/" BBFILE_PATTERN_local = "^/stuff/openembedded.modified/" BBFILE_PRIORITY_upstream = "5" BBFILE_PRIORITY_local = "10"