diff options
| -rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml index b3e7dd8d9e..862a6bddfe 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | |||
| @@ -652,6 +652,51 @@ | |||
| 652 | after the "inherit" statement. | 652 | after the "inherit" statement. |
| 653 | </note> | 653 | </note> |
| 654 | </para> | 654 | </para> |
| 655 | |||
| 656 | <para> | ||
| 657 | If necessary, it is possible to inherit a class | ||
| 658 | conditionally by using | ||
| 659 | a variable expression after the <filename>inherit</filename> | ||
| 660 | statement. | ||
| 661 | Here is an example: | ||
| 662 | <literallayout class='monospaced'> | ||
| 663 | inherit ${VARNAME} | ||
| 664 | </literallayout> | ||
| 665 | If <filename>VARNAME</filename> is going to be set, it needs | ||
| 666 | to be set before the <filename>inherit</filename> statement | ||
| 667 | is parsed. | ||
| 668 | One way to achieve a conditional inherit in this case is to use | ||
| 669 | overrides: | ||
| 670 | <literallayout class='monospaced'> | ||
| 671 | VARIABLE = "" | ||
| 672 | VARIABLE_someoverride = "myclass" | ||
| 673 | </literallayout> | ||
| 674 | </para> | ||
| 675 | |||
| 676 | <para> | ||
| 677 | Another method is by using anonymous Python. | ||
| 678 | Here is an example: | ||
| 679 | <literallayout class='monospaced'> | ||
| 680 | python () { | ||
| 681 | if condition == value: | ||
| 682 | d.setVar('VARIABLE', 'myclass') | ||
| 683 | else: | ||
| 684 | d.setVar('VARIABLE', '') | ||
| 685 | } | ||
| 686 | </literallayout> | ||
| 687 | </para> | ||
| 688 | |||
| 689 | <para> | ||
| 690 | Alternatively, you could use an in-line Python expression | ||
| 691 | in the following form: | ||
| 692 | <literallayout class='monospaced'> | ||
| 693 | inherit ${@'classname' if condition else ''} | ||
| 694 | inherit ${@functionname(params)} | ||
| 695 | </literallayout> | ||
| 696 | In all cases, if the expression evaluates to an empty | ||
| 697 | string, the statement does not trigger a syntax error | ||
| 698 | because it becomes a no-op. | ||
| 699 | </para> | ||
| 655 | </section> | 700 | </section> |
| 656 | 701 | ||
| 657 | <section id='include-directive'> | 702 | <section id='include-directive'> |
