bitbake-user-manual-intro.xml 45 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891
  1. <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
  2. "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd">
  3. <chapter id="bitbake-user-manual-intro">
  4. <title>Overview</title>
  5. <para>
  6. Welcome to the BitBake User Manual.
  7. This manual provides information on the BitBake tool.
  8. The information attempts to be as independent as possible regarding
  9. systems that use BitBake, such as OpenEmbedded and the
  10. Yocto Project.
  11. In some cases, scenarios or examples within the context of
  12. a build system are used in the manual to help with understanding.
  13. For these cases, the manual clearly states the context.
  14. </para>
  15. <section id="intro">
  16. <title>Introduction</title>
  17. <para>
  18. Fundamentally, BitBake is a generic task execution
  19. engine that allows shell and Python tasks to be run
  20. efficiently and in parallel while working within
  21. complex inter-task dependency constraints.
  22. One of BitBake's main users, OpenEmbedded, takes this core
  23. and builds embedded Linux software stacks using
  24. a task-oriented approach.
  25. </para>
  26. <para>
  27. Conceptually, BitBake is similar to GNU Make in
  28. some regards but has significant differences:
  29. <itemizedlist>
  30. <listitem><para>
  31. BitBake executes tasks according to provided
  32. metadata that builds up the tasks.
  33. Metadata is stored in recipe (<filename>.bb</filename>)
  34. and related recipe "append" (<filename>.bbappend</filename>)
  35. files, configuration (<filename>.conf</filename>) and
  36. underlying include (<filename>.inc</filename>) files, and
  37. in class (<filename>.bbclass</filename>) files.
  38. The metadata provides
  39. BitBake with instructions on what tasks to run and
  40. the dependencies between those tasks.
  41. </para></listitem>
  42. <listitem><para>
  43. BitBake includes a fetcher library for obtaining source
  44. code from various places such as local files, source control
  45. systems, or websites.
  46. </para></listitem>
  47. <listitem><para>
  48. The instructions for each unit to be built (e.g. a piece
  49. of software) are known as "recipe" files and
  50. contain all the information about the unit
  51. (dependencies, source file locations, checksums, description
  52. and so on).
  53. </para></listitem>
  54. <listitem><para>
  55. BitBake includes a client/server abstraction and can
  56. be used from a command line or used as a service over
  57. XML-RPC and has several different user interfaces.
  58. </para></listitem>
  59. </itemizedlist>
  60. </para>
  61. </section>
  62. <section id="history-and-goals">
  63. <title>History and Goals</title>
  64. <para>
  65. BitBake was originally a part of the OpenEmbedded project.
  66. It was inspired by the Portage package management system
  67. used by the Gentoo Linux distribution.
  68. On December 7, 2004, OpenEmbedded project team member
  69. Chris Larson split the project into two distinct pieces:
  70. <itemizedlist>
  71. <listitem><para>BitBake, a generic task executor</para></listitem>
  72. <listitem><para>OpenEmbedded, a metadata set utilized by
  73. BitBake</para></listitem>
  74. </itemizedlist>
  75. Today, BitBake is the primary basis of the
  76. <ulink url="http://www.openembedded.org/">OpenEmbedded</ulink>
  77. project, which is being used to build and maintain Linux
  78. distributions such as the
  79. <ulink url='http://www.angstrom-distribution.org/'>Angstrom Distribution</ulink>,
  80. and which is also being used as the build tool for Linux projects
  81. such as the
  82. <ulink url='http://www.yoctoproject.org'>Yocto Project</ulink>.
  83. </para>
  84. <para>
  85. Prior to BitBake, no other build tool adequately met the needs of
  86. an aspiring embedded Linux distribution.
  87. All of the build systems used by traditional desktop Linux
  88. distributions lacked important functionality, and none of the
  89. ad hoc Buildroot-based systems, prevalent in the
  90. embedded space, were scalable or maintainable.
  91. </para>
  92. <para>
  93. Some important original goals for BitBake were:
  94. <itemizedlist>
  95. <listitem><para>
  96. Handle cross-compilation.
  97. </para></listitem>
  98. <listitem><para>
  99. Handle inter-package dependencies (build time on
  100. target architecture, build time on native
  101. architecture, and runtime).
  102. </para></listitem>
  103. <listitem><para>
  104. Support running any number of tasks within a given
  105. package, including, but not limited to, fetching
  106. upstream sources, unpacking them, patching them,
  107. configuring them, and so forth.
  108. </para></listitem>
  109. <listitem><para>
  110. Be Linux distribution agnostic for both build and
  111. target systems.
  112. </para></listitem>
  113. <listitem><para>
  114. Be architecture agnostic.
  115. </para></listitem>
  116. <listitem><para>
  117. Support multiple build and target operating systems
  118. (e.g. Cygwin, the BSDs, and so forth).
  119. </para></listitem>
  120. <listitem><para>
  121. Be self-contained, rather than tightly
  122. integrated into the build machine's root
  123. filesystem.
  124. </para></listitem>
  125. <listitem><para>
  126. Handle conditional metadata on the target architecture,
  127. operating system, distribution, and machine.
  128. </para></listitem>
  129. <listitem><para>
  130. Be easy to use the tools to supply local metadata and packages
  131. against which to operate.
  132. </para></listitem>
  133. <listitem><para>
  134. Be easy to use BitBake to collaborate between multiple
  135. projects for their builds.
  136. </para></listitem>
  137. <listitem><para>
  138. Provide an inheritance mechanism to share
  139. common metadata between many packages.
  140. </para></listitem>
  141. </itemizedlist>
  142. Over time it became apparent that some further requirements
  143. were necessary:
  144. <itemizedlist>
  145. <listitem><para>
  146. Handle variants of a base recipe (e.g. native, sdk,
  147. and multilib).
  148. </para></listitem>
  149. <listitem><para>
  150. Split metadata into layers and allow layers
  151. to enhance or override other layers.
  152. </para></listitem>
  153. <listitem><para>
  154. Allow representation of a given set of input variables
  155. to a task as a checksum.
  156. Based on that checksum, allow acceleration of builds
  157. with prebuilt components.
  158. </para></listitem>
  159. </itemizedlist>
  160. BitBake satisfies all the original requirements and many more
  161. with extensions being made to the basic functionality to
  162. reflect the additional requirements.
  163. Flexibility and power have always been the priorities.
  164. BitBake is highly extensible and supports embedded Python code and
  165. execution of any arbitrary tasks.
  166. </para>
  167. </section>
  168. <section id="Concepts">
  169. <title>Concepts</title>
  170. <para>
  171. BitBake is a program written in the Python language.
  172. At the highest level, BitBake interprets metadata, decides
  173. what tasks are required to run, and executes those tasks.
  174. Similar to GNU Make, BitBake controls how software is
  175. built.
  176. GNU Make achieves its control through "makefiles", while
  177. BitBake uses "recipes".
  178. </para>
  179. <para>
  180. BitBake extends the capabilities of a simple
  181. tool like GNU Make by allowing for the definition of much more
  182. complex tasks, such as assembling entire embedded Linux
  183. distributions.
  184. </para>
  185. <para>
  186. The remainder of this section introduces several concepts
  187. that should be understood in order to better leverage
  188. the power of BitBake.
  189. </para>
  190. <section id='recipes'>
  191. <title>Recipes</title>
  192. <para>
  193. BitBake Recipes, which are denoted by the file extension
  194. <filename>.bb</filename>, are the most basic metadata files.
  195. These recipe files provide BitBake with the following:
  196. <itemizedlist>
  197. <listitem><para>Descriptive information about the
  198. package (author, homepage, license, and so on)</para></listitem>
  199. <listitem><para>The version of the recipe</para></listitem>
  200. <listitem><para>Existing dependencies (both build
  201. and runtime dependencies)</para></listitem>
  202. <listitem><para>Where the source code resides and
  203. how to fetch it</para></listitem>
  204. <listitem><para>Whether the source code requires
  205. any patches, where to find them, and how to apply
  206. them</para></listitem>
  207. <listitem><para>How to configure and compile the
  208. source code</para></listitem>
  209. <listitem><para>How to assemble the generated artifacts into
  210. one or more installable packages</para></listitem>
  211. <listitem><para>Where on the target machine to install the
  212. package or packages created</para></listitem>
  213. </itemizedlist>
  214. </para>
  215. <para>
  216. Within the context of BitBake, or any project utilizing BitBake
  217. as its build system, files with the <filename>.bb</filename>
  218. extension are referred to as <firstterm>recipes</firstterm>.
  219. <note>
  220. The term "package" is also commonly used to describe recipes.
  221. However, since the same word is used to describe packaged
  222. output from a project, it is best to maintain a single
  223. descriptive term - "recipes".
  224. Put another way, a single "recipe" file is quite capable
  225. of generating a number of related but separately installable
  226. "packages".
  227. In fact, that ability is fairly common.
  228. </note>
  229. </para>
  230. </section>
  231. <section id='configuration-files'>
  232. <title>Configuration Files</title>
  233. <para>
  234. Configuration files, which are denoted by the
  235. <filename>.conf</filename> extension, define
  236. various configuration variables that govern the project's build
  237. process.
  238. These files fall into several areas that define
  239. machine configuration, distribution configuration,
  240. possible compiler tuning, general common
  241. configuration, and user configuration.
  242. The main configuration file is the sample
  243. <filename>bitbake.conf</filename> file, which is
  244. located within the BitBake source tree
  245. <filename>conf</filename> directory.
  246. </para>
  247. </section>
  248. <section id='classes'>
  249. <title>Classes</title>
  250. <para>
  251. Class files, which are denoted by the
  252. <filename>.bbclass</filename> extension, contain
  253. information that is useful to share between metadata files.
  254. The BitBake source tree currently comes with one class metadata file
  255. called <filename>base.bbclass</filename>.
  256. You can find this file in the
  257. <filename>classes</filename> directory.
  258. The <filename>base.bbclass</filename> class files is special since it
  259. is always included automatically for all recipes
  260. and classes.
  261. This class contains definitions for standard basic tasks such
  262. as fetching, unpacking, configuring (empty by default),
  263. compiling (runs any Makefile present), installing (empty by
  264. default) and packaging (empty by default).
  265. These tasks are often overridden or extended by other classes
  266. added during the project development process.
  267. </para>
  268. </section>
  269. <section id='layers'>
  270. <title>Layers</title>
  271. <para>
  272. Layers allow you to isolate different types of
  273. customizations from each other.
  274. While you might find it tempting to keep everything in one layer
  275. when working on a single project, the more modular
  276. your metadata, the easier it is to cope with future changes.
  277. </para>
  278. <para>
  279. To illustrate how you can use layers to keep things modular,
  280. consider customizations you might make to support a specific target machine.
  281. These types of customizations typically reside in a special layer,
  282. rather than a general layer, called a <firstterm>Board Support Package</firstterm> (BSP)
  283. layer.
  284. Furthermore, the machine customizations should be isolated from
  285. recipes and metadata that support a new GUI environment, for
  286. example.
  287. This situation gives you a couple of layers: one for the machine
  288. configurations and one for the GUI environment.
  289. It is important to understand, however, that the BSP layer can still
  290. make machine-specific additions to recipes within
  291. the GUI environment layer without polluting the GUI layer itself
  292. with those machine-specific changes.
  293. You can accomplish this through a recipe that is a BitBake append
  294. (<filename>.bbappend</filename>) file.
  295. </para>
  296. </section>
  297. <section id='append-bbappend-files'>
  298. <title>Append Files</title>
  299. <para>
  300. Append files, which are files that have the
  301. <filename>.bbappend</filename> file extension, extend or
  302. override information in an existing recipe file.
  303. </para>
  304. <para>
  305. BitBake expects every append file to have a corresponding recipe file.
  306. Furthermore, the append file and corresponding recipe file
  307. must use the same root filename.
  308. The filenames can differ only in the file type suffix used
  309. (e.g. <filename>formfactor_0.0.bb</filename> and
  310. <filename>formfactor_0.0.bbappend</filename>).
  311. </para>
  312. <para>
  313. Information in append files extends or
  314. overrides the information in the underlying,
  315. similarly-named recipe files.
  316. </para>
  317. <para>
  318. When you name an append file, you can use the
  319. "<filename>%</filename>" wildcard character to allow for matching
  320. recipe names.
  321. For example, suppose you have an append file named
  322. as follows:
  323. <literallayout class='monospaced'>
  324. busybox_1.21.%.bbappend
  325. </literallayout>
  326. That append file would match any <filename>busybox_1.21.</filename><replaceable>x</replaceable><filename>.bb</filename>
  327. version of the recipe.
  328. So, the append file would match the following recipe names:
  329. <literallayout class='monospaced'>
  330. busybox_1.21.1.bb
  331. busybox_1.21.2.bb
  332. busybox_1.21.3.bb
  333. </literallayout>
  334. <note><title>Important</title>
  335. The use of the "<filename>%</filename>" character
  336. is limited in that it only works directly in front of the
  337. <filename>.bbappend</filename> portion of the append file's
  338. name.
  339. You cannot use the wildcard character in any other
  340. location of the name.
  341. </note>
  342. If the <filename>busybox</filename> recipe was updated to
  343. <filename>busybox_1.3.0.bb</filename>, the append name would not
  344. match.
  345. However, if you named the append file
  346. <filename>busybox_1.%.bbappend</filename>, then you would have a match.
  347. </para>
  348. <para>
  349. In the most general case, you could name the append file something as
  350. simple as <filename>busybox_%.bbappend</filename> to be entirely
  351. version independent.
  352. </para>
  353. </section>
  354. </section>
  355. <section id='obtaining-bitbake'>
  356. <title>Obtaining BitBake</title>
  357. <para>
  358. You can obtain BitBake several different ways:
  359. <itemizedlist>
  360. <listitem><para><emphasis>Cloning BitBake:</emphasis>
  361. Using Git to clone the BitBake source code repository
  362. is the recommended method for obtaining BitBake.
  363. Cloning the repository makes it easy to get bug fixes
  364. and have access to stable branches and the master
  365. branch.
  366. Once you have cloned BitBake, you should use
  367. the latest stable
  368. branch for development since the master branch is for
  369. BitBake development and might contain less stable changes.
  370. </para>
  371. <para>You usually need a version of BitBake
  372. that matches the metadata you are using.
  373. The metadata is generally backwards compatible but
  374. not forward compatible.</para>
  375. <para>Here is an example that clones the BitBake repository:
  376. <literallayout class='monospaced'>
  377. $ git clone git://git.openembedded.org/bitbake
  378. </literallayout>
  379. This command clones the BitBake Git repository into a
  380. directory called <filename>bitbake</filename>.
  381. Alternatively, you can
  382. designate a directory after the
  383. <filename>git clone</filename> command
  384. if you want to call the new directory something
  385. other than <filename>bitbake</filename>.
  386. Here is an example that names the directory
  387. <filename>bbdev</filename>:
  388. <literallayout class='monospaced'>
  389. $ git clone git://git.openembedded.org/bitbake bbdev
  390. </literallayout></para></listitem>
  391. <listitem><para><emphasis>Installation using your Distribution
  392. Package Management System:</emphasis>
  393. This method is not
  394. recommended because the BitBake version that is
  395. provided by your distribution, in most cases,
  396. is several
  397. releases behind a snapshot of the BitBake repository.
  398. </para></listitem>
  399. <listitem><para><emphasis>Taking a snapshot of BitBake:</emphasis>
  400. Downloading a snapshot of BitBake from the
  401. source code repository gives you access to a known
  402. branch or release of BitBake.
  403. <note>
  404. Cloning the Git repository, as described earlier,
  405. is the preferred method for getting BitBake.
  406. Cloning the repository makes it easier to update as
  407. patches are added to the stable branches.
  408. </note></para>
  409. <para>The following example downloads a snapshot of
  410. BitBake version 1.17.0:
  411. <literallayout class='monospaced'>
  412. $ wget http://git.openembedded.org/bitbake/snapshot/bitbake-1.17.0.tar.gz
  413. $ tar zxpvf bitbake-1.17.0.tar.gz
  414. </literallayout>
  415. After extraction of the tarball using the tar utility,
  416. you have a directory entitled
  417. <filename>bitbake-1.17.0</filename>.
  418. </para></listitem>
  419. <listitem><para><emphasis>Using the BitBake that Comes With Your
  420. Build Checkout:</emphasis>
  421. A final possibility for getting a copy of BitBake is that it
  422. already comes with your checkout of a larger BitBake-based build
  423. system, such as Poky.
  424. Rather than manually checking out individual layers and
  425. gluing them together yourself, you can check
  426. out an entire build system.
  427. The checkout will already include a version of BitBake that
  428. has been thoroughly tested for compatibility with the other
  429. components.
  430. For information on how to check out a particular BitBake-based
  431. build system, consult that build system's supporting documentation.
  432. </para></listitem>
  433. </itemizedlist>
  434. </para>
  435. </section>
  436. <section id="bitbake-user-manual-command">
  437. <title>The BitBake Command</title>
  438. <para>
  439. The <filename>bitbake</filename> command is the primary interface
  440. to the BitBake tool.
  441. This section presents the BitBake command syntax and provides
  442. several execution examples.
  443. </para>
  444. <section id='usage-and-syntax'>
  445. <title>Usage and syntax</title>
  446. <para>
  447. Following is the usage and syntax for BitBake:
  448. <literallayout class='monospaced'>
  449. $ bitbake -h
  450. Usage: bitbake [options] [recipename/target recipe:do_task ...]
  451. Executes the specified task (default is 'build') for a given set of target recipes (.bb files).
  452. It is assumed there is a conf/bblayers.conf available in cwd or in BBPATH which
  453. will provide the layer, BBFILES and other configuration information.
  454. Options:
  455. --version show program's version number and exit
  456. -h, --help show this help message and exit
  457. -b BUILDFILE, --buildfile=BUILDFILE
  458. Execute tasks from a specific .bb recipe directly.
  459. WARNING: Does not handle any dependencies from other
  460. recipes.
  461. -k, --continue Continue as much as possible after an error. While the
  462. target that failed and anything depending on it cannot
  463. be built, as much as possible will be built before
  464. stopping.
  465. -f, --force Force the specified targets/task to run (invalidating
  466. any existing stamp file).
  467. -c CMD, --cmd=CMD Specify the task to execute. The exact options
  468. available depend on the metadata. Some examples might
  469. be 'compile' or 'populate_sysroot' or 'listtasks' may
  470. give a list of the tasks available.
  471. -C INVALIDATE_STAMP, --clear-stamp=INVALIDATE_STAMP
  472. Invalidate the stamp for the specified task such as
  473. 'compile' and then run the default task for the
  474. specified target(s).
  475. -r PREFILE, --read=PREFILE
  476. Read the specified file before bitbake.conf.
  477. -R POSTFILE, --postread=POSTFILE
  478. Read the specified file after bitbake.conf.
  479. -v, --verbose Enable tracing of shell tasks (with 'set -x'). Also
  480. print bb.note(...) messages to stdout (in addition to
  481. writing them to ${T}/log.do_&lt;task&gt;).
  482. -D, --debug Increase the debug level. You can specify this more
  483. than once. -D sets the debug level to 1, where only
  484. bb.debug(1, ...) messages are printed to stdout; -DD
  485. sets the debug level to 2, where both bb.debug(1, ...)
  486. and bb.debug(2, ...) messages are printed; etc.
  487. Without -D, no debug messages are printed. Note that
  488. -D only affects output to stdout. All debug messages
  489. are written to ${T}/log.do_taskname, regardless of the
  490. debug level.
  491. -q, --quiet Output less log message data to the terminal. You can
  492. specify this more than once.
  493. -n, --dry-run Don't execute, just go through the motions.
  494. -S SIGNATURE_HANDLER, --dump-signatures=SIGNATURE_HANDLER
  495. Dump out the signature construction information, with
  496. no task execution. The SIGNATURE_HANDLER parameter is
  497. passed to the handler. Two common values are none and
  498. printdiff but the handler may define more/less. none
  499. means only dump the signature, printdiff means compare
  500. the dumped signature with the cached one.
  501. -p, --parse-only Quit after parsing the BB recipes.
  502. -s, --show-versions Show current and preferred versions of all recipes.
  503. -e, --environment Show the global or per-recipe environment complete
  504. with information about where variables were
  505. set/changed.
  506. -g, --graphviz Save dependency tree information for the specified
  507. targets in the dot syntax.
  508. -I EXTRA_ASSUME_PROVIDED, --ignore-deps=EXTRA_ASSUME_PROVIDED
  509. Assume these dependencies don't exist and are already
  510. provided (equivalent to ASSUME_PROVIDED). Useful to
  511. make dependency graphs more appealing
  512. -l DEBUG_DOMAINS, --log-domains=DEBUG_DOMAINS
  513. Show debug logging for the specified logging domains
  514. -P, --profile Profile the command and save reports.
  515. -u UI, --ui=UI The user interface to use (knotty, ncurses or taskexp
  516. - default knotty).
  517. --token=XMLRPCTOKEN Specify the connection token to be used when
  518. connecting to a remote server.
  519. --revisions-changed Set the exit code depending on whether upstream
  520. floating revisions have changed or not.
  521. --server-only Run bitbake without a UI, only starting a server
  522. (cooker) process.
  523. -B BIND, --bind=BIND The name/address for the bitbake xmlrpc server to bind
  524. to.
  525. -T SERVER_TIMEOUT, --idle-timeout=SERVER_TIMEOUT
  526. Set timeout to unload bitbake server due to
  527. inactivity, set to -1 means no unload, default:
  528. Environment variable BB_SERVER_TIMEOUT.
  529. --no-setscene Do not run any setscene tasks. sstate will be ignored
  530. and everything needed, built.
  531. --setscene-only Only run setscene tasks, don't run any real tasks.
  532. --remote-server=REMOTE_SERVER
  533. Connect to the specified server.
  534. -m, --kill-server Terminate any running bitbake server.
  535. --observe-only Connect to a server as an observing-only client.
  536. --status-only Check the status of the remote bitbake server.
  537. -w WRITEEVENTLOG, --write-log=WRITEEVENTLOG
  538. Writes the event log of the build to a bitbake event
  539. json file. Use '' (empty string) to assign the name
  540. automatically.
  541. --runall=RUNALL Run the specified task for any recipe in the taskgraph
  542. of the specified target (even if it wouldn't otherwise
  543. have run).
  544. --runonly=RUNONLY Run only the specified task within the taskgraph of
  545. the specified targets (and any task dependencies those
  546. tasks may have).
  547. </literallayout>
  548. </para>
  549. </section>
  550. <section id='bitbake-examples'>
  551. <title>Examples</title>
  552. <para>
  553. This section presents some examples showing how to use BitBake.
  554. </para>
  555. <section id='example-executing-a-task-against-a-single-recipe'>
  556. <title>Executing a Task Against a Single Recipe</title>
  557. <para>
  558. Executing tasks for a single recipe file is relatively simple.
  559. You specify the file in question, and BitBake parses
  560. it and executes the specified task.
  561. If you do not specify a task, BitBake executes the default
  562. task, which is "build”.
  563. BitBake obeys inter-task dependencies when doing
  564. so.
  565. </para>
  566. <para>
  567. The following command runs the build task, which is
  568. the default task, on the <filename>foo_1.0.bb</filename>
  569. recipe file:
  570. <literallayout class='monospaced'>
  571. $ bitbake -b foo_1.0.bb
  572. </literallayout>
  573. The following command runs the clean task on the
  574. <filename>foo.bb</filename> recipe file:
  575. <literallayout class='monospaced'>
  576. $ bitbake -b foo.bb -c clean
  577. </literallayout>
  578. <note>
  579. The "-b" option explicitly does not handle recipe
  580. dependencies.
  581. Other than for debugging purposes, it is instead
  582. recommended that you use the syntax presented in the
  583. next section.
  584. </note>
  585. </para>
  586. </section>
  587. <section id='executing-tasks-against-a-set-of-recipe-files'>
  588. <title>Executing Tasks Against a Set of Recipe Files</title>
  589. <para>
  590. There are a number of additional complexities introduced
  591. when one wants to manage multiple <filename>.bb</filename>
  592. files.
  593. Clearly there needs to be a way to tell BitBake what
  594. files are available and, of those, which you
  595. want to execute.
  596. There also needs to be a way for each recipe
  597. to express its dependencies, both for build-time and
  598. runtime.
  599. There must be a way for you to express recipe preferences
  600. when multiple recipes provide the same functionality, or when
  601. there are multiple versions of a recipe.
  602. </para>
  603. <para>
  604. The <filename>bitbake</filename> command, when not using
  605. "--buildfile" or "-b" only accepts a "PROVIDES".
  606. You cannot provide anything else.
  607. By default, a recipe file generally "PROVIDES" its
  608. "packagename" as shown in the following example:
  609. <literallayout class='monospaced'>
  610. $ bitbake foo
  611. </literallayout>
  612. This next example "PROVIDES" the package name and also uses
  613. the "-c" option to tell BitBake to just execute the
  614. <filename>do_clean</filename> task:
  615. <literallayout class='monospaced'>
  616. $ bitbake -c clean foo
  617. </literallayout>
  618. </para>
  619. </section>
  620. <section id='executing-a-list-of-task-and-recipe-combinations'>
  621. <title>Executing a List of Task and Recipe Combinations</title>
  622. <para>
  623. The BitBake command line supports specifying different
  624. tasks for individual targets when you specify multiple
  625. targets.
  626. For example, suppose you had two targets (or recipes)
  627. <filename>myfirstrecipe</filename> and
  628. <filename>mysecondrecipe</filename> and you needed
  629. BitBake to run <filename>taskA</filename> for the first
  630. recipe and <filename>taskB</filename> for the second
  631. recipe:
  632. <literallayout class='monospaced'>
  633. $ bitbake myfirstrecipe:do_taskA mysecondrecipe:do_taskB
  634. </literallayout>
  635. </para>
  636. </section>
  637. <section id='generating-dependency-graphs'>
  638. <title>Generating Dependency Graphs</title>
  639. <para>
  640. BitBake is able to generate dependency graphs using
  641. the <filename>dot</filename> syntax.
  642. You can convert these graphs into images using the
  643. <filename>dot</filename> tool from
  644. <ulink url='http://www.graphviz.org'>Graphviz</ulink>.
  645. </para>
  646. <para>
  647. When you generate a dependency graph, BitBake writes two files
  648. to the current working directory:
  649. <itemizedlist>
  650. <listitem><para>
  651. <emphasis><filename>task-depends.dot</filename>:</emphasis>
  652. Shows dependencies between tasks.
  653. These dependencies match BitBake's internal task execution list.
  654. </para></listitem>
  655. <listitem><para>
  656. <emphasis><filename>pn-buildlist</filename>:</emphasis>
  657. Shows a simple list of targets that are to be built.
  658. </para></listitem>
  659. </itemizedlist>
  660. </para>
  661. <para>
  662. To stop depending on common depends, use the "-I" depend
  663. option and BitBake omits them from the graph.
  664. Leaving this information out can produce more readable graphs.
  665. This way, you can remove from the graph
  666. <filename>DEPENDS</filename> from inherited classes
  667. such as <filename>base.bbclass</filename>.
  668. </para>
  669. <para>
  670. Here are two examples that create dependency graphs.
  671. The second example omits depends common in OpenEmbedded from
  672. the graph:
  673. <literallayout class='monospaced'>
  674. $ bitbake -g foo
  675. $ bitbake -g -I virtual/kernel -I eglibc foo
  676. </literallayout>
  677. </para>
  678. </section>
  679. <section id='executing-a-multiple-configuration-build'>
  680. <title>Executing a Multiple Configuration Build</title>
  681. <para>
  682. BitBake is able to build multiple images or packages
  683. using a single command where the different targets
  684. require different configurations (multiple configuration
  685. builds).
  686. Each target, in this scenario, is referred to as a
  687. "multiconfig".
  688. </para>
  689. <para>
  690. To accomplish a multiple configuration build, you must
  691. define each target's configuration separately using
  692. a parallel configuration file in the build directory.
  693. The location for these multiconfig configuration files
  694. is specific.
  695. They must reside in the current build directory in
  696. a sub-directory of <filename>conf</filename> named
  697. <filename>multiconfig</filename>.
  698. Following is an example for two separate targets:
  699. <imagedata fileref="figures/bb_multiconfig_files.png" align="center" width="4in" depth="3in" />
  700. </para>
  701. <para>
  702. The reason for this required file hierarchy
  703. is because the <filename>BBPATH</filename> variable
  704. is not constructed until the layers are parsed.
  705. Consequently, using the configuration file as a
  706. pre-configuration file is not possible unless it is
  707. located in the current working directory.
  708. </para>
  709. <para>
  710. Minimally, each configuration file must define the
  711. machine and the temporary directory BitBake uses
  712. for the build.
  713. Suggested practice dictates that you do not
  714. overlap the temporary directories used during the
  715. builds.
  716. </para>
  717. <para>
  718. Aside from separate configuration files for each
  719. target, you must also enable BitBake to perform multiple
  720. configuration builds.
  721. Enabling is accomplished by setting the
  722. <link linkend='var-bb-BBMULTICONFIG'><filename>BBMULTICONFIG</filename></link>
  723. variable in the <filename>local.conf</filename>
  724. configuration file.
  725. As an example, suppose you had configuration files
  726. for <filename>target1</filename> and
  727. <filename>target2</filename> defined in the build
  728. directory.
  729. The following statement in the
  730. <filename>local.conf</filename> file both enables
  731. BitBake to perform multiple configuration builds and
  732. specifies the two extra multiconfigs:
  733. <literallayout class='monospaced'>
  734. BBMULTICONFIG = "target1 target2"
  735. </literallayout>
  736. </para>
  737. <para>
  738. Once the target configuration files are in place and
  739. BitBake has been enabled to perform multiple configuration
  740. builds, use the following command form to start the
  741. builds:
  742. <literallayout class='monospaced'>
  743. $ bitbake [mc:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable> [[[mc:<replaceable>multiconfigname</replaceable>:]<replaceable>target</replaceable>] ... ]
  744. </literallayout>
  745. Here is an example for two extra multiconfigs:
  746. <filename>target1</filename> and
  747. <filename>target2</filename>:
  748. <literallayout class='monospaced'>
  749. $ bitbake mc::<replaceable>target</replaceable> mc:target1:<replaceable>target</replaceable> mc:target2:<replaceable>target</replaceable>
  750. </literallayout>
  751. </para>
  752. </section>
  753. <section id='bb-enabling-multiple-configuration-build-dependencies'>
  754. <title>Enabling Multiple Configuration Build Dependencies</title>
  755. <para>
  756. Sometimes dependencies can exist between targets
  757. (multiconfigs) in a multiple configuration build.
  758. For example, suppose that in order to build an image
  759. for a particular architecture, the root filesystem of
  760. another build for a different architecture needs to
  761. exist.
  762. In other words, the image for the first multiconfig depends
  763. on the root filesystem of the second multiconfig.
  764. This dependency is essentially that the task in the recipe
  765. that builds one multiconfig is dependent on the
  766. completion of the task in the recipe that builds
  767. another multiconfig.
  768. </para>
  769. <para>
  770. To enable dependencies in a multiple configuration
  771. build, you must declare the dependencies in the recipe
  772. using the following statement form:
  773. <literallayout class='monospaced'>
  774. <replaceable>task_or_package</replaceable>[mcdepends] = "mc:<replaceable>from_multiconfig</replaceable>:<replaceable>to_multiconfig</replaceable>:<replaceable>recipe_name</replaceable>:<replaceable>task_on_which_to_depend</replaceable>"
  775. </literallayout>
  776. To better show how to use this statement, consider an
  777. example with two multiconfigs: <filename>target1</filename>
  778. and <filename>target2</filename>:
  779. <literallayout class='monospaced'>
  780. <replaceable>image_task</replaceable>[mcdepends] = "mc:target1:target2:<replaceable>image2</replaceable>:<replaceable>rootfs_task</replaceable>"
  781. </literallayout>
  782. In this example, the
  783. <replaceable>from_multiconfig</replaceable> is "target1" and
  784. the <replaceable>to_multiconfig</replaceable> is "target2".
  785. The task on which the image whose recipe contains
  786. <replaceable>image_task</replaceable> depends on the
  787. completion of the <replaceable>rootfs_task</replaceable>
  788. used to build out <replaceable>image2</replaceable>, which
  789. is associated with the "target2" multiconfig.
  790. </para>
  791. <para>
  792. Once you set up this dependency, you can build the
  793. "target1" multiconfig using a BitBake command as follows:
  794. <literallayout class='monospaced'>
  795. $ bitbake mc:target1:<replaceable>image1</replaceable>
  796. </literallayout>
  797. This command executes all the tasks needed to create
  798. <replaceable>image1</replaceable> for the "target1"
  799. multiconfig.
  800. Because of the dependency, BitBake also executes through
  801. the <replaceable>rootfs_task</replaceable> for the "target2"
  802. multiconfig build.
  803. </para>
  804. <para>
  805. Having a recipe depend on the root filesystem of another
  806. build might not seem that useful.
  807. Consider this change to the statement in the
  808. <replaceable>image1</replaceable> recipe:
  809. <literallayout class='monospaced'>
  810. <replaceable>image_task</replaceable>[mcdepends] = "mc:target1:target2:<replaceable>image2</replaceable>:<replaceable>image_task</replaceable>"
  811. </literallayout>
  812. In this case, BitBake must create
  813. <replaceable>image2</replaceable> for the "target2"
  814. build since the "target1" build depends on it.
  815. </para>
  816. <para>
  817. Because "target1" and "target2" are enabled for multiple
  818. configuration builds and have separate configuration
  819. files, BitBake places the artifacts for each build in the
  820. respective temporary build directories.
  821. </para>
  822. </section>
  823. </section>
  824. </section>
  825. </chapter>