diff options
| -rw-r--r-- | bitbake/doc/user-manual/user-manual-metadata.xml | 150 |
1 files changed, 122 insertions, 28 deletions
diff --git a/bitbake/doc/user-manual/user-manual-metadata.xml b/bitbake/doc/user-manual/user-manual-metadata.xml index 9708bbb12f..621b376d37 100644 --- a/bitbake/doc/user-manual/user-manual-metadata.xml +++ b/bitbake/doc/user-manual/user-manual-metadata.xml | |||
| @@ -484,49 +484,132 @@ | |||
| 484 | </section> | 484 | </section> |
| 485 | </section> | 485 | </section> |
| 486 | 486 | ||
| 487 | <section id='inheritance'> | 487 | <section id='sharing-functionality'> |
| 488 | <title>Inheritance</title> | 488 | <title>Sharing Functionality</title> |
| 489 | 489 | ||
| 490 | <section id='inheritance-directive'> | 490 | <para> |
| 491 | <title>Inheritance Directive</title> | 491 | BitBake allows for metadata sharing through include files and |
| 492 | class files (<filename>.bbclass</filename>). | ||
| 493 | For example, suppose you have a piece of common functionality | ||
| 494 | such as a task definition that you want to share between | ||
| 495 | more than one recipe. | ||
| 496 | In this case, creating a <filename>.bbclass</filename> | ||
| 497 | file that contains the common functionality and uses the | ||
| 498 | <filename>inherit</filename> directive would be a common | ||
| 499 | way to share the task. | ||
| 500 | </para> | ||
| 501 | |||
| 502 | <para> | ||
| 503 | This section presents the mechanisms BitBake provides to | ||
| 504 | allow you to share functionality between recipes. | ||
| 505 | Specifically, the mechanisms include <filename>include</filename>, | ||
| 506 | <filename>inherit</filename>, <filename>INHERIT</filename>, and | ||
| 507 | <filename>require</filename> statements. | ||
| 508 | </para> | ||
| 509 | |||
| 510 | <section id='locating-include-and-class-files'> | ||
| 511 | <title>Locating Include and Class Files</title> | ||
| 512 | |||
| 513 | <para> | ||
| 514 | BitBake uses the <filename>BBPATH</filename> variable | ||
| 515 | to locate needed class and configuration files. | ||
| 516 | The <filename>BBPATH</filename> variable is analogous to | ||
| 517 | the environment variable <filename>PATH</filename>. | ||
| 518 | Use of <filename>BBPATH</filename> is specific to the build | ||
| 519 | environment (e.g. Yocto Project, OpenEmbedded, and so forth). | ||
| 520 | </para> | ||
| 521 | </section> | ||
| 492 | 522 | ||
| 493 | <note> | 523 | <section id='inherit-directive'> |
| 494 | This is only supported in <filename>.bb</filename> and | 524 | <title><filename>inherit</filename> Directive</title> |
| 495 | <filename>.bbclass</filename> files. | ||
| 496 | </note> | ||
| 497 | 525 | ||
| 498 | <para> | 526 | <para> |
| 499 | The inherit directive is a means of specifying what classes | 527 | When writing a recipe or class file, you can use the |
| 500 | of functionality your <filename>.bb</filename> requires. | 528 | <filename>inherit</filename> directive to inherit the |
| 501 | It is a rudimentary form of inheritance. | 529 | functionality of a class (<filename>.bbclass</filename>). |
| 530 | BitBake only supports this directive when used within these | ||
| 531 | two types of files (i.e. <filename>.bb</filename> and | ||
| 532 | <filename>.bbclass</filename> files). | ||
| 533 | </para> | ||
| 534 | |||
| 535 | <para> | ||
| 536 | The <filename>inherit</filename> directive is a rudimentary | ||
| 537 | means of specifying what classes of functionality your | ||
| 538 | recipe requires. | ||
| 502 | For example, you can easily abstract out the tasks involved in | 539 | For example, you can easily abstract out the tasks involved in |
| 503 | building a package that uses autoconf and automake, and put | 540 | building a package that uses Autoconf and Automake and put |
| 504 | that into a bbclass for your packages to make use of. | 541 | those tasks into a class file that can be used by your package. |
| 505 | A given bbclass is located by searching for classes/filename.bbclass | 542 | As an example, an <filename>autotools.bbclass</filename> file |
| 506 | in <filename>BBPATH</filename>, where filename is what you inherited. | 543 | could use the following directive to inherit needed |
| 544 | site information: | ||
| 545 | <literallayout class='monospaced'> | ||
| 546 | inherit siteinfo | ||
| 547 | </literallayout> | ||
| 548 | In this case, BitBake would search for the directory | ||
| 549 | <filename>classes/siteinfo.bbclass</filename> | ||
| 550 | in <filename>BBPATH</filename>. | ||
| 507 | </para> | 551 | </para> |
| 508 | </section> | 552 | </section> |
| 509 | 553 | ||
| 510 | <section id='inclusion-directive'> | 554 | <section id='include-directive'> |
| 511 | <title>Inclusion Directive</title> | 555 | <title><filename>include</filename> Directive</title> |
| 512 | 556 | ||
| 513 | <para> | 557 | <para> |
| 558 | BitBake understands the <filename>include</filename> | ||
| 559 | directive. | ||
| 514 | This directive causes BitBake to parse whatever file you specify, | 560 | This directive causes BitBake to parse whatever file you specify, |
| 515 | and insert it at that location, which is not unlike Make. | 561 | and to insert that file at that location. |
| 516 | However, if the path specified on the include line is a | 562 | The directive is much like Make except that if the path specified |
| 517 | relative path, BitBake will locate the first one it can find | 563 | on the include line is a relative path, BitBake locates |
| 518 | within <filename>BBPATH</filename>. | 564 | the first file it can find within <filename>BBPATH</filename>. |
| 565 | </para> | ||
| 566 | |||
| 567 | <para> | ||
| 568 | As an example, suppose you needed a recipe to include some | ||
| 569 | self-test files: | ||
| 570 | <literallayout class='monospaced'> | ||
| 571 | include test_recipe.inc | ||
| 572 | </literallayout> | ||
| 573 | <note> | ||
| 574 | The <filename>include</filename> directive does not | ||
| 575 | produce an error when the file cannot be found. | ||
| 576 | Consequently, it is recommended that if the file you | ||
| 577 | are including is expected to exist, you should use | ||
| 578 | <link linkend='require-inclusion'><filename>require</filename></link> | ||
| 579 | instead of <filename>include</filename>. | ||
| 580 | Doing so makes sure that an error is produced if the | ||
| 581 | file cannot be found. | ||
| 582 | </note> | ||
| 519 | </para> | 583 | </para> |
| 520 | </section> | 584 | </section> |
| 521 | 585 | ||
| 522 | <section id='requiring-inclusion'> | 586 | <section id='require-inclusion'> |
| 523 | <title>Requiring Inclusion</title> | 587 | <title><filename>require</filename> Directive</title> |
| 524 | 588 | ||
| 525 | <para> | 589 | <para> |
| 526 | In contrast to the include directive, require will raise a | 590 | BitBake understands the <filename>require</filename> |
| 527 | ParseError if the file to be included cannot | 591 | directive. |
| 592 | This directive behaves just like the | ||
| 593 | <filename>include</filename> directive with the exception that | ||
| 594 | BitBake raises a parsing error if the file to be included cannot | ||
| 528 | be found. | 595 | be found. |
| 529 | Otherwise it will behave just like the include directive. | 596 | Thus, any file you require is inserted into the file that is |
| 597 | being parsed at the location of the directive. | ||
| 598 | </para> | ||
| 599 | |||
| 600 | <para> | ||
| 601 | Similar to how BitBake uses <filename>include</filename>, | ||
| 602 | if the path specified | ||
| 603 | on the require line is a relative path, BitBake locates | ||
| 604 | the first file it can find within <filename>BBPATH</filename>. | ||
| 605 | </para> | ||
| 606 | |||
| 607 | <para> | ||
| 608 | As an example, suppose you needed a recipe to require some | ||
| 609 | self-test files: | ||
| 610 | <literallayout class='monospaced'> | ||
| 611 | require test_recipe.inc | ||
| 612 | </literallayout> | ||
| 530 | </para> | 613 | </para> |
| 531 | </section> | 614 | </section> |
| 532 | 615 | ||
| @@ -534,9 +617,20 @@ | |||
| 534 | <title><filename>INHERIT</filename> Configuration Directive</title> | 617 | <title><filename>INHERIT</filename> Configuration Directive</title> |
| 535 | 618 | ||
| 536 | <para> | 619 | <para> |
| 620 | When creating a configuration file (<filename>.conf</filename>), | ||
| 621 | you can use the <filename>INHERIT</filename> directive to | ||
| 622 | inherit a class. | ||
| 623 | BitBake only supports this directive when used within | ||
| 624 | a configuration file. | ||
| 625 | </para> | ||
| 626 | |||
| 627 | <para> | ||
| 628 | Suppose you needed to inherit a multilib global class. | ||
| 629 | <literallayout class='monospaced'> | ||
| 630 | INHERIT += "multilib_global" | ||
| 631 | </literallayout> | ||
| 537 | This configuration directive causes the named class to be inherited | 632 | This configuration directive causes the named class to be inherited |
| 538 | at this point during parsing. | 633 | at the point of the directive during parsing. |
| 539 | This variable is only valid in configuration files. | ||
| 540 | </para> | 634 | </para> |
| 541 | </section> | 635 | </section> |
| 542 | </section> | 636 | </section> |
