summaryrefslogtreecommitdiffstats
path: root/bitbake
diff options
context:
space:
mode:
authorScott Rifenbark <srifenbark@gmail.com>2016-03-22 13:35:28 -0700
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-03-23 21:55:38 +0000
commit7ec8f286f70087aec1a82ff4c096cc5904b096ff (patch)
tree50de2b0a29da339bfc2245ee8295256339bd7dd3 /bitbake
parent75cba5443e34d8f215b605f8248ca0a2dd9a5a02 (diff)
downloadpoky-7ec8f286f70087aec1a82ff4c096cc5904b096ff.tar.gz
bitbake: bitbake-user-manual: Updated the "inherit Directive" section.
Fixes [YOCTO #9283] Updated the description to document conditional inherits. Provided several examples. (Bitbake rev: 07f97f4d913cf1c8233995152105fff6c6c7b9a0) Signed-off-by: Scott Rifenbark <srifenbark@gmail.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r--bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml45
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'>