diff options
author | Scott Rifenbark <srifenbark@gmail.com> | 2016-03-22 13:35:28 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2016-03-23 21:55:38 +0000 |
commit | 7ec8f286f70087aec1a82ff4c096cc5904b096ff (patch) | |
tree | 50de2b0a29da339bfc2245ee8295256339bd7dd3 /bitbake/doc | |
parent | 75cba5443e34d8f215b605f8248ca0a2dd9a5a02 (diff) | |
download | openembedded-core-contrib-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/doc')
-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 @@ after the "inherit" statement. </note> </para> + + <para> + If necessary, it is possible to inherit a class + conditionally by using + a variable expression after the <filename>inherit</filename> + statement. + Here is an example: + <literallayout class='monospaced'> + inherit ${VARNAME} + </literallayout> + If <filename>VARNAME</filename> is going to be set, it needs + to be set before the <filename>inherit</filename> statement + is parsed. + One way to achieve a conditional inherit in this case is to use + overrides: + <literallayout class='monospaced'> + VARIABLE = "" + VARIABLE_someoverride = "myclass" + </literallayout> + </para> + + <para> + Another method is by using anonymous Python. + Here is an example: + <literallayout class='monospaced'> + python () { + if condition == value: + d.setVar('VARIABLE', 'myclass') + else: + d.setVar('VARIABLE', '') + } + </literallayout> + </para> + + <para> + Alternatively, you could use an in-line Python expression + in the following form: + <literallayout class='monospaced'> + inherit ${@'classname' if condition else ''} + inherit ${@functionname(params)} + </literallayout> + In all cases, if the expression evaluates to an empty + string, the statement does not trigger a syntax error + because it becomes a no-op. + </para> </section> <section id='include-directive'> |