Bug 9283

Summary: Document conditional inherits
Product: [Documentation] BitBake User Manual Reporter: Paul Eggleton <bluelightning>
Component: bitbake-manualAssignee: Scott Rifenbark <srifenbark>
Status: RESOLVED FIXED QA Contact:
Severity: enhancement    
Priority: Medium+ CC: joshuagloe, srifenbark
Version: unspecified   
Target Milestone: 2.1 M4   
Hardware: x86   
OS: Multiple   
Whiteboard: 21 March 2016: RESOLVED
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: Done (doc changes complete)

Description Paul Eggleton 2016-03-17 02:47:25 UTC
Under "3.3.2. inherit Directive" in the BitBake manual we should add some information at the end mentioning that you can do conditional inherits by using a variable expression after the inherit i.e.

inherit ${VARNAME}

If VARNAME is going to be set it needs to be set before the inherit statement is parsed (possibly achieving conditionality using overrides or through an anonymous python function). If the variable evaluates to an empty string the statement will not trigger a syntax error i.e. it becomes a no-op.

Of course an in-line Python expression is also permissible e.g.

inherit ${@'classname' if condition else ''}
inherit ${@functionname(params)}


This brings up a tangential point - we don't currently explain in-line Python; we do mention it in passing but we ought to have a small section on it in the BitBake manual.
Comment 1 Scott Rifenbark 2016-03-22 20:34:06 UTC
Worked with Paul to interactively fix this up.  Here is the link: http://www.yoctoproject.org/docs/2.1/bitbake-user-manual/bitbake-user-manual.html#inherit-directive.  

I am marking it RESOLVED and setting the doc flag to "done".

Scott