1
0
mirror of https://git.yoctoproject.org/poky synced 2026-06-01 13:09:50 +00:00

bitbake: bitbake-user-manual-metadata.xml: Edits to flexible inheritance section.

Fixes [YOCTO #5472]

Applied review edits from Paul Eggleton to this section.
Minor edits and some re-writing.

(Bitbake rev: 91c4913c0ecdf4e61817687095d0ca4086dfee8a)

Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Scott Rifenbark
2014-04-11 11:47:57 -07:00
committed by Richard Purdie
parent 7253253972
commit c23e7052fb
@@ -793,36 +793,35 @@
</para> </para>
</section> </section>
<section id='automatically-mapping-functions-within-the-context-of-a-class'> <section id='flexible-inheritance-for-class-functions'>
<title>Automatically Mapping Functions Within the Context of a Class</title> <title>Flexible Inheritance for Class Functions</title>
<para> <para>
Through coding techniques and the use of Through coding techniques and the use of
<filename>EXPORT_FUNCTIONS</filename>, BitBake supports <filename>EXPORT_FUNCTIONS</filename>, BitBake supports
automatic mapping for functions within the context of exporting a function from a class such that the
a class. class function appears as the default implementation
of the function, but can still be called if a recipe
inheriting the class needs to define its own version of
the function.
</para> </para>
<para> <para>
To understand the benefits of this feature, consider the basic scenario To understand the benefits of this feature, consider
where a class defines a function and your recipe inherits the class. the basic scenario where a class defines a task function
In this basic scenario, your recipe has access to the function in the and your recipe inherits the class.
class by way of inheritance and can freely call and use the function In this basic scenario, your recipe inherits the task
as defined in the class. function as defined in the class.
However, if you need to have a modified version of that function If desired, your recipe can add to the start and end of the
in your recipe you are limited to using either your modified version function by using the "_prepend" or "_append" operations
of the function or using "prepend_" or "_append" operators to add respectively, or it can redefine the function completely.
code to be executed before or after the original function in the However, if it redefines the function, there is
class. no means for it to call the class version of the function.
Your recipe cannot use both versions of the fucntion.
</para> </para>
<para> <para>
Function mapping allows you to access both your custom function To make use of this technique, you need the following
function that is defined in the recipe and the original function that things in place:
is defined in the class.
You have this access all from within your recipe.
To accomplish this, you need some things in place:
<itemizedlist> <itemizedlist>
<listitem><para> <listitem><para>
The class needs to define the function as follows: The class needs to define the function as follows:
@@ -853,12 +852,24 @@
<listitem><para> <listitem><para>
You need to call the function appropriately from within your You need to call the function appropriately from within your
recipe. recipe.
Continuing with the same example, Continuing with the same example, if your recipe
your recipe would call the <filename>do_foo</filename> function needs to call the class version of the function,
from the recipe by referring to it as it should call <filename>bar_do_foo</filename>.
<filename>bar_do_foo</filename>. Assuming <filename>do_foo</filename> was a shell function
To call your modified version of the function as defined in your and <filename>EXPORT_FUNCTIONS</filename> was used as above,
recipe, call it as <filename>do_foo</filename>. the recipe's function could conditionally call the
class version of the function as follows:
<literallayout class='monospaced'>
do_foo() {
if [ somecondition ] ; then
bar_do_foo
else
# Do something else
fi
}
</literallayout>
To call your modified version of the function as defined
in your recipe, call it as <filename>do_foo</filename>.
</para></listitem> </para></listitem>
</itemizedlist> </itemizedlist>
With these conditions met, your single recipe With these conditions met, your single recipe