diff options
author | Antonin Godard <antonin.godard@bootlin.com> | 2024-11-20 10:30:02 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2024-11-28 00:06:24 +0000 |
commit | f53fe9c84aca500f12915a2e1c5d3f189fc8af0c (patch) | |
tree | c4a92fe482c3c2ad92d6a04a794df38a53d9e20c /bitbake | |
parent | 4ffd0e559af909fa7afa43a62f91c3e4f3d5c48e (diff) | |
download | poky-f53fe9c84aca500f12915a2e1c5d3f189fc8af0c.tar.gz |
bitbake: doc: bitbake-user-manual: document inherit_defer
This was added in 2.7.2. Since using inherit_defer is safer that inherit
when inheriting conditionally, move the instructions about that in
inherit_defer.
Fixes [YOCTO #15640].
Reported-by: Yoann Congal <yoann.congal@smile.fr>
(Bitbake rev: eb10df5a9619e243e28e0f4cd6122c24ed668f52)
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake')
-rw-r--r-- | bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | 43 |
1 files changed, 36 insertions, 7 deletions
diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst index 58975f4c88..40a0c6f02d 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | |||
@@ -771,6 +771,8 @@ In order for include and class files to be found by BitBake, they need | |||
771 | to be located in a "classes" subdirectory that can be found in | 771 | to be located in a "classes" subdirectory that can be found in |
772 | :term:`BBPATH`. | 772 | :term:`BBPATH`. |
773 | 773 | ||
774 | .. _ref-bitbake-user-manual-metadata-inherit: | ||
775 | |||
774 | ``inherit`` Directive | 776 | ``inherit`` Directive |
775 | --------------------- | 777 | --------------------- |
776 | 778 | ||
@@ -809,19 +811,43 @@ An advantage with the inherit directive as compared to both the | |||
809 | :ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>` and :ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>` | 811 | :ref:`include <bitbake-user-manual/bitbake-user-manual-metadata:\`\`include\`\` directive>` and :ref:`require <bitbake-user-manual/bitbake-user-manual-metadata:\`\`require\`\` directive>` |
810 | directives is that you can inherit class files conditionally. You can | 812 | directives is that you can inherit class files conditionally. You can |
811 | accomplish this by using a variable expression after the ``inherit`` | 813 | accomplish this by using a variable expression after the ``inherit`` |
812 | statement. Here is an example:: | 814 | statement. |
815 | |||
816 | For inheriting classes conditionally, using the :ref:`inherit_defer | ||
817 | <ref-bitbake-user-manual-metadata-inherit-defer>` directive is advised as | ||
818 | :ref:`inherit_defer <ref-bitbake-user-manual-metadata-inherit-defer>` is | ||
819 | evaluated at the end of parsing. | ||
820 | |||
821 | .. _ref-bitbake-user-manual-metadata-inherit-defer: | ||
822 | |||
823 | ``inherit_defer`` Directive | ||
824 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
825 | |||
826 | The :ref:`inherit_defer <ref-bitbake-user-manual-metadata-inherit-defer>` | ||
827 | directive works like the :ref:`inherit | ||
828 | <ref-bitbake-user-manual-metadata-inherit>` directive, except that it is only | ||
829 | evaluated at the end of parsing. Its usage is recommended when a conditional | ||
830 | expression is used. | ||
813 | 831 | ||
814 | inherit ${VARNAME} | 832 | This allows conditional expressions to be evaluated "late", meaning changes to |
833 | the variable after the line is parsed will take effect. With the :ref:`inherit | ||
834 | <ref-bitbake-user-manual-metadata-inherit>` directive this is not the case. | ||
835 | |||
836 | Here is an example:: | ||
837 | |||
838 | inherit_defer ${VARNAME} | ||
815 | 839 | ||
816 | If ``VARNAME`` is | 840 | If ``VARNAME`` is |
817 | going to be set, it needs to be set before the ``inherit`` statement is | 841 | going to be set, it needs to be set before the ``inherit_defer`` statement is |
818 | parsed. One way to achieve a conditional inherit in this case is to use | 842 | parsed. One way to achieve a conditional inherit in this case is to use |
819 | overrides:: | 843 | overrides:: |
820 | 844 | ||
821 | VARIABLE = "" | 845 | VARIABLE = "" |
822 | VARIABLE:someoverride = "myclass" | 846 | VARIABLE:someoverride = "myclass" |
823 | 847 | ||
824 | Another method is by using anonymous Python. Here is an example:: | 848 | Another method is by using :ref:`anonymous Python |
849 | <bitbake-user-manual/bitbake-user-manual-metadata:Anonymous Python Functions>`. | ||
850 | Here is an example:: | ||
825 | 851 | ||
826 | python () { | 852 | python () { |
827 | if condition == value: | 853 | if condition == value: |
@@ -830,11 +856,14 @@ Another method is by using anonymous Python. Here is an example:: | |||
830 | d.setVar('VARIABLE', '') | 856 | d.setVar('VARIABLE', '') |
831 | } | 857 | } |
832 | 858 | ||
833 | Alternatively, you could use an in-line Python expression in the | 859 | Alternatively, you could use an inline Python expression in the |
834 | following form:: | 860 | following form:: |
835 | 861 | ||
836 | inherit ${@'classname' if condition else ''} | 862 | inherit_defer ${@'classname' if condition else ''} |
837 | inherit ${@functionname(params)} | 863 | |
864 | Or:: | ||
865 | |||
866 | inherit_defer ${@bb.utils.contains('VARIABLE', 'something', 'classname', '', d)} | ||
838 | 867 | ||
839 | In all cases, if the expression evaluates to an | 868 | In all cases, if the expression evaluates to an |
840 | empty string, the statement does not trigger a syntax error because it | 869 | empty string, the statement does not trigger a syntax error because it |