bitbake-user-manual-intro.rst 29 KB

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