summaryrefslogtreecommitdiffstats
path: root/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst731
1 files changed, 470 insertions, 261 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
index 7ea68ade72..f60a9d8312 100644
--- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
+++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
@@ -26,7 +26,7 @@ assignment. ::
26 VARIABLE = "value" 26 VARIABLE = "value"
27 27
28As expected, if you include leading or 28As expected, if you include leading or
29trailing spaces as part of an assignment, the spaces are retained: :: 29trailing spaces as part of an assignment, the spaces are retained::
30 30
31 VARIABLE = " value" 31 VARIABLE = " value"
32 VARIABLE = "value " 32 VARIABLE = "value "
@@ -40,7 +40,7 @@ blank space (i.e. these are not the same values). ::
40 40
41You can use single quotes instead of double quotes when setting a 41You can use single quotes instead of double quotes when setting a
42variable's value. Doing so allows you to use values that contain the 42variable's value. Doing so allows you to use values that contain the
43double quote character: :: 43double quote character::
44 44
45 VARIABLE = 'I have a " in my value' 45 VARIABLE = 'I have a " in my value'
46 46
@@ -77,7 +77,7 @@ occurs, you can use BitBake to check the actual value of the suspect
77variable. You can make these checks for both configuration and recipe 77variable. You can make these checks for both configuration and recipe
78level changes: 78level changes:
79 79
80- For configuration changes, use the following: :: 80- For configuration changes, use the following::
81 81
82 $ bitbake -e 82 $ bitbake -e
83 83
@@ -91,9 +91,10 @@ level changes:
91 Variables that are exported to the environment are preceded by the 91 Variables that are exported to the environment are preceded by the
92 string "export" in the command's output. 92 string "export" in the command's output.
93 93
94- For recipe changes, use the following: :: 94- To find changes to a given variable in a specific recipe, use the
95 following::
95 96
96 $ bitbake recipe -e \| grep VARIABLE=" 97 $ bitbake recipename -e | grep VARIABLENAME=\"
97 98
98 This command checks to see if the variable actually makes 99 This command checks to see if the variable actually makes
99 it into a specific recipe. 100 it into a specific recipe.
@@ -103,20 +104,20 @@ Line Joining
103 104
104Outside of :ref:`functions <bitbake-user-manual/bitbake-user-manual-metadata:functions>`, 105Outside of :ref:`functions <bitbake-user-manual/bitbake-user-manual-metadata:functions>`,
105BitBake joins any line ending in 106BitBake joins any line ending in
106a backslash character ("\") with the following line before parsing 107a backslash character ("\\") with the following line before parsing
107statements. The most common use for the "\" character is to split 108statements. The most common use for the "\\" character is to split
108variable assignments over multiple lines, as in the following example: :: 109variable assignments over multiple lines, as in the following example::
109 110
110 FOO = "bar \ 111 FOO = "bar \
111 baz \ 112 baz \
112 qaz" 113 qaz"
113 114
114Both the "\" character and the newline 115Both the "\\" character and the newline
115character that follow it are removed when joining lines. Thus, no 116character that follow it are removed when joining lines. Thus, no
116newline characters end up in the value of ``FOO``. 117newline characters end up in the value of ``FOO``.
117 118
118Consider this additional example where the two assignments both assign 119Consider this additional example where the two assignments both assign
119"barbaz" to ``FOO``: :: 120"barbaz" to ``FOO``::
120 121
121 FOO = "barbaz" 122 FOO = "barbaz"
122 FOO = "bar\ 123 FOO = "bar\
@@ -124,7 +125,7 @@ Consider this additional example where the two assignments both assign
124 125
125.. note:: 126.. note::
126 127
127 BitBake does not interpret escape sequences like "\n" in variable 128 BitBake does not interpret escape sequences like "\\n" in variable
128 values. For these to have an effect, the value must be passed to some 129 values. For these to have an effect, the value must be passed to some
129 utility that interprets escape sequences, such as 130 utility that interprets escape sequences, such as
130 ``printf`` or ``echo -n``. 131 ``printf`` or ``echo -n``.
@@ -149,7 +150,7 @@ The "=" operator does not immediately expand variable references in the
149right-hand side. Instead, expansion is deferred until the variable 150right-hand side. Instead, expansion is deferred until the variable
150assigned to is actually used. The result depends on the current values 151assigned to is actually used. The result depends on the current values
151of the referenced variables. The following example should clarify this 152of the referenced variables. The following example should clarify this
152behavior: :: 153behavior::
153 154
154 A = "${B} baz" 155 A = "${B} baz"
155 B = "${C} bar" 156 B = "${C} bar"
@@ -158,7 +159,7 @@ behavior: ::
158 C = "qux" 159 C = "qux"
159 *At this point, ${A} equals "qux bar baz"* 160 *At this point, ${A} equals "qux bar baz"*
160 B = "norf" 161 B = "norf"
161 *At this point, ${A} equals "norf baz"\* 162 *At this point, ${A} equals "norf baz"*
162 163
163Contrast this behavior with the 164Contrast this behavior with the
164:ref:`bitbake-user-manual/bitbake-user-manual-metadata:immediate variable 165:ref:`bitbake-user-manual/bitbake-user-manual-metadata:immediate variable
@@ -177,7 +178,7 @@ Setting a default value (?=)
177You can use the "?=" operator to achieve a "softer" assignment for a 178You can use the "?=" operator to achieve a "softer" assignment for a
178variable. This type of assignment allows you to define a variable if it 179variable. This type of assignment allows you to define a variable if it
179is undefined when the statement is parsed, but to leave the value alone 180is undefined when the statement is parsed, but to leave the value alone
180if the variable has a value. Here is an example: :: 181if the variable has a value. Here is an example::
181 182
182 A ?= "aval" 183 A ?= "aval"
183 184
@@ -194,28 +195,51 @@ value. However, if ``A`` is not set, the variable is set to "aval".
194Setting a weak default value (??=) 195Setting a weak default value (??=)
195---------------------------------- 196----------------------------------
196 197
197It is possible to use a "weaker" assignment than in the previous section 198The weak default value of a variable is the value which that variable
198by using the "??=" operator. This assignment behaves identical to "?=" 199will expand to if no value has been assigned to it via any of the other
199except that the assignment is made at the end of the parsing process 200assignment operators. The "??=" operator takes effect immediately, replacing
200rather than immediately. Consequently, when multiple "??=" assignments 201any previously defined weak default value. Here is an example::
201exist, the last one is used. Also, any "=" or "?=" assignment will
202override the value set with "??=". Here is an example: ::
203 202
204 A ??= "somevalue" 203 W ??= "x"
205 A ??= "someothervalue" 204 A := "${W}" # Immediate variable expansion
205 W ??= "y"
206 B := "${W}" # Immediate variable expansion
207 W ??= "z"
208 C = "${W}"
209 W ?= "i"
206 210
207If ``A`` is set before the above statements are 211After parsing we will have::
208parsed, the variable retains its value. If ``A`` is not set, the
209variable is set to "someothervalue".
210 212
211Again, this assignment is a "lazy" or "weak" assignment because it does 213 A = "x"
212not occur until the end of the parsing process. 214 B = "y"
215 C = "i"
216 W = "i"
217
218Appending and prepending non-override style will not substitute the weak
219default value, which means that after parsing::
220
221 W ??= "x"
222 W += "y"
223
224we will have::
225
226 W = " y"
227
228On the other hand, override-style appends/prepends/removes are applied after
229any active weak default value has been substituted::
230
231 W ??= "x"
232 W:append = "y"
233
234After parsing we will have::
235
236 W = "xy"
213 237
214Immediate variable expansion (:=) 238Immediate variable expansion (:=)
215--------------------------------- 239---------------------------------
216 240
217The ":=" operator results in a variable's contents being expanded 241The ":=" operator results in a variable's contents being expanded
218immediately, rather than when the variable is actually used: :: 242immediately, rather than when the variable is actually used::
219 243
220 T = "123" 244 T = "123"
221 A := "test ${T}" 245 A := "test ${T}"
@@ -225,7 +249,7 @@ immediately, rather than when the variable is actually used: ::
225 C := "${C}append" 249 C := "${C}append"
226 250
227In this example, ``A`` contains "test 123", even though the final value 251In this example, ``A`` contains "test 123", even though the final value
228of ``T`` is "456". The variable ``B`` will end up containing "456 252of :term:`T` is "456". The variable :term:`B` will end up containing "456
229cvalappend". This is because references to undefined variables are 253cvalappend". This is because references to undefined variables are
230preserved as is during (immediate)expansion. This is in contrast to GNU 254preserved as is during (immediate)expansion. This is in contrast to GNU
231Make, where undefined variables expand to nothing. The variable ``C`` 255Make, where undefined variables expand to nothing. The variable ``C``
@@ -241,14 +265,14 @@ the "+=" and "=+" operators. These operators insert a space between the
241current value and prepended or appended value. 265current value and prepended or appended value.
242 266
243These operators take immediate effect during parsing. Here are some 267These operators take immediate effect during parsing. Here are some
244examples: :: 268examples::
245 269
246 B = "bval" 270 B = "bval"
247 B += "additionaldata" 271 B += "additionaldata"
248 C = "cval" 272 C = "cval"
249 C =+ "test" 273 C =+ "test"
250 274
251The variable ``B`` contains "bval additionaldata" and ``C`` contains "test 275The variable :term:`B` contains "bval additionaldata" and ``C`` contains "test
252cval". 276cval".
253 277
254.. _appending-and-prepending-without-spaces: 278.. _appending-and-prepending-without-spaces:
@@ -260,14 +284,14 @@ If you want to append or prepend values without an inserted space, use
260the ".=" and "=." operators. 284the ".=" and "=." operators.
261 285
262These operators take immediate effect during parsing. Here are some 286These operators take immediate effect during parsing. Here are some
263examples: :: 287examples::
264 288
265 B = "bval" 289 B = "bval"
266 B .= "additionaldata" 290 B .= "additionaldata"
267 C = "cval" 291 C = "cval"
268 C =. "test" 292 C =. "test"
269 293
270The variable ``B`` contains "bvaladditionaldata" and ``C`` contains 294The variable :term:`B` contains "bvaladditionaldata" and ``C`` contains
271"testcval". 295"testcval".
272 296
273Appending and Prepending (Override Style Syntax) 297Appending and Prepending (Override Style Syntax)
@@ -278,16 +302,16 @@ style syntax. When you use this syntax, no spaces are inserted.
278 302
279These operators differ from the ":=", ".=", "=.", "+=", and "=+" 303These operators differ from the ":=", ".=", "=.", "+=", and "=+"
280operators in that their effects are applied at variable expansion time 304operators in that their effects are applied at variable expansion time
281rather than being immediately applied. Here are some examples: :: 305rather than being immediately applied. Here are some examples::
282 306
283 B = "bval" 307 B = "bval"
284 B_append = " additional data" 308 B:append = " additional data"
285 C = "cval" 309 C = "cval"
286 C_prepend = "additional data " 310 C:prepend = "additional data "
287 D = "dval" 311 D = "dval"
288 D_append = "additional data" 312 D:append = "additional data"
289 313
290The variable ``B`` 314The variable :term:`B`
291becomes "bval additional data" and ``C`` becomes "additional data cval". 315becomes "bval additional data" and ``C`` becomes "additional data cval".
292The variable ``D`` becomes "dvaladditional data". 316The variable ``D`` becomes "dvaladditional data".
293 317
@@ -295,6 +319,10 @@ The variable ``D`` becomes "dvaladditional data".
295 319
296 You must control all spacing when you use the override syntax. 320 You must control all spacing when you use the override syntax.
297 321
322.. note::
323
324 The overrides are applied in this order, ":append", ":prepend", ":remove".
325
298It is also possible to append and prepend to shell functions and 326It is also possible to append and prepend to shell functions and
299BitBake-style Python functions. See the ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:shell functions`" and ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:bitbake-style python functions`" 327BitBake-style Python functions. See the ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:shell functions`" and ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:bitbake-style python functions`"
300sections for examples. 328sections for examples.
@@ -306,16 +334,17 @@ Removal (Override Style Syntax)
306 334
307You can remove values from lists using the removal override style 335You can remove values from lists using the removal override style
308syntax. Specifying a value for removal causes all occurrences of that 336syntax. Specifying a value for removal causes all occurrences of that
309value to be removed from the variable. 337value to be removed from the variable. Unlike ":append" and ":prepend",
338there is no need to add a leading or trailing space to the value.
310 339
311When you use this syntax, BitBake expects one or more strings. 340When you use this syntax, BitBake expects one or more strings.
312Surrounding spaces and spacing are preserved. Here is an example: :: 341Surrounding spaces and spacing are preserved. Here is an example::
313 342
314 FOO = "123 456 789 123456 123 456 123 456" 343 FOO = "123 456 789 123456 123 456 123 456"
315 FOO_remove = "123" 344 FOO:remove = "123"
316 FOO_remove = "456" 345 FOO:remove = "456"
317 FOO2 = " abc def ghi abcdef abc def abc def def" 346 FOO2 = " abc def ghi abcdef abc def abc def def"
318 FOO2_remove = "\ 347 FOO2:remove = "\
319 def \ 348 def \
320 abc \ 349 abc \
321 ghi \ 350 ghi \
@@ -324,40 +353,62 @@ Surrounding spaces and spacing are preserved. Here is an example: ::
324The variable ``FOO`` becomes 353The variable ``FOO`` becomes
325" 789 123456 " and ``FOO2`` becomes " abcdef ". 354" 789 123456 " and ``FOO2`` becomes " abcdef ".
326 355
327Like "_append" and "_prepend", "_remove" is applied at variable 356Like ":append" and ":prepend", ":remove" is applied at variable
328expansion time. 357expansion time.
329 358
359.. note::
360
361 The overrides are applied in this order, ":append", ":prepend", ":remove".
362 This implies it is not possible to re-append previously removed strings.
363 However, one can undo a ":remove" by using an intermediate variable whose
364 content is passed to the ":remove" so that modifying the intermediate
365 variable equals to keeping the string in::
366
367 FOOREMOVE = "123 456 789"
368 FOO:remove = "${FOOREMOVE}"
369 ...
370 FOOREMOVE = "123 789"
371
372 This expands to ``FOO:remove = "123 789"``.
373
374.. note::
375
376 Override application order may not match variable parse history, i.e.
377 the output of ``bitbake -e`` may contain ":remove" before ":append",
378 but the result will be removed string, because ":remove" is handled
379 last.
380
330Override Style Operation Advantages 381Override Style Operation Advantages
331----------------------------------- 382-----------------------------------
332 383
333An advantage of the override style operations "_append", "_prepend", and 384An advantage of the override style operations ":append", ":prepend", and
334"_remove" as compared to the "+=" and "=+" operators is that the 385":remove" as compared to the "+=" and "=+" operators is that the
335override style operators provide guaranteed operations. For example, 386override style operators provide guaranteed operations. For example,
336consider a class ``foo.bbclass`` that needs to add the value "val" to 387consider a class ``foo.bbclass`` that needs to add the value "val" to
337the variable ``FOO``, and a recipe that uses ``foo.bbclass`` as follows: :: 388the variable ``FOO``, and a recipe that uses ``foo.bbclass`` as follows::
338 389
339 inherit foo 390 inherit foo
340 FOO = "initial" 391 FOO = "initial"
341 392
342If ``foo.bbclass`` uses the "+=" operator, 393If ``foo.bbclass`` uses the "+=" operator,
343as follows, then the final value of ``FOO`` will be "initial", which is 394as follows, then the final value of ``FOO`` will be "initial", which is
344not what is desired: :: 395not what is desired::
345 396
346 FOO += "val" 397 FOO += "val"
347 398
348If, on the other hand, ``foo.bbclass`` 399If, on the other hand, ``foo.bbclass``
349uses the "_append" operator, then the final value of ``FOO`` will be 400uses the ":append" operator, then the final value of ``FOO`` will be
350"initial val", as intended: :: 401"initial val", as intended::
351 402
352 FOO_append = " val" 403 FOO:append = " val"
353 404
354.. note:: 405.. note::
355 406
356 It is never necessary to use "+=" together with "_append". The following 407 It is never necessary to use "+=" together with ":append". The following
357 sequence of assignments appends "barbaz" to FOO: :: 408 sequence of assignments appends "barbaz" to FOO::
358 409
359 FOO_append = "bar" 410 FOO:append = "bar"
360 FOO_append = "baz" 411 FOO:append = "baz"
361 412
362 413
363 The only effect of changing the second assignment in the previous 414 The only effect of changing the second assignment in the previous
@@ -378,10 +429,10 @@ You can find more out about variable flags in general in the
378 429
379You can define, append, and prepend values to variable flags. All the 430You can define, append, and prepend values to variable flags. All the
380standard syntax operations previously mentioned work for variable flags 431standard syntax operations previously mentioned work for variable flags
381except for override style syntax (i.e. "_prepend", "_append", and 432except for override style syntax (i.e. ":prepend", ":append", and
382"_remove"). 433":remove").
383 434
384Here are some examples showing how to set variable flags: :: 435Here are some examples showing how to set variable flags::
385 436
386 FOO[a] = "abc" 437 FOO[a] = "abc"
387 FOO[b] = "123" 438 FOO[b] = "123"
@@ -393,15 +444,21 @@ respectively. The ``[a]`` flag becomes "abc 456".
393 444
394No need exists to pre-define variable flags. You can simply start using 445No need exists to pre-define variable flags. You can simply start using
395them. One extremely common application is to attach some brief 446them. One extremely common application is to attach some brief
396documentation to a BitBake variable as follows: :: 447documentation to a BitBake variable as follows::
397 448
398 CACHE[doc] = "The directory holding the cache of the metadata." 449 CACHE[doc] = "The directory holding the cache of the metadata."
399 450
451.. note::
452
453 Variable flag names starting with an underscore (``_``) character
454 are allowed but are ignored by ``d.getVarFlags("VAR")``
455 in Python code. Such flag names are used internally by BitBake.
456
400Inline Python Variable Expansion 457Inline Python Variable Expansion
401-------------------------------- 458--------------------------------
402 459
403You can use inline Python variable expansion to set variables. Here is 460You can use inline Python variable expansion to set variables. Here is
404an example: :: 461an example::
405 462
406 DATE = "${@time.strftime('%Y%m%d',time.gmtime())}" 463 DATE = "${@time.strftime('%Y%m%d',time.gmtime())}"
407 464
@@ -410,21 +467,21 @@ This example results in the ``DATE`` variable being set to the current date.
410Probably the most common use of this feature is to extract the value of 467Probably the most common use of this feature is to extract the value of
411variables from BitBake's internal data dictionary, ``d``. The following 468variables from BitBake's internal data dictionary, ``d``. The following
412lines select the values of a package name and its version number, 469lines select the values of a package name and its version number,
413respectively: :: 470respectively::
414 471
415 PN = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}" 472 PN = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[0] or 'defaultpkgname'}"
416 PV = "${@bb.parse.BBHandler.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}" 473 PV = "${@bb.parse.vars_from_file(d.getVar('FILE', False),d)[1] or '1.0'}"
417 474
418.. note:: 475.. note::
419 476
420 Inline Python expressions work just like variable expansions insofar as the 477 Inline Python expressions work just like variable expansions insofar as the
421 "=" and ":=" operators are concerned. Given the following assignment, foo() 478 "=" and ":=" operators are concerned. Given the following assignment, foo()
422 is called each time FOO is expanded: :: 479 is called each time FOO is expanded::
423 480
424 FOO = "${@foo()}" 481 FOO = "${@foo()}"
425 482
426 Contrast this with the following immediate assignment, where foo() is only 483 Contrast this with the following immediate assignment, where foo() is only
427 called once, while the assignment is parsed: :: 484 called once, while the assignment is parsed::
428 485
429 FOO := "${@foo()}" 486 FOO := "${@foo()}"
430 487
@@ -437,7 +494,7 @@ Unsetting variables
437 494
438It is possible to completely remove a variable or a variable flag from 495It is possible to completely remove a variable or a variable flag from
439BitBake's internal data dictionary by using the "unset" keyword. Here is 496BitBake's internal data dictionary by using the "unset" keyword. Here is
440an example: :: 497an example::
441 498
442 unset DATE 499 unset DATE
443 unset do_fetch[noexec] 500 unset do_fetch[noexec]
@@ -452,7 +509,7 @@ When specifying pathnames for use with BitBake, do not use the tilde
452cause BitBake to not recognize the path since BitBake does not expand 509cause BitBake to not recognize the path since BitBake does not expand
453this character in the same way a shell would. 510this character in the same way a shell would.
454 511
455Instead, provide a fuller path as the following example illustrates: :: 512Instead, provide a fuller path as the following example illustrates::
456 513
457 BBLAYERS ?= " \ 514 BBLAYERS ?= " \
458 /home/scott-lenovo/LayerA \ 515 /home/scott-lenovo/LayerA \
@@ -463,7 +520,7 @@ Exporting Variables to the Environment
463 520
464You can export variables to the environment of running tasks by using 521You can export variables to the environment of running tasks by using
465the ``export`` keyword. For example, in the following example, the 522the ``export`` keyword. For example, in the following example, the
466``do_foo`` task prints "value from the environment" when run: :: 523``do_foo`` task prints "value from the environment" when run::
467 524
468 export ENV_VARIABLE 525 export ENV_VARIABLE
469 ENV_VARIABLE = "value from the environment" 526 ENV_VARIABLE = "value from the environment"
@@ -481,7 +538,7 @@ It does not matter whether ``export ENV_VARIABLE`` appears before or
481after assignments to ``ENV_VARIABLE``. 538after assignments to ``ENV_VARIABLE``.
482 539
483It is also possible to combine ``export`` with setting a value for the 540It is also possible to combine ``export`` with setting a value for the
484variable. Here is an example: :: 541variable. Here is an example::
485 542
486 export ENV_VARIABLE = "variable-value" 543 export ENV_VARIABLE = "variable-value"
487 544
@@ -496,78 +553,78 @@ Conditional Syntax (Overrides)
496 553
497BitBake uses :term:`OVERRIDES` to control what 554BitBake uses :term:`OVERRIDES` to control what
498variables are overridden after BitBake parses recipes and configuration 555variables are overridden after BitBake parses recipes and configuration
499files. This section describes how you can use ``OVERRIDES`` as 556files. This section describes how you can use :term:`OVERRIDES` as
500conditional metadata, talks about key expansion in relationship to 557conditional metadata, talks about key expansion in relationship to
501``OVERRIDES``, and provides some examples to help with understanding. 558:term:`OVERRIDES`, and provides some examples to help with understanding.
502 559
503Conditional Metadata 560Conditional Metadata
504-------------------- 561--------------------
505 562
506You can use ``OVERRIDES`` to conditionally select a specific version of 563You can use :term:`OVERRIDES` to conditionally select a specific version of
507a variable and to conditionally append or prepend the value of a 564a variable and to conditionally append or prepend the value of a
508variable. 565variable.
509 566
510.. note:: 567.. note::
511 568
512 Overrides can only use lower-case characters. Additionally, 569 Overrides can only use lower-case characters, digits and dashes.
513 underscores are not permitted in override names as they are used to 570 In particular, colons are not permitted in override names as they are used to
514 separate overrides from each other and from the variable name. 571 separate overrides from each other and from the variable name.
515 572
516- *Selecting a Variable:* The ``OVERRIDES`` variable is a 573- *Selecting a Variable:* The :term:`OVERRIDES` variable is a
517 colon-character-separated list that contains items for which you want 574 colon-character-separated list that contains items for which you want
518 to satisfy conditions. Thus, if you have a variable that is 575 to satisfy conditions. Thus, if you have a variable that is
519 conditional on "arm", and "arm" is in ``OVERRIDES``, then the 576 conditional on "arm", and "arm" is in :term:`OVERRIDES`, then the
520 "arm"-specific version of the variable is used rather than the 577 "arm"-specific version of the variable is used rather than the
521 non-conditional version. Here is an example: :: 578 non-conditional version. Here is an example::
522 579
523 OVERRIDES = "architecture:os:machine" 580 OVERRIDES = "architecture:os:machine"
524 TEST = "default" 581 TEST = "default"
525 TEST_os = "osspecific" 582 TEST:os = "osspecific"
526 TEST_nooverride = "othercondvalue" 583 TEST:nooverride = "othercondvalue"
527 584
528 In this example, the ``OVERRIDES`` 585 In this example, the :term:`OVERRIDES`
529 variable lists three overrides: "architecture", "os", and "machine". 586 variable lists three overrides: "architecture", "os", and "machine".
530 The variable ``TEST`` by itself has a default value of "default". You 587 The variable ``TEST`` by itself has a default value of "default". You
531 select the os-specific version of the ``TEST`` variable by appending 588 select the os-specific version of the ``TEST`` variable by appending
532 the "os" override to the variable (i.e. ``TEST_os``). 589 the "os" override to the variable (i.e. ``TEST:os``).
533 590
534 To better understand this, consider a practical example that assumes 591 To better understand this, consider a practical example that assumes
535 an OpenEmbedded metadata-based Linux kernel recipe file. The 592 an OpenEmbedded metadata-based Linux kernel recipe file. The
536 following lines from the recipe file first set the kernel branch 593 following lines from the recipe file first set the kernel branch
537 variable ``KBRANCH`` to a default value, then conditionally override 594 variable ``KBRANCH`` to a default value, then conditionally override
538 that value based on the architecture of the build: :: 595 that value based on the architecture of the build::
539 596
540 KBRANCH = "standard/base" 597 KBRANCH = "standard/base"
541 KBRANCH_qemuarm = "standard/arm-versatile-926ejs" 598 KBRANCH:qemuarm = "standard/arm-versatile-926ejs"
542 KBRANCH_qemumips = "standard/mti-malta32" 599 KBRANCH:qemumips = "standard/mti-malta32"
543 KBRANCH_qemuppc = "standard/qemuppc" 600 KBRANCH:qemuppc = "standard/qemuppc"
544 KBRANCH_qemux86 = "standard/common-pc/base" 601 KBRANCH:qemux86 = "standard/common-pc/base"
545 KBRANCH_qemux86-64 = "standard/common-pc-64/base" 602 KBRANCH:qemux86-64 = "standard/common-pc-64/base"
546 KBRANCH_qemumips64 = "standard/mti-malta64" 603 KBRANCH:qemumips64 = "standard/mti-malta64"
547 604
548- *Appending and Prepending:* BitBake also supports append and prepend 605- *Appending and Prepending:* BitBake also supports append and prepend
549 operations to variable values based on whether a specific item is 606 operations to variable values based on whether a specific item is
550 listed in ``OVERRIDES``. Here is an example: :: 607 listed in :term:`OVERRIDES`. Here is an example::
551 608
552 DEPENDS = "glibc ncurses" 609 DEPENDS = "glibc ncurses"
553 OVERRIDES = "machine:local" 610 OVERRIDES = "machine:local"
554 DEPENDS_append_machine = "libmad" 611 DEPENDS:append:machine = "libmad"
555 612
556 In this example, ``DEPENDS`` becomes "glibc ncurses libmad". 613 In this example, :term:`DEPENDS` becomes "glibc ncurses libmad".
557 614
558 Again, using an OpenEmbedded metadata-based kernel recipe file as an 615 Again, using an OpenEmbedded metadata-based kernel recipe file as an
559 example, the following lines will conditionally append to the 616 example, the following lines will conditionally append to the
560 ``KERNEL_FEATURES`` variable based on the architecture: :: 617 ``KERNEL_FEATURES`` variable based on the architecture::
561 618
562 KERNEL_FEATURES_append = " ${KERNEL_EXTRA_FEATURES}" 619 KERNEL_FEATURES:append = " ${KERNEL_EXTRA_FEATURES}"
563 KERNEL_FEATURES_append_qemux86=" cfg/sound.scc cfg/paravirt_kvm.scc" 620 KERNEL_FEATURES:append:qemux86=" cfg/sound.scc cfg/paravirt_kvm.scc"
564 KERNEL_FEATURES_append_qemux86-64=" cfg/sound.scc cfg/paravirt_kvm.scc" 621 KERNEL_FEATURES:append:qemux86-64=" cfg/sound.scc cfg/paravirt_kvm.scc"
565 622
566- *Setting a Variable for a Single Task:* BitBake supports setting a 623- *Setting a Variable for a Single Task:* BitBake supports setting a
567 variable just for the duration of a single task. Here is an example: :: 624 variable just for the duration of a single task. Here is an example::
568 625
569 FOO_task-configure = "val 1" 626 FOO:task-configure = "val 1"
570 FOO_task-compile = "val 2" 627 FOO:task-compile = "val 2"
571 628
572 In the 629 In the
573 previous example, ``FOO`` has the value "val 1" while the 630 previous example, ``FOO`` has the value "val 1" while the
@@ -580,15 +637,25 @@ variable.
580 ``do_compile`` task. 637 ``do_compile`` task.
581 638
582 You can also use this syntax with other combinations (e.g. 639 You can also use this syntax with other combinations (e.g.
583 "``_prepend``") as shown in the following example: :: 640 "``:prepend``") as shown in the following example::
641
642 EXTRA_OEMAKE:prepend:task-compile = "${PARALLEL_MAKE} "
643
644.. note::
584 645
585 EXTRA_OEMAKE_prepend_task-compile = "${PARALLEL_MAKE} " 646 Before BitBake 1.52 (Honister 3.4), the syntax for :term:`OVERRIDES`
647 used ``_`` instead of ``:``, so you will still find a lot of documentation
648 using ``_append``, ``_prepend``, and ``_remove``, for example.
649
650 For details, see the
651 :yocto_docs:`Overrides Syntax Changes </migration-guides/migration-3.4.html#override-syntax-changes>`
652 section in the Yocto Project manual migration notes.
586 653
587Key Expansion 654Key Expansion
588------------- 655-------------
589 656
590Key expansion happens when the BitBake datastore is finalized. To better 657Key expansion happens when the BitBake datastore is finalized. To better
591understand this, consider the following example: :: 658understand this, consider the following example::
592 659
593 A${B} = "X" 660 A${B} = "X"
594 B = "2" 661 B = "2"
@@ -612,57 +679,57 @@ users.
612 679
613There is often confusion concerning the order in which overrides and 680There is often confusion concerning the order in which overrides and
614various "append" operators take effect. Recall that an append or prepend 681various "append" operators take effect. Recall that an append or prepend
615operation using "_append" and "_prepend" does not result in an immediate 682operation using ":append" and ":prepend" does not result in an immediate
616assignment as would "+=", ".=", "=+", or "=.". Consider the following 683assignment as would "+=", ".=", "=+", or "=.". Consider the following
617example: :: 684example::
618 685
619 OVERRIDES = "foo" 686 OVERRIDES = "foo"
620 A = "Z" 687 A = "Z"
621 A_foo_append = "X" 688 A:foo:append = "X"
622 689
623For this case, 690For this case,
624``A`` is unconditionally set to "Z" and "X" is unconditionally and 691``A`` is unconditionally set to "Z" and "X" is unconditionally and
625immediately appended to the variable ``A_foo``. Because overrides have 692immediately appended to the variable ``A:foo``. Because overrides have
626not been applied yet, ``A_foo`` is set to "X" due to the append and 693not been applied yet, ``A:foo`` is set to "X" due to the append and
627``A`` simply equals "Z". 694``A`` simply equals "Z".
628 695
629Applying overrides, however, changes things. Since "foo" is listed in 696Applying overrides, however, changes things. Since "foo" is listed in
630``OVERRIDES``, the conditional variable ``A`` is replaced with the "foo" 697:term:`OVERRIDES`, the conditional variable ``A`` is replaced with the "foo"
631version, which is equal to "X". So effectively, ``A_foo`` replaces 698version, which is equal to "X". So effectively, ``A:foo`` replaces
632``A``. 699``A``.
633 700
634This next example changes the order of the override and the append: :: 701This next example changes the order of the override and the append::
635 702
636 OVERRIDES = "foo" 703 OVERRIDES = "foo"
637 A = "Z" 704 A = "Z"
638 A_append_foo = "X" 705 A:append:foo = "X"
639 706
640For this case, before 707For this case, before
641overrides are handled, ``A`` is set to "Z" and ``A_append_foo`` is set 708overrides are handled, ``A`` is set to "Z" and ``A:append:foo`` is set
642to "X". Once the override for "foo" is applied, however, ``A`` gets 709to "X". Once the override for "foo" is applied, however, ``A`` gets
643appended with "X". Consequently, ``A`` becomes "ZX". Notice that spaces 710appended with "X". Consequently, ``A`` becomes "ZX". Notice that spaces
644are not appended. 711are not appended.
645 712
646This next example has the order of the appends and overrides reversed 713This next example has the order of the appends and overrides reversed
647back as in the first example: :: 714back as in the first example::
648 715
649 OVERRIDES = "foo" 716 OVERRIDES = "foo"
650 A = "Y" 717 A = "Y"
651 A_foo_append = "Z" 718 A:foo:append = "Z"
652 A_foo_append = "X" 719 A:foo:append = "X"
653 720
654For this case, before any overrides are resolved, 721For this case, before any overrides are resolved,
655``A`` is set to "Y" using an immediate assignment. After this immediate 722``A`` is set to "Y" using an immediate assignment. After this immediate
656assignment, ``A_foo`` is set to "Z", and then further appended with "X" 723assignment, ``A:foo`` is set to "Z", and then further appended with "X"
657leaving the variable set to "ZX". Finally, applying the override for 724leaving the variable set to "ZX". Finally, applying the override for
658"foo" results in the conditional variable ``A`` becoming "ZX" (i.e. 725"foo" results in the conditional variable ``A`` becoming "ZX" (i.e.
659``A`` is replaced with ``A_foo``). 726``A`` is replaced with ``A:foo``).
660 727
661This final example mixes in some varying operators: :: 728This final example mixes in some varying operators::
662 729
663 A = "1" 730 A = "1"
664 A_append = "2" 731 A:append = "2"
665 A_append = "3" 732 A:append = "3"
666 A += "4" 733 A += "4"
667 A .= "5" 734 A .= "5"
668 735
@@ -670,7 +737,7 @@ For this case, the type of append
670operators are affecting the order of assignments as BitBake passes 737operators are affecting the order of assignments as BitBake passes
671through the code multiple times. Initially, ``A`` is set to "1 45" 738through the code multiple times. Initially, ``A`` is set to "1 45"
672because of the three statements that use immediate operators. After 739because of the three statements that use immediate operators. After
673these assignments are made, BitBake applies the "_append" operations. 740these assignments are made, BitBake applies the ":append" operations.
674Those operations result in ``A`` becoming "1 4523". 741Those operations result in ``A`` becoming "1 4523".
675 742
676Sharing Functionality 743Sharing Functionality
@@ -686,8 +753,10 @@ share the task.
686 753
687This section presents the mechanisms BitBake provides to allow you to 754This section presents the mechanisms BitBake provides to allow you to
688share functionality between recipes. Specifically, the mechanisms 755share functionality between recipes. Specifically, the mechanisms
689include ``include``, ``inherit``, ``INHERIT``, and ``require`` 756include ``include``, ``inherit``, :term:`INHERIT`, and ``require``
690directives. 757directives. There is also a higher-level abstraction called
758``configuration fragments`` that is enabled with ``addfragments``
759directive.
691 760
692Locating Include and Class Files 761Locating Include and Class Files
693-------------------------------- 762--------------------------------
@@ -702,7 +771,9 @@ current directory for ``include`` and ``require`` directives.
702 771
703In order for include and class files to be found by BitBake, they need 772In order for include and class files to be found by BitBake, they need
704to be located in a "classes" subdirectory that can be found in 773to be located in a "classes" subdirectory that can be found in
705``BBPATH``. 774:term:`BBPATH`.
775
776.. _ref-bitbake-user-manual-metadata-inherit:
706 777
707``inherit`` Directive 778``inherit`` Directive
708--------------------- 779---------------------
@@ -720,12 +791,12 @@ file and then have your recipe inherit that class file.
720 791
721As an example, your recipes could use the following directive to inherit 792As an example, your recipes could use the following directive to inherit
722an ``autotools.bbclass`` file. The class file would contain common 793an ``autotools.bbclass`` file. The class file would contain common
723functionality for using Autotools that could be shared across recipes: :: 794functionality for using Autotools that could be shared across recipes::
724 795
725 inherit autotools 796 inherit autotools
726 797
727In this case, BitBake would search for the directory 798In this case, BitBake would search for the directory
728``classes/autotools.bbclass`` in ``BBPATH``. 799``classes/autotools.bbclass`` in :term:`BBPATH`.
729 800
730.. note:: 801.. note::
731 802
@@ -734,7 +805,7 @@ In this case, BitBake would search for the directory
734 805
735If you want to use the directive to inherit multiple classes, separate 806If you want to use the directive to inherit multiple classes, separate
736them with spaces. The following example shows how to inherit both the 807them with spaces. The following example shows how to inherit both the
737``buildhistory`` and ``rm_work`` classes: :: 808``buildhistory`` and ``rm_work`` classes::
738 809
739 inherit buildhistory rm_work 810 inherit buildhistory rm_work
740 811
@@ -742,19 +813,43 @@ An advantage with the inherit directive as compared to both the
742:ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>` and :ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>` 813:ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>` and :ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>`
743directives is that you can inherit class files conditionally. You can 814directives is that you can inherit class files conditionally. You can
744accomplish this by using a variable expression after the ``inherit`` 815accomplish this by using a variable expression after the ``inherit``
745statement. Here is an example: :: 816statement.
817
818For inheriting classes conditionally, using the :ref:`inherit_defer
819<ref-bitbake-user-manual-metadata-inherit-defer>` directive is advised as
820:ref:`inherit_defer <ref-bitbake-user-manual-metadata-inherit-defer>` is
821evaluated at the end of parsing.
822
823.. _ref-bitbake-user-manual-metadata-inherit-defer:
824
825``inherit_defer`` Directive
826~~~~~~~~~~~~~~~~~~~~~~~~~~~
827
828The :ref:`inherit_defer <ref-bitbake-user-manual-metadata-inherit-defer>`
829directive works like the :ref:`inherit
830<ref-bitbake-user-manual-metadata-inherit>` directive, except that it is only
831evaluated at the end of parsing. Its usage is recommended when a conditional
832expression is used.
746 833
747 inherit ${VARNAME} 834This allows conditional expressions to be evaluated "late", meaning changes to
835the variable after the line is parsed will take effect. With the :ref:`inherit
836<ref-bitbake-user-manual-metadata-inherit>` directive this is not the case.
837
838Here is an example::
839
840 inherit_defer ${VARNAME}
748 841
749If ``VARNAME`` is 842If ``VARNAME`` is
750going to be set, it needs to be set before the ``inherit`` statement is 843going to be set, it needs to be set before the ``inherit_defer`` statement is
751parsed. One way to achieve a conditional inherit in this case is to use 844parsed. One way to achieve a conditional inherit in this case is to use
752overrides: :: 845overrides::
753 846
754 VARIABLE = "" 847 VARIABLE = ""
755 VARIABLE_someoverride = "myclass" 848 VARIABLE:someoverride = "myclass"
756 849
757Another method is by using anonymous Python. Here is an example: :: 850Another method is by using :ref:`anonymous Python
851<bitbake-user-manual/bitbake-user-manual-metadata:Anonymous Python Functions>`.
852Here is an example::
758 853
759 python () { 854 python () {
760 if condition == value: 855 if condition == value:
@@ -763,11 +858,14 @@ Another method is by using anonymous Python. Here is an example: ::
763 d.setVar('VARIABLE', '') 858 d.setVar('VARIABLE', '')
764 } 859 }
765 860
766Alternatively, you could use an in-line Python expression in the 861Alternatively, you could use an inline Python expression in the
767following form: :: 862following form::
863
864 inherit_defer ${@'classname' if condition else ''}
768 865
769 inherit ${@'classname' if condition else ''} 866Or::
770 inherit ${@functionname(params)} 867
868 inherit_defer ${@bb.utils.contains('VARIABLE', 'something', 'classname', '', d)}
771 869
772In all cases, if the expression evaluates to an 870In all cases, if the expression evaluates to an
773empty string, the statement does not trigger a syntax error because it 871empty string, the statement does not trigger a syntax error because it
@@ -780,7 +878,7 @@ BitBake understands the ``include`` directive. This directive causes
780BitBake to parse whatever file you specify, and to insert that file at 878BitBake to parse whatever file you specify, and to insert that file at
781that location. The directive is much like its equivalent in Make except 879that location. The directive is much like its equivalent in Make except
782that if the path specified on the include line is a relative path, 880that if the path specified on the include line is a relative path,
783BitBake locates the first file it can find within ``BBPATH``. 881BitBake locates the first file it can find within :term:`BBPATH`.
784 882
785The include directive is a more generic method of including 883The include directive is a more generic method of including
786functionality as compared to the :ref:`inherit <bitbake-user-manual/bitbake-user-manual-metadata:\`\`inherit\`\` directive>` 884functionality as compared to the :ref:`inherit <bitbake-user-manual/bitbake-user-manual-metadata:\`\`inherit\`\` directive>`
@@ -790,7 +888,7 @@ encapsulated functionality or configuration that does not suit a
790``.bbclass`` file. 888``.bbclass`` file.
791 889
792As an example, suppose you needed a recipe to include some self-test 890As an example, suppose you needed a recipe to include some self-test
793definitions: :: 891definitions::
794 892
795 include test_defs.inc 893 include test_defs.inc
796 894
@@ -802,6 +900,33 @@ definitions: ::
802 of include . Doing so makes sure that an error is produced if the file cannot 900 of include . Doing so makes sure that an error is produced if the file cannot
803 be found. 901 be found.
804 902
903``include_all`` Directive
904-------------------------
905
906The ``include_all`` directive works like the :ref:`include
907<bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>`
908directive but will include all of the files that match the specified path in
909the enabled layers (layers part of :term:`BBLAYERS`).
910
911For example, let's say a ``maintainers.inc`` file is present in different layers
912and is conventionally placed in the ``conf/distro/include`` directory of each
913layer. In that case the ``include_all`` directive can be used to include
914the ``maintainers.inc`` file for all of these layers::
915
916 include_all conf/distro/include/maintainers.inc
917
918In other words, the ``maintainers.inc`` file for each layer is included through
919the :ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>`
920directive.
921
922BitBake will iterate through the colon-separated :term:`BBPATH` list to look for
923matching files to include, from left to right. As a consequence, matching files
924are included in that order.
925
926As the ``include_all`` directive uses the :ref:`include
927<bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>`
928directive in the background, no error is produced if no files are matched.
929
805.. _require-inclusion: 930.. _require-inclusion:
806 931
807``require`` Directive 932``require`` Directive
@@ -822,7 +947,7 @@ does not suit a ``.bbclass`` file.
822 947
823Similar to how BitBake handles :ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>`, if 948Similar to how BitBake handles :ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>`, if
824the path specified on the require line is a relative path, BitBake 949the path specified on the require line is a relative path, BitBake
825locates the first file it can find within ``BBPATH``. 950locates the first file it can find within :term:`BBPATH`.
826 951
827As an example, suppose you have two versions of a recipe (e.g. 952As an example, suppose you have two versions of a recipe (e.g.
828``foo_1.2.2.bb`` and ``foo_2.0.0.bb``) where each version contains some 953``foo_1.2.2.bb`` and ``foo_2.0.0.bb``) where each version contains some
@@ -831,7 +956,7 @@ include file named ``foo.inc`` that contains the common definitions
831needed to build "foo". You need to be sure ``foo.inc`` is located in the 956needed to build "foo". You need to be sure ``foo.inc`` is located in the
832same directory as your two recipe files as well. Once these conditions 957same directory as your two recipe files as well. Once these conditions
833are set up, you can share the functionality using a ``require`` 958are set up, you can share the functionality using a ``require``
834directive from within each recipe: :: 959directive from within each recipe::
835 960
836 require foo.inc 961 require foo.inc
837 962
@@ -844,14 +969,14 @@ class. BitBake only supports this directive when used within a
844configuration file. 969configuration file.
845 970
846As an example, suppose you needed to inherit a class file called 971As an example, suppose you needed to inherit a class file called
847``abc.bbclass`` from a configuration file as follows: :: 972``abc.bbclass`` from a configuration file as follows::
848 973
849 INHERIT += "abc" 974 INHERIT += "abc"
850 975
851This configuration directive causes the named class to be inherited at 976This configuration directive causes the named class to be inherited at
852the point of the directive during parsing. As with the ``inherit`` 977the point of the directive during parsing. As with the ``inherit``
853directive, the ``.bbclass`` file must be located in a "classes" 978directive, the ``.bbclass`` file must be located in a "classes"
854subdirectory in one of the directories specified in ``BBPATH``. 979subdirectory in one of the directories specified in :term:`BBPATH`.
855 980
856.. note:: 981.. note::
857 982
@@ -862,10 +987,69 @@ subdirectory in one of the directories specified in ``BBPATH``.
862If you want to use the directive to inherit multiple classes, you can 987If you want to use the directive to inherit multiple classes, you can
863provide them on the same line in the ``local.conf`` file. Use spaces to 988provide them on the same line in the ``local.conf`` file. Use spaces to
864separate the classes. The following example shows how to inherit both 989separate the classes. The following example shows how to inherit both
865the ``autotools`` and ``pkgconfig`` classes: :: 990the ``autotools`` and ``pkgconfig`` classes::
866 991
867 INHERIT += "autotools pkgconfig" 992 INHERIT += "autotools pkgconfig"
868 993
994``addfragments`` Directive
995--------------------------
996
997This directive allows fine-tuning local configurations with configuration
998snippets contained in layers in a structured, controlled way. Typically it would
999go into ``bitbake.conf``, for example::
1000
1001 addfragments conf/fragments OE_FRAGMENTS OE_FRAGMENTS_METADATA_VARS OE_BUILTIN_FRAGMENTS
1002
1003``addfragments`` takes four parameters:
1004
1005- path prefix for fragment files inside the layer file tree that bitbake
1006 uses to construct full paths to the fragment files
1007
1008- name of variable that holds the list of enabled fragments in an
1009 active build
1010
1011- name of variable that contains a list of variable names containing
1012 fragment-specific metadata (such as descriptions)
1013
1014- name of variable that contains definitions for built-in fragments
1015
1016This allows listing enabled configuration fragments in ``OE_FRAGMENTS``
1017variable like this::
1018
1019 OE_FRAGMENTS = "core/domain/somefragment core/someotherfragment anotherlayer/anotherdomain/anotherfragment"
1020
1021Fragment names listed in this variable must be prefixed by the layer name
1022where a fragment file is located, defined by :term:`BBFILE_COLLECTIONS` in ``layer.conf``.
1023
1024The implementation then expands this list into
1025:ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>`
1026directives with full paths to respective layers::
1027
1028 require /path/to/core-layer/conf/fragments/domain/somefragment.conf
1029 require /path/to/core-layer/conf/fragments/someotherfragment.conf
1030 require /path/to/another-layer/conf/fragments/anotherdomain/anotherfragment.conf
1031
1032The variable containing a list of fragment metadata variables could look like this::
1033
1034 OE_FRAGMENTS_METADATA_VARS = "BB_CONF_FRAGMENT_SUMMARY BB_CONF_FRAGMENT_DESCRIPTION"
1035
1036The implementation will add a flag containing the fragment name to each of those variables
1037when parsing fragments, so that the variables are namespaced by fragment name, and do not override
1038each other when several fragments are enabled.
1039
1040The variable containing a built-in fragment definitions could look like this::
1041
1042 OE_BUILTIN_FRAGMENTS = "someprefix:SOMEVARIABLE anotherprefix:ANOTHERVARIABLE"
1043
1044and then if 'someprefix/somevalue' is added to the variable that holds the list
1045of enabled fragments:
1046
1047 OE_FRAGMENTS = "... someprefix/somevalue"
1048
1049bitbake will treat that as direct value assignment in its configuration::
1050
1051 SOMEVARIABLE = "somevalue"
1052
869Functions 1053Functions
870========= 1054=========
871 1055
@@ -893,9 +1077,9 @@ Regardless of the type of function, you can only define them in class
893Shell Functions 1077Shell Functions
894--------------- 1078---------------
895 1079
896Functions written in shell script and executed either directly as 1080Functions written in shell script are executed either directly as
897functions, tasks, or both. They can also be called by other shell 1081functions, tasks, or both. They can also be called by other shell
898functions. Here is an example shell function definition: :: 1082functions. Here is an example shell function definition::
899 1083
900 some_function () { 1084 some_function () {
901 echo "Hello World" 1085 echo "Hello World"
@@ -907,19 +1091,19 @@ rules. The scripts are executed by ``/bin/sh``, which may not be a bash
907shell but might be something such as ``dash``. You should not use 1091shell but might be something such as ``dash``. You should not use
908Bash-specific script (bashisms). 1092Bash-specific script (bashisms).
909 1093
910Overrides and override-style operators like ``_append`` and ``_prepend`` 1094Overrides and override-style operators like ``:append`` and ``:prepend``
911can also be applied to shell functions. Most commonly, this application 1095can also be applied to shell functions. Most commonly, this application
912would be used in a ``.bbappend`` file to modify functions in the main 1096would be used in a ``.bbappend`` file to modify functions in the main
913recipe. It can also be used to modify functions inherited from classes. 1097recipe. It can also be used to modify functions inherited from classes.
914 1098
915As an example, consider the following: :: 1099As an example, consider the following::
916 1100
917 do_foo() { 1101 do_foo() {
918 bbplain first 1102 bbplain first
919 fn 1103 fn
920 } 1104 }
921 1105
922 fn_prepend() { 1106 fn:prepend() {
923 bbplain second 1107 bbplain second
924 } 1108 }
925 1109
@@ -927,11 +1111,11 @@ As an example, consider the following: ::
927 bbplain third 1111 bbplain third
928 } 1112 }
929 1113
930 do_foo_append() { 1114 do_foo:append() {
931 bbplain fourth 1115 bbplain fourth
932 } 1116 }
933 1117
934Running ``do_foo`` prints the following: :: 1118Running ``do_foo`` prints the following::
935 1119
936 recipename do_foo: first 1120 recipename do_foo: first
937 recipename do_foo: second 1121 recipename do_foo: second
@@ -943,7 +1127,7 @@ Running ``do_foo`` prints the following: ::
943 Overrides and override-style operators can be applied to any shell 1127 Overrides and override-style operators can be applied to any shell
944 function, not just :ref:`tasks <bitbake-user-manual/bitbake-user-manual-metadata:tasks>`. 1128 function, not just :ref:`tasks <bitbake-user-manual/bitbake-user-manual-metadata:tasks>`.
945 1129
946You can use the ``bitbake -e`` recipename command to view the final 1130You can use the ``bitbake -e recipename`` command to view the final
947assembled function after all overrides have been applied. 1131assembled function after all overrides have been applied.
948 1132
949BitBake-Style Python Functions 1133BitBake-Style Python Functions
@@ -952,7 +1136,7 @@ BitBake-Style Python Functions
952These functions are written in Python and executed by BitBake or other 1136These functions are written in Python and executed by BitBake or other
953Python functions using ``bb.build.exec_func()``. 1137Python functions using ``bb.build.exec_func()``.
954 1138
955An example BitBake function is: :: 1139An example BitBake function is::
956 1140
957 python some_python_function () { 1141 python some_python_function () {
958 d.setVar("TEXT", "Hello World") 1142 d.setVar("TEXT", "Hello World")
@@ -975,9 +1159,9 @@ import these modules. Also in these types of functions, the datastore
975Similar to shell functions, you can also apply overrides and 1159Similar to shell functions, you can also apply overrides and
976override-style operators to BitBake-style Python functions. 1160override-style operators to BitBake-style Python functions.
977 1161
978As an example, consider the following: :: 1162As an example, consider the following::
979 1163
980 python do_foo_prepend() { 1164 python do_foo:prepend() {
981 bb.plain("first") 1165 bb.plain("first")
982 } 1166 }
983 1167
@@ -985,17 +1169,17 @@ As an example, consider the following: ::
985 bb.plain("second") 1169 bb.plain("second")
986 } 1170 }
987 1171
988 python do_foo_append() { 1172 python do_foo:append() {
989 bb.plain("third") 1173 bb.plain("third")
990 } 1174 }
991 1175
992Running ``do_foo`` prints the following: :: 1176Running ``do_foo`` prints the following::
993 1177
994 recipename do_foo: first 1178 recipename do_foo: first
995 recipename do_foo: second 1179 recipename do_foo: second
996 recipename do_foo: third 1180 recipename do_foo: third
997 1181
998You can use the ``bitbake -e`` recipename command to view 1182You can use the ``bitbake -e recipename`` command to view
999the final assembled function after all overrides have been applied. 1183the final assembled function after all overrides have been applied.
1000 1184
1001Python Functions 1185Python Functions
@@ -1004,7 +1188,7 @@ Python Functions
1004These functions are written in Python and are executed by other Python 1188These functions are written in Python and are executed by other Python
1005code. Examples of Python functions are utility functions that you intend 1189code. Examples of Python functions are utility functions that you intend
1006to call from in-line Python or from within other Python functions. Here 1190to call from in-line Python or from within other Python functions. Here
1007is an example: :: 1191is an example::
1008 1192
1009 def get_depends(d): 1193 def get_depends(d):
1010 if d.getVar('SOMECONDITION'): 1194 if d.getVar('SOMECONDITION'):
@@ -1015,7 +1199,7 @@ is an example: ::
1015 SOMECONDITION = "1" 1199 SOMECONDITION = "1"
1016 DEPENDS = "${@get_depends(d)}" 1200 DEPENDS = "${@get_depends(d)}"
1017 1201
1018This would result in ``DEPENDS`` containing ``dependencywithcond``. 1202This would result in :term:`DEPENDS` containing ``dependencywithcond``.
1019 1203
1020Here are some things to know about Python functions: 1204Here are some things to know about Python functions:
1021 1205
@@ -1056,7 +1240,7 @@ functions and regular Python functions defined with "def":
1056- Regular Python functions are called with the usual Python syntax. 1240- Regular Python functions are called with the usual Python syntax.
1057 BitBake-style Python functions are usually tasks and are called 1241 BitBake-style Python functions are usually tasks and are called
1058 directly by BitBake, but can also be called manually from Python code 1242 directly by BitBake, but can also be called manually from Python code
1059 by using the ``bb.build.exec_func()`` function. Here is an example: :: 1243 by using the ``bb.build.exec_func()`` function. Here is an example::
1060 1244
1061 bb.build.exec_func("my_bitbake_style_function", d) 1245 bb.build.exec_func("my_bitbake_style_function", d)
1062 1246
@@ -1094,7 +1278,7 @@ Sometimes it is useful to set variables or perform other operations
1094programmatically during parsing. To do this, you can define special 1278programmatically during parsing. To do this, you can define special
1095Python functions, called anonymous Python functions, that run at the end 1279Python functions, called anonymous Python functions, that run at the end
1096of parsing. For example, the following conditionally sets a variable 1280of parsing. For example, the following conditionally sets a variable
1097based on the value of another variable: :: 1281based on the value of another variable::
1098 1282
1099 python () { 1283 python () {
1100 if d.getVar('SOMEVAR') == 'value': 1284 if d.getVar('SOMEVAR') == 'value':
@@ -1107,7 +1291,7 @@ the name "__anonymous", rather than no name.
1107Anonymous Python functions always run at the end of parsing, regardless 1291Anonymous Python functions always run at the end of parsing, regardless
1108of where they are defined. If a recipe contains many anonymous 1292of where they are defined. If a recipe contains many anonymous
1109functions, they run in the same order as they are defined within the 1293functions, they run in the same order as they are defined within the
1110recipe. As an example, consider the following snippet: :: 1294recipe. As an example, consider the following snippet::
1111 1295
1112 python () { 1296 python () {
1113 d.setVar('FOO', 'foo 2') 1297 d.setVar('FOO', 'foo 2')
@@ -1122,7 +1306,7 @@ recipe. As an example, consider the following snippet: ::
1122 BAR = "bar 1" 1306 BAR = "bar 1"
1123 1307
1124The previous example is conceptually 1308The previous example is conceptually
1125equivalent to the following snippet: :: 1309equivalent to the following snippet::
1126 1310
1127 FOO = "foo 1" 1311 FOO = "foo 1"
1128 BAR = "bar 1" 1312 BAR = "bar 1"
@@ -1134,12 +1318,12 @@ equivalent to the following snippet: ::
1134values set for the variables within the anonymous functions become 1318values set for the variables within the anonymous functions become
1135available to tasks, which always run after parsing. 1319available to tasks, which always run after parsing.
1136 1320
1137Overrides and override-style operators such as "``_append``" are applied 1321Overrides and override-style operators such as "``:append``" are applied
1138before anonymous functions run. In the following example, ``FOO`` ends 1322before anonymous functions run. In the following example, ``FOO`` ends
1139up with the value "foo from anonymous": :: 1323up with the value "foo from anonymous"::
1140 1324
1141 FOO = "foo" 1325 FOO = "foo"
1142 FOO_append = " from outside" 1326 FOO:append = " from outside"
1143 1327
1144 python () { 1328 python () {
1145 d.setVar("FOO", "foo from anonymous") 1329 d.setVar("FOO", "foo from anonymous")
@@ -1164,7 +1348,7 @@ To understand the benefits of this feature, consider the basic scenario
1164where a class defines a task function and your recipe inherits the 1348where a class defines a task function and your recipe inherits the
1165class. In this basic scenario, your recipe inherits the task function as 1349class. In this basic scenario, your recipe inherits the task function as
1166defined in the class. If desired, your recipe can add to the start and 1350defined in the class. If desired, your recipe can add to the start and
1167end of the function by using the "_prepend" or "_append" operations 1351end of the function by using the ":prepend" or ":append" operations
1168respectively, or it can redefine the function completely. However, if it 1352respectively, or it can redefine the function completely. However, if it
1169redefines the function, there is no means for it to call the class 1353redefines the function, there is no means for it to call the class
1170version of the function. ``EXPORT_FUNCTIONS`` provides a mechanism that 1354version of the function. ``EXPORT_FUNCTIONS`` provides a mechanism that
@@ -1173,24 +1357,24 @@ version of the function.
1173 1357
1174To make use of this technique, you need the following things in place: 1358To make use of this technique, you need the following things in place:
1175 1359
1176- The class needs to define the function as follows: :: 1360- The class needs to define the function as follows::
1177 1361
1178 classname_functionname 1362 classname_functionname
1179 1363
1180 For example, if you have a class file 1364 For example, if you have a class file
1181 ``bar.bbclass`` and a function named ``do_foo``, the class must 1365 ``bar.bbclass`` and a function named ``do_foo``, the class must
1182 define the function as follows: :: 1366 define the function as follows::
1183 1367
1184 bar_do_foo 1368 bar_do_foo
1185 1369
1186- The class needs to contain the ``EXPORT_FUNCTIONS`` statement as 1370- The class needs to contain the ``EXPORT_FUNCTIONS`` statement as
1187 follows: :: 1371 follows::
1188 1372
1189 EXPORT_FUNCTIONS functionname 1373 EXPORT_FUNCTIONS functionname
1190 1374
1191 For example, continuing with 1375 For example, continuing with
1192 the same example, the statement in the ``bar.bbclass`` would be as 1376 the same example, the statement in the ``bar.bbclass`` would be as
1193 follows: :: 1377 follows::
1194 1378
1195 EXPORT_FUNCTIONS do_foo 1379 EXPORT_FUNCTIONS do_foo
1196 1380
@@ -1199,7 +1383,7 @@ To make use of this technique, you need the following things in place:
1199 class version of the function, it should call ``bar_do_foo``. 1383 class version of the function, it should call ``bar_do_foo``.
1200 Assuming ``do_foo`` was a shell function and ``EXPORT_FUNCTIONS`` was 1384 Assuming ``do_foo`` was a shell function and ``EXPORT_FUNCTIONS`` was
1201 used as above, the recipe's function could conditionally call the 1385 used as above, the recipe's function could conditionally call the
1202 class version of the function as follows: :: 1386 class version of the function as follows::
1203 1387
1204 do_foo() { 1388 do_foo() {
1205 if [ somecondition ] ; then 1389 if [ somecondition ] ; then
@@ -1233,11 +1417,11 @@ Tasks are either :ref:`shell functions <bitbake-user-manual/bitbake-user-manual-
1233that have been promoted to tasks by using the ``addtask`` command. The 1417that have been promoted to tasks by using the ``addtask`` command. The
1234``addtask`` command can also optionally describe dependencies between 1418``addtask`` command can also optionally describe dependencies between
1235the task and other tasks. Here is an example that shows how to define a 1419the task and other tasks. Here is an example that shows how to define a
1236task and declare some dependencies: :: 1420task and declare some dependencies::
1237 1421
1238 python do_printdate () { 1422 python do_printdate () {
1239 import time 1423 import datetime
1240 print time.strftime('%Y%m%d', time.gmtime()) 1424 bb.plain('Date: %s' % (datetime.date.today()))
1241 } 1425 }
1242 addtask printdate after do_fetch before do_build 1426 addtask printdate after do_fetch before do_build
1243 1427
@@ -1264,12 +1448,12 @@ Additionally, the ``do_printdate`` task becomes dependent upon the
1264 rerun for experimentation purposes, you can make BitBake always 1448 rerun for experimentation purposes, you can make BitBake always
1265 consider the task "out-of-date" by using the 1449 consider the task "out-of-date" by using the
1266 :ref:`[nostamp] <bitbake-user-manual/bitbake-user-manual-metadata:Variable Flags>` 1450 :ref:`[nostamp] <bitbake-user-manual/bitbake-user-manual-metadata:Variable Flags>`
1267 variable flag, as follows: :: 1451 variable flag, as follows::
1268 1452
1269 do_printdate[nostamp] = "1" 1453 do_printdate[nostamp] = "1"
1270 1454
1271 You can also explicitly run the task and provide the 1455 You can also explicitly run the task and provide the
1272 -f option as follows: :: 1456 -f option as follows::
1273 1457
1274 $ bitbake recipe -c printdate -f 1458 $ bitbake recipe -c printdate -f
1275 1459
@@ -1278,7 +1462,7 @@ Additionally, the ``do_printdate`` task becomes dependent upon the
1278 name. 1462 name.
1279 1463
1280You might wonder about the practical effects of using ``addtask`` 1464You might wonder about the practical effects of using ``addtask``
1281without specifying any dependencies as is done in the following example: :: 1465without specifying any dependencies as is done in the following example::
1282 1466
1283 addtask printdate 1467 addtask printdate
1284 1468
@@ -1286,7 +1470,7 @@ In this example, assuming dependencies have not been
1286added through some other means, the only way to run the task is by 1470added through some other means, the only way to run the task is by
1287explicitly selecting it with ``bitbake`` recipe ``-c printdate``. You 1471explicitly selecting it with ``bitbake`` recipe ``-c printdate``. You
1288can use the ``do_listtasks`` task to list all tasks defined in a recipe 1472can use the ``do_listtasks`` task to list all tasks defined in a recipe
1289as shown in the following example: :: 1473as shown in the following example::
1290 1474
1291 $ bitbake recipe -c listtasks 1475 $ bitbake recipe -c listtasks
1292 1476
@@ -1296,12 +1480,23 @@ For more information on task dependencies, see the
1296See the ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:variable flags`" section for information 1480See the ":ref:`bitbake-user-manual/bitbake-user-manual-metadata:variable flags`" section for information
1297on variable flags you can use with tasks. 1481on variable flags you can use with tasks.
1298 1482
1483.. note::
1484
1485 While it's infrequent, it's possible to define multiple tasks as
1486 dependencies when calling ``addtask``. For example, here's a snippet
1487 from the OpenEmbedded class file ``package_tar.bbclass``::
1488
1489 addtask package_write_tar before do_build after do_packagedata do_package
1490
1491 Note how the ``package_write_tar`` task has to wait until both of
1492 ``do_packagedata`` and ``do_package`` complete.
1493
1299Deleting a Task 1494Deleting a Task
1300--------------- 1495---------------
1301 1496
1302As well as being able to add tasks, you can delete them. Simply use the 1497As well as being able to add tasks, you can delete them. Simply use the
1303``deltask`` command to delete a task. For example, to delete the example 1498``deltask`` command to delete a task. For example, to delete the example
1304task used in the previous sections, you would use: :: 1499task used in the previous sections, you would use::
1305 1500
1306 deltask printdate 1501 deltask printdate
1307 1502
@@ -1317,7 +1512,7 @@ to run before ``do_a``.
1317 1512
1318If you want dependencies such as these to remain intact, use the 1513If you want dependencies such as these to remain intact, use the
1319``[noexec]`` varflag to disable the task instead of using the 1514``[noexec]`` varflag to disable the task instead of using the
1320``deltask`` command to delete it: :: 1515``deltask`` command to delete it::
1321 1516
1322 do_b[noexec] = "1" 1517 do_b[noexec] = "1"
1323 1518
@@ -1331,8 +1526,8 @@ the build machine cannot influence the build.
1331.. note:: 1526.. note::
1332 1527
1333 By default, BitBake cleans the environment to include only those 1528 By default, BitBake cleans the environment to include only those
1334 things exported or listed in its whitelist to ensure that the build 1529 things exported or listed in its passthrough list to ensure that the
1335 environment is reproducible and consistent. You can prevent this 1530 build environment is reproducible and consistent. You can prevent this
1336 "cleaning" by setting the :term:`BB_PRESERVE_ENV` variable. 1531 "cleaning" by setting the :term:`BB_PRESERVE_ENV` variable.
1337 1532
1338Consequently, if you do want something to get passed into the build task 1533Consequently, if you do want something to get passed into the build task
@@ -1340,14 +1535,14 @@ environment, you must take these two steps:
1340 1535
1341#. Tell BitBake to load what you want from the environment into the 1536#. Tell BitBake to load what you want from the environment into the
1342 datastore. You can do so through the 1537 datastore. You can do so through the
1343 :term:`BB_ENV_WHITELIST` and 1538 :term:`BB_ENV_PASSTHROUGH` and
1344 :term:`BB_ENV_EXTRAWHITE` variables. For 1539 :term:`BB_ENV_PASSTHROUGH_ADDITIONS` variables. For
1345 example, assume you want to prevent the build system from accessing 1540 example, assume you want to prevent the build system from accessing
1346 your ``$HOME/.ccache`` directory. The following command "whitelists" 1541 your ``$HOME/.ccache`` directory. The following command adds the
1347 the environment variable ``CCACHE_DIR`` causing BitBake to allow that 1542 the environment variable ``CCACHE_DIR`` to BitBake's passthrough
1348 variable into the datastore: :: 1543 list to allow that variable into the datastore::
1349 1544
1350 export BB_ENV_EXTRAWHITE="$BB_ENV_EXTRAWHITE CCACHE_DIR" 1545 export BB_ENV_PASSTHROUGH_ADDITIONS="$BB_ENV_PASSTHROUGH_ADDITIONS CCACHE_DIR"
1351 1546
1352#. Tell BitBake to export what you have loaded into the datastore to the 1547#. Tell BitBake to export what you have loaded into the datastore to the
1353 task environment of every running task. Loading something from the 1548 task environment of every running task. Loading something from the
@@ -1355,7 +1550,7 @@ environment, you must take these two steps:
1355 available in the datastore. To export it to the task environment of 1550 available in the datastore. To export it to the task environment of
1356 every running task, use a command similar to the following in your 1551 every running task, use a command similar to the following in your
1357 local configuration file ``local.conf`` or your distribution 1552 local configuration file ``local.conf`` or your distribution
1358 configuration file: :: 1553 configuration file::
1359 1554
1360 export CCACHE_DIR 1555 export CCACHE_DIR
1361 1556
@@ -1364,17 +1559,17 @@ environment, you must take these two steps:
1364 A side effect of the previous steps is that BitBake records the 1559 A side effect of the previous steps is that BitBake records the
1365 variable as a dependency of the build process in things like the 1560 variable as a dependency of the build process in things like the
1366 setscene checksums. If doing so results in unnecessary rebuilds of 1561 setscene checksums. If doing so results in unnecessary rebuilds of
1367 tasks, you can whitelist the variable so that the setscene code 1562 tasks, you can also flag the variable so that the setscene code
1368 ignores the dependency when it creates checksums. 1563 ignores the dependency when it creates checksums.
1369 1564
1370Sometimes, it is useful to be able to obtain information from the 1565Sometimes, it is useful to be able to obtain information from the
1371original execution environment. BitBake saves a copy of the original 1566original execution environment. BitBake saves a copy of the original
1372environment into a special variable named :term:`BB_ORIGENV`. 1567environment into a special variable named :term:`BB_ORIGENV`.
1373 1568
1374The ``BB_ORIGENV`` variable returns a datastore object that can be 1569The :term:`BB_ORIGENV` variable returns a datastore object that can be
1375queried using the standard datastore operators such as 1570queried using the standard datastore operators such as
1376``getVar(, False)``. The datastore object is useful, for example, to 1571``getVar(, False)``. The datastore object is useful, for example, to
1377find the original ``DISPLAY`` variable. Here is an example: :: 1572find the original ``DISPLAY`` variable. Here is an example::
1378 1573
1379 origenv = d.getVar("BB_ORIGENV", False) 1574 origenv = d.getVar("BB_ORIGENV", False)
1380 bar = origenv.getVar("BAR", False) 1575 bar = origenv.getVar("BAR", False)
@@ -1387,7 +1582,7 @@ Variable Flags
1387 1582
1388Variable flags (varflags) help control a task's functionality and 1583Variable flags (varflags) help control a task's functionality and
1389dependencies. BitBake reads and writes varflags to the datastore using 1584dependencies. BitBake reads and writes varflags to the datastore using
1390the following command forms: :: 1585the following command forms::
1391 1586
1392 variable = d.getVarFlags("variable") 1587 variable = d.getVarFlags("variable")
1393 self.d.setVarFlags("FOO", {"func": True}) 1588 self.d.setVarFlags("FOO", {"func": True})
@@ -1418,12 +1613,35 @@ functionality of the task:
1418 directory listed is used as the current working directory for the 1613 directory listed is used as the current working directory for the
1419 task. 1614 task.
1420 1615
1616- ``[file-checksums]``: Controls the file dependencies for a task. The
1617 baseline file list is the set of files associated with
1618 :term:`SRC_URI`. May be used to set additional dependencies on
1619 files not associated with :term:`SRC_URI`.
1620
1621 The value set to the list is a file-boolean pair where the first
1622 value is the file name and the second is whether or not it
1623 physically exists on the filesystem. ::
1624
1625 do_configure[file-checksums] += "${MY_DIRPATH}/my-file.txt:True"
1626
1627 It is important to record any paths which the task looked at and
1628 which didn't exist. This means that if these do exist at a later
1629 time, the task can be rerun with the new additional files. The
1630 "exists" True or False value after the path allows this to be
1631 handled.
1632
1421- ``[lockfiles]``: Specifies one or more lockfiles to lock while the 1633- ``[lockfiles]``: Specifies one or more lockfiles to lock while the
1422 task executes. Only one task may hold a lockfile, and any task that 1634 task executes. Only one task may hold a lockfile, and any task that
1423 attempts to lock an already locked file will block until the lock is 1635 attempts to lock an already locked file will block until the lock is
1424 released. You can use this variable flag to accomplish mutual 1636 released. You can use this variable flag to accomplish mutual
1425 exclusion. 1637 exclusion.
1426 1638
1639- ``[network]``: When set to "1", allows a task to access the network. By
1640 default, only the ``do_fetch`` task is granted network access. Recipes
1641 shouldn't access the network outside of ``do_fetch`` as it usually
1642 undermines fetcher source mirroring, image and licence manifests, software
1643 auditing and supply chain security.
1644
1427- ``[noexec]``: When set to "1", marks the task as being empty, with 1645- ``[noexec]``: When set to "1", marks the task as being empty, with
1428 no execution required. You can use the ``[noexec]`` flag to set up 1646 no execution required. You can use the ``[noexec]`` flag to set up
1429 tasks as dependency placeholders, or to disable tasks defined 1647 tasks as dependency placeholders, or to disable tasks defined
@@ -1456,7 +1674,7 @@ functionality of the task:
1456 can result in unpredictable behavior. 1674 can result in unpredictable behavior.
1457 1675
1458 - Setting the varflag to a value greater than the value used in 1676 - Setting the varflag to a value greater than the value used in
1459 the ``BB_NUMBER_THREADS`` variable causes ``number_threads`` to 1677 the :term:`BB_NUMBER_THREADS` variable causes ``number_threads`` to
1460 have no effect. 1678 have no effect.
1461 1679
1462- ``[postfuncs]``: List of functions to call after the completion of 1680- ``[postfuncs]``: List of functions to call after the completion of
@@ -1526,7 +1744,7 @@ intent is to make it easy to do things like email notification on build
1526failures. 1744failures.
1527 1745
1528Following is an example event handler that prints the name of the event 1746Following is an example event handler that prints the name of the event
1529and the content of the ``FILE`` variable: :: 1747and the content of the :term:`FILE` variable::
1530 1748
1531 addhandler myclass_eventhandler 1749 addhandler myclass_eventhandler
1532 python myclass_eventhandler() { 1750 python myclass_eventhandler() {
@@ -1565,11 +1783,11 @@ might have an interest in viewing:
1565 1783
1566- ``bb.event.ConfigParsed()``: Fired when the base configuration; which 1784- ``bb.event.ConfigParsed()``: Fired when the base configuration; which
1567 consists of ``bitbake.conf``, ``base.bbclass`` and any global 1785 consists of ``bitbake.conf``, ``base.bbclass`` and any global
1568 ``INHERIT`` statements; has been parsed. You can see multiple such 1786 :term:`INHERIT` statements; has been parsed. You can see multiple such
1569 events when each of the workers parse the base configuration or if 1787 events when each of the workers parse the base configuration or if
1570 the server changes configuration and reparses. Any given datastore 1788 the server changes configuration and reparses. Any given datastore
1571 only has one such event executed against it, however. If 1789 only has one such event executed against it, however. If
1572 ```BB_INVALIDCONF`` <#>`__ is set in the datastore by the event 1790 :term:`BB_INVALIDCONF` is set in the datastore by the event
1573 handler, the configuration is reparsed and a new event triggered, 1791 handler, the configuration is reparsed and a new event triggered,
1574 allowing the metadata to update configuration. 1792 allowing the metadata to update configuration.
1575 1793
@@ -1636,13 +1854,18 @@ user interfaces:
1636 1854
1637.. _variants-class-extension-mechanism: 1855.. _variants-class-extension-mechanism:
1638 1856
1639Variants - Class Extension Mechanism 1857Variants --- Class Extension Mechanism
1640==================================== 1858======================================
1859
1860BitBake supports multiple incarnations of a recipe file via the
1861:term:`BBCLASSEXTEND` variable.
1862
1863The :term:`BBCLASSEXTEND` variable is a space separated list of classes used
1864to "extend" the recipe for each variant. Here is an example that results in a
1865second incarnation of the current recipe being available. This second
1866incarnation will have the "native" class inherited. ::
1641 1867
1642BitBake supports two features that facilitate creating from a single 1868 BBCLASSEXTEND = "native"
1643recipe file multiple incarnations of that recipe file where all
1644incarnations are buildable. These features are enabled through the
1645:term:`BBCLASSEXTEND` and :term:`BBVERSIONS` variables.
1646 1869
1647.. note:: 1870.. note::
1648 1871
@@ -1652,34 +1875,6 @@ incarnations are buildable. These features are enabled through the
1652 class. For specific examples, see the OE-Core native , nativesdk , and 1875 class. For specific examples, see the OE-Core native , nativesdk , and
1653 multilib classes. 1876 multilib classes.
1654 1877
1655- ``BBCLASSEXTEND``: This variable is a space separated list of
1656 classes used to "extend" the recipe for each variant. Here is an
1657 example that results in a second incarnation of the current recipe
1658 being available. This second incarnation will have the "native" class
1659 inherited. ::
1660
1661 BBCLASSEXTEND = "native"
1662
1663- ``BBVERSIONS``: This variable allows a single recipe to build
1664 multiple versions of a project from a single recipe file. You can
1665 also specify conditional metadata (using the
1666 :term:`OVERRIDES` mechanism) for a single
1667 version, or an optionally named range of versions. Here is an
1668 example: ::
1669
1670 BBVERSIONS = "1.0 2.0 git"
1671 SRC_URI_git = "git://someurl/somepath.git"
1672
1673 BBVERSIONS = "1.0.[0-6]:1.0.0+ 1.0.[7-9]:1.0.7+"
1674 SRC_URI_append_1.0.7+ = "file://some_patch_which_the_new_versions_need.patch;patch=1"
1675
1676 The name of the range defaults to the original version of the recipe. For
1677 example, in OpenEmbedded, the recipe file ``foo_1.0.0+.bb`` creates a default
1678 name range of ``1.0.0+``. This is useful because the range name is not only
1679 placed into overrides, but it is also made available for the metadata to use
1680 in the variable that defines the base recipe versions for use in ``file://``
1681 search paths (:term:`FILESPATH`).
1682
1683Dependencies 1878Dependencies
1684============ 1879============
1685 1880
@@ -1708,7 +1903,7 @@ Dependencies Internal to the ``.bb`` File
1708BitBake uses the ``addtask`` directive to manage dependencies that are 1903BitBake uses the ``addtask`` directive to manage dependencies that are
1709internal to a given recipe file. You can use the ``addtask`` directive 1904internal to a given recipe file. You can use the ``addtask`` directive
1710to indicate when a task is dependent on other tasks or when other tasks 1905to indicate when a task is dependent on other tasks or when other tasks
1711depend on that recipe. Here is an example: :: 1906depend on that recipe. Here is an example::
1712 1907
1713 addtask printdate after do_fetch before do_build 1908 addtask printdate after do_fetch before do_build
1714 1909
@@ -1732,7 +1927,7 @@ task depends on the completion of the ``do_printdate`` task.
1732 1927
1733 - The directive ``addtask mytask after do_configure`` by itself 1928 - The directive ``addtask mytask after do_configure`` by itself
1734 never causes ``do_mytask`` to run. ``do_mytask`` can still be run 1929 never causes ``do_mytask`` to run. ``do_mytask`` can still be run
1735 manually as follows: :: 1930 manually as follows::
1736 1931
1737 $ bitbake recipe -c mytask 1932 $ bitbake recipe -c mytask
1738 1933
@@ -1745,13 +1940,13 @@ Build Dependencies
1745 1940
1746BitBake uses the :term:`DEPENDS` variable to manage 1941BitBake uses the :term:`DEPENDS` variable to manage
1747build time dependencies. The ``[deptask]`` varflag for tasks signifies 1942build time dependencies. The ``[deptask]`` varflag for tasks signifies
1748the task of each item listed in ``DEPENDS`` that must complete before 1943the task of each item listed in :term:`DEPENDS` that must complete before
1749that task can be executed. Here is an example: :: 1944that task can be executed. Here is an example::
1750 1945
1751 do_configure[deptask] = "do_populate_sysroot" 1946 do_configure[deptask] = "do_populate_sysroot"
1752 1947
1753In this example, the ``do_populate_sysroot`` task 1948In this example, the ``do_populate_sysroot`` task
1754of each item in ``DEPENDS`` must complete before ``do_configure`` can 1949of each item in :term:`DEPENDS` must complete before ``do_configure`` can
1755execute. 1950execute.
1756 1951
1757Runtime Dependencies 1952Runtime Dependencies
@@ -1760,8 +1955,8 @@ Runtime Dependencies
1760BitBake uses the :term:`PACKAGES`, :term:`RDEPENDS`, and :term:`RRECOMMENDS` 1955BitBake uses the :term:`PACKAGES`, :term:`RDEPENDS`, and :term:`RRECOMMENDS`
1761variables to manage runtime dependencies. 1956variables to manage runtime dependencies.
1762 1957
1763The ``PACKAGES`` variable lists runtime packages. Each of those packages 1958The :term:`PACKAGES` variable lists runtime packages. Each of those packages
1764can have ``RDEPENDS`` and ``RRECOMMENDS`` runtime dependencies. The 1959can have :term:`RDEPENDS` and :term:`RRECOMMENDS` runtime dependencies. The
1765``[rdeptask]`` flag for tasks is used to signify the task of each item 1960``[rdeptask]`` flag for tasks is used to signify the task of each item
1766runtime dependency which must have completed before that task can be 1961runtime dependency which must have completed before that task can be
1767executed. :: 1962executed. ::
@@ -1769,9 +1964,9 @@ executed. ::
1769 do_package_qa[rdeptask] = "do_packagedata" 1964 do_package_qa[rdeptask] = "do_packagedata"
1770 1965
1771In the previous 1966In the previous
1772example, the ``do_packagedata`` task of each item in ``RDEPENDS`` must 1967example, the ``do_packagedata`` task of each item in :term:`RDEPENDS` must
1773have completed before ``do_package_qa`` can execute. 1968have completed before ``do_package_qa`` can execute.
1774Although ``RDEPENDS`` contains entries from the 1969Although :term:`RDEPENDS` contains entries from the
1775runtime dependency namespace, BitBake knows how to map them back 1970runtime dependency namespace, BitBake knows how to map them back
1776to the build-time dependency namespace, in which the tasks are defined. 1971to the build-time dependency namespace, in which the tasks are defined.
1777 1972
@@ -1788,7 +1983,7 @@ dependencies are discovered and added.
1788 1983
1789The ``[recrdeptask]`` flag is most commonly used in high-level recipes 1984The ``[recrdeptask]`` flag is most commonly used in high-level recipes
1790that need to wait for some task to finish "globally". For example, 1985that need to wait for some task to finish "globally". For example,
1791``image.bbclass`` has the following: :: 1986``image.bbclass`` has the following::
1792 1987
1793 do_rootfs[recrdeptask] += "do_packagedata" 1988 do_rootfs[recrdeptask] += "do_packagedata"
1794 1989
@@ -1797,7 +1992,7 @@ the current recipe and all recipes reachable (by way of dependencies)
1797from the image recipe must run before the ``do_rootfs`` task can run. 1992from the image recipe must run before the ``do_rootfs`` task can run.
1798 1993
1799BitBake allows a task to recursively depend on itself by 1994BitBake allows a task to recursively depend on itself by
1800referencing itself in the task list: :: 1995referencing itself in the task list::
1801 1996
1802 do_a[recrdeptask] = "do_a do_b" 1997 do_a[recrdeptask] = "do_a do_b"
1803 1998
@@ -1814,7 +2009,7 @@ Inter-Task Dependencies
1814BitBake uses the ``[depends]`` flag in a more generic form to manage 2009BitBake uses the ``[depends]`` flag in a more generic form to manage
1815inter-task dependencies. This more generic form allows for 2010inter-task dependencies. This more generic form allows for
1816inter-dependency checks for specific tasks rather than checks for the 2011inter-dependency checks for specific tasks rather than checks for the
1817data in ``DEPENDS``. Here is an example: :: 2012data in :term:`DEPENDS`. Here is an example::
1818 2013
1819 do_patch[depends] = "quilt-native:do_populate_sysroot" 2014 do_patch[depends] = "quilt-native:do_populate_sysroot"
1820 2015
@@ -1894,11 +2089,35 @@ access. Here is a list of available operations:
1894Other Functions 2089Other Functions
1895--------------- 2090---------------
1896 2091
1897You can find many other functions that can be called from Python by 2092Other functions are documented in the
1898looking at the source code of the ``bb`` module, which is in 2093:doc:`/bitbake-user-manual/bitbake-user-manual-library-functions` document.
1899``bitbake/lib/bb``. For example, ``bitbake/lib/bb/utils.py`` includes 2094
1900the commonly used functions ``bb.utils.contains()`` and 2095Extending Python Library Code
1901``bb.utils.mkdirhier()``, which come with docstrings. 2096-----------------------------
2097
2098If you wish to add your own Python library code (e.g. to provide
2099functions/classes you can use from Python functions in the metadata)
2100you can do so from any layer using the ``addpylib`` directive.
2101This directive is typically added to your layer configuration (
2102``conf/layer.conf``) although it will be handled in any ``.conf`` file.
2103
2104Usage is of the form::
2105
2106 addpylib <directory> <namespace>
2107
2108Where <directory> specifies the directory to add to the library path.
2109The specified <namespace> is imported automatically, and if the imported
2110module specifies an attribute named ``BBIMPORTS``, that list of
2111sub-modules is iterated and imported too.
2112
2113Testing and Debugging BitBake Python code
2114-----------------------------------------
2115
2116The OpenEmbedded build system implements a convenient ``pydevshell`` target which
2117you can use to access the BitBake datastore and experiment with your own Python
2118code. See :yocto_docs:`Using a Python Development Shell
2119</dev-manual/python-development-shell.html#using-a-python-development-shell>` in the Yocto
2120Project manual for details.
1902 2121
1903Task Checksums and Setscene 2122Task Checksums and Setscene
1904=========================== 2123===========================
@@ -1909,7 +2128,7 @@ To help understand how BitBake does this, the section assumes an
1909OpenEmbedded metadata-based example. 2128OpenEmbedded metadata-based example.
1910 2129
1911These checksums are stored in :term:`STAMP`. You can 2130These checksums are stored in :term:`STAMP`. You can
1912examine the checksums using the following BitBake command: :: 2131examine the checksums using the following BitBake command::
1913 2132
1914 $ bitbake-dumpsigs 2133 $ bitbake-dumpsigs
1915 2134
@@ -1932,16 +2151,6 @@ The following list describes related variables:
1932 Specifies a function BitBake calls that determines whether BitBake 2151 Specifies a function BitBake calls that determines whether BitBake
1933 requires a setscene dependency to be met. 2152 requires a setscene dependency to be met.
1934 2153
1935- :term:`BB_SETSCENE_VERIFY_FUNCTION2`:
1936 Specifies a function to call that verifies the list of planned task
1937 execution before the main task execution happens.
1938
1939- :term:`BB_STAMP_POLICY`: Defines the mode
1940 for comparing timestamps of stamp files.
1941
1942- :term:`BB_STAMP_WHITELIST`: Lists stamp
1943 files that are looked at when the stamp policy is "whitelist".
1944
1945- :term:`BB_TASKHASH`: Within an executing task, 2154- :term:`BB_TASKHASH`: Within an executing task,
1946 this variable holds the hash of the task as returned by the currently 2155 this variable holds the hash of the task as returned by the currently
1947 enabled signature generator. 2156 enabled signature generator.
@@ -1956,7 +2165,7 @@ Wildcard Support in Variables
1956============================= 2165=============================
1957 2166
1958Support for wildcard use in variables varies depending on the context in 2167Support for wildcard use in variables varies depending on the context in
1959which it is used. For example, some variables and file names allow 2168which it is used. For example, some variables and filenames allow
1960limited use of wildcards through the "``%``" and "``*``" characters. 2169limited use of wildcards through the "``%``" and "``*``" characters.
1961Other variables or names support Python's 2170Other variables or names support Python's
1962`glob <https://docs.python.org/3/library/glob.html>`_ syntax, 2171`glob <https://docs.python.org/3/library/glob.html>`_ syntax,