diff options
author | Scott Rifenbark <scott.m.rifenbark@intel.com> | 2014-04-11 11:47:57 -0700 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2014-04-21 23:03:18 +0100 |
commit | 9889a91a5b84175b91fec05b7a40234f72ac09b2 (patch) | |
tree | 540d3ea4c0f77de809752fe04728c96798dc3627 /bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | |
parent | 392de9d5685e17aed868eb5659032103748825f4 (diff) | |
download | poky-9889a91a5b84175b91fec05b7a40234f72ac09b2.tar.gz |
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: 7259d9d40aad8254751f7674653cd362a9023054)
Signed-off-by: Scott Rifenbark <scott.m.rifenbark@intel.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml')
-rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | 63 |
1 files changed, 37 insertions, 26 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 41ae3b8c0a..365c4b8f97 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.xml | |||
@@ -793,36 +793,35 @@ | |||
793 | </para> | 793 | </para> |
794 | </section> | 794 | </section> |
795 | 795 | ||
796 | <section id='automatically-mapping-functions-within-the-context-of-a-class'> | 796 | <section id='flexible-inheritance-for-class-functions'> |
797 | <title>Automatically Mapping Functions Within the Context of a Class</title> | 797 | <title>Flexible Inheritance for Class Functions</title> |
798 | 798 | ||
799 | <para> | 799 | <para> |
800 | Through coding techniques and the use of | 800 | Through coding techniques and the use of |
801 | <filename>EXPORT_FUNCTIONS</filename>, BitBake supports | 801 | <filename>EXPORT_FUNCTIONS</filename>, BitBake supports |
802 | automatic mapping for functions within the context of | 802 | exporting a function from a class such that the |
803 | a class. | 803 | class function appears as the default implementation |
804 | of the function, but can still be called if a recipe | ||
805 | inheriting the class needs to define its own version of | ||
806 | the function. | ||
804 | </para> | 807 | </para> |
805 | 808 | ||
806 | <para> | 809 | <para> |
807 | To understand the benefits of this feature, consider the basic scenario | 810 | To understand the benefits of this feature, consider |
808 | where a class defines a function and your recipe inherits the class. | 811 | the basic scenario where a class defines a task function |
809 | In this basic scenario, your recipe has access to the function in the | 812 | and your recipe inherits the class. |
810 | class by way of inheritance and can freely call and use the function | 813 | In this basic scenario, your recipe inherits the task |
811 | as defined in the class. | 814 | function as defined in the class. |
812 | However, if you need to have a modified version of that function | 815 | If desired, your recipe can add to the start and end of the |
813 | in your recipe you are limited to using either your modified version | 816 | function by using the "_prepend" or "_append" operations |
814 | of the function or using "prepend_" or "_append" operators to add | 817 | respectively, or it can redefine the function completely. |
815 | code to be executed before or after the original function in the | 818 | However, if it redefines the function, there is |
816 | class. | 819 | no means for it to call the class version of the function. |
817 | Your recipe cannot use both versions of the fucntion. | ||
818 | </para> | 820 | </para> |
819 | 821 | ||
820 | <para> | 822 | <para> |
821 | Function mapping allows you to access both your custom function | 823 | To make use of this technique, you need the following |
822 | function that is defined in the recipe and the original function that | 824 | things in place: |
823 | is defined in the class. | ||
824 | You have this access all from within your recipe. | ||
825 | To accomplish this, you need some things in place: | ||
826 | <itemizedlist> | 825 | <itemizedlist> |
827 | <listitem><para> | 826 | <listitem><para> |
828 | The class needs to define the function as follows: | 827 | The class needs to define the function as follows: |
@@ -853,12 +852,24 @@ | |||
853 | <listitem><para> | 852 | <listitem><para> |
854 | You need to call the function appropriately from within your | 853 | You need to call the function appropriately from within your |
855 | recipe. | 854 | recipe. |
856 | Continuing with the same example, | 855 | Continuing with the same example, if your recipe |
857 | your recipe would call the <filename>do_foo</filename> function | 856 | needs to call the class version of the function, |
858 | from the recipe by referring to it as | 857 | it should call <filename>bar_do_foo</filename>. |
859 | <filename>bar_do_foo</filename>. | 858 | Assuming <filename>do_foo</filename> was a shell function |
860 | To call your modified version of the function as defined in your | 859 | and <filename>EXPORT_FUNCTIONS</filename> was used as above, |
861 | recipe, call it as <filename>do_foo</filename>. | 860 | the recipe's function could conditionally call the |
861 | class version of the function as follows: | ||
862 | <literallayout class='monospaced'> | ||
863 | do_foo() { | ||
864 | if [ somecondition ] ; then | ||
865 | bar_do_foo | ||
866 | else | ||
867 | # Do something else | ||
868 | fi | ||
869 | } | ||
870 | </literallayout> | ||
871 | To call your modified version of the function as defined | ||
872 | in your recipe, call it as <filename>do_foo</filename>. | ||
862 | </para></listitem> | 873 | </para></listitem> |
863 | </itemizedlist> | 874 | </itemizedlist> |
864 | With these conditions met, your single recipe | 875 | With these conditions met, your single recipe |