From: Scott Rifenbark Date: Tue, 22 Mar 2016 20:35:28 +0000 (-0700) Subject: bitbake: bitbake-user-manual: Updated the "inherit Directive" section. X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7ec8f286f70087aec1a82ff4c096cc5904b096ff;p=thirdparty%2Fopenembedded%2Fopenembedded-core-contrib.git 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 Signed-off-by: Richard Purdie --- 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 b3e7dd8d9e6..862a6bddfe6 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. + + + If necessary, it is possible to inherit a class + conditionally by using + a variable expression after the inherit + statement. + Here is an example: + + inherit ${VARNAME} + + If VARNAME is going to be set, it needs + to be set before the inherit statement + is parsed. + One way to achieve a conditional inherit in this case is to use + overrides: + + VARIABLE = "" + VARIABLE_someoverride = "myclass" + + + + + Another method is by using anonymous Python. + Here is an example: + + python () { + if condition == value: + d.setVar('VARIABLE', 'myclass') + else: + d.setVar('VARIABLE', '') + } + + + + + Alternatively, you could use an in-line Python expression + in the following form: + + inherit ${@'classname' if condition else ''} + inherit ${@functionname(params)} + + 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. +