public inbox for docs@lists.yoctoproject.org
 help / color / mirror / Atom feed
* [bitbake-devel PATCH] doc: bitbake-user-manual: document inherit_defer
@ 2024-11-18 15:36 Antonin Godard
  2024-11-18 15:44 ` [bitbake-devel] " Quentin Schulz
  0 siblings, 1 reply; 3+ messages in thread
From: Antonin Godard @ 2024-11-18 15:36 UTC (permalink / raw)
  To: bitbake-devel; +Cc: docs, Thomas Petazzoni, Yoann Congal, Antonin Godard

This was added in 2.7.2. Add it as a subsection of the inherit
directive.

Fixes [YOCTO #15640].

Reported-by: Yoann Congal <yoann.congal@smile.fr>
Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
---
 doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
index 58975f4c88ce549a2fd27136c0cb37b636bafcdb..ab16ddde3cf837092d4c43e467b4becceae23b27 100644
--- a/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
+++ b/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
@@ -840,6 +840,19 @@ 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.
 
+``inherit_defer`` Directive
+~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The ``inherit_defer`` directive works like the ``inherit`` directive, except
+that it is only evaluated at the end of parsing. Its usage is recommended when a
+conditional expression is used. For example::
+
+   inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
+
+This allows conditional expressions to be evaluated "late", meaning changes
+to the variable after the line is parsed will take effect. With the ``inherit``
+directive this is not the case.
+
 ``include`` Directive
 ---------------------
 

---
base-commit: 40ca2b66df610ac74918edf54369781f52b03728
change-id: 20241118-inherit-defer-48d3c8e0c087

Best regards,
-- 
Antonin Godard <antonin.godard@bootlin.com>



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [bitbake-devel] [bitbake-devel PATCH] doc: bitbake-user-manual: document inherit_defer
  2024-11-18 15:36 [bitbake-devel PATCH] doc: bitbake-user-manual: document inherit_defer Antonin Godard
@ 2024-11-18 15:44 ` Quentin Schulz
  2024-11-18 16:04   ` Antonin Godard
  0 siblings, 1 reply; 3+ messages in thread
From: Quentin Schulz @ 2024-11-18 15:44 UTC (permalink / raw)
  To: antonin.godard, bitbake-devel; +Cc: docs, Thomas Petazzoni, Yoann Congal

Hi Antonin,

On 11/18/24 4:36 PM, Antonin Godard via lists.openembedded.org wrote:
> This was added in 2.7.2. Add it as a subsection of the inherit
> directive.
> 
> Fixes [YOCTO #15640].
> 
> Reported-by: Yoann Congal <yoann.congal@smile.fr>
> Signed-off-by: Antonin Godard <antonin.godard@bootlin.com>
> ---
>   doc/bitbake-user-manual/bitbake-user-manual-metadata.rst | 13 +++++++++++++
>   1 file changed, 13 insertions(+)
> 
> diff --git a/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
> index 58975f4c88ce549a2fd27136c0cb37b636bafcdb..ab16ddde3cf837092d4c43e467b4becceae23b27 100644
> --- a/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
> +++ b/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst
> @@ -840,6 +840,19 @@ 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.
>   
> +``inherit_defer`` Directive
> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
> +
> +The ``inherit_defer`` directive works like the ``inherit`` directive, except

add a ref here to the inherit directive section?

> +that it is only evaluated at the end of parsing. Its usage is recommended when a
> +conditional expression is used. For example::
> +
> +   inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
> +
> +This allows conditional expressions to be evaluated "late", meaning changes
> +to the variable after the line is parsed will take effect. With the ``inherit``
> +directive this is not the case.
> +

OK so I don't know if this wouldn't also typically apply to "inherit 
${VARIABLE}" if VARIABLE is set after the inherit?

Ahah, I believe this is actually specified in the inherit directive section!

"""
An advantage with the inherit directive as compared to both the include 
and require directives is that you can inherit class files 
conditionally. You can accomplish this 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.
"""

Also, I believe we very likely want to remove the last few paragraphs of 
the inherit directive section?

i.e. from
"""
One way to achieve a conditional inherit in this case is to use overrides:
"""
to the end of the section.

I guess we could replace it with "if you want to conditionally inherit, 
please use :ref:`inherit_defer`".

or something along those lines.

What do you think?

Cheers,
Quentin


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bitbake-devel] [bitbake-devel PATCH] doc: bitbake-user-manual: document inherit_defer
  2024-11-18 15:44 ` [bitbake-devel] " Quentin Schulz
@ 2024-11-18 16:04   ` Antonin Godard
  0 siblings, 0 replies; 3+ messages in thread
From: Antonin Godard @ 2024-11-18 16:04 UTC (permalink / raw)
  To: Quentin Schulz, bitbake-devel; +Cc: docs, Thomas Petazzoni, Yoann Congal

Hi Quentin,

On Mon Nov 18, 2024 at 4:44 PM CET, Quentin Schulz wrote:
[...]
>> +``inherit_defer`` Directive
>> +~~~~~~~~~~~~~~~~~~~~~~~~~~~
>> +
>> +The ``inherit_defer`` directive works like the ``inherit`` directive, except
>
> add a ref here to the inherit directive section?

Yes, thanks.

>> +that it is only evaluated at the end of parsing. Its usage is recommended when a
>> +conditional expression is used. For example::
>> +
>> +   inherit_defer ${@bb.utils.contains('PACKAGECONFIG', 'python', 'python3targetconfig', '', d)}
>> +
>> +This allows conditional expressions to be evaluated "late", meaning changes
>> +to the variable after the line is parsed will take effect. With the ``inherit``
>> +directive this is not the case.
>> +
>
> OK so I don't know if this wouldn't also typically apply to "inherit 
> ${VARIABLE}" if VARIABLE is set after the inherit?
>
> Ahah, I believe this is actually specified in the inherit directive section!
>
> """
> An advantage with the inherit directive as compared to both the include 
> and require directives is that you can inherit class files 
> conditionally. You can accomplish this 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.
> """
>
> Also, I believe we very likely want to remove the last few paragraphs of 
> the inherit directive section?
>
> i.e. from
> """
> One way to achieve a conditional inherit in this case is to use overrides:
> """
> to the end of the section.
>
> I guess we could replace it with "if you want to conditionally inherit, 
> please use :ref:`inherit_defer`".
>
> or something along those lines.
>
> What do you think?

And so the documentation would advise to always use `inherit_defer` for
conditional inherits. As far as I understand the purpose of inherit_defer, this
is fine to me (and error-safe), so I agree with you on removing the conditional
case from the inherit directive section and redirecting towards inherit_defer.

This makes me wonder why inherit_defer isn't merged into inherit then (i.e.
inherit would behave like inherit_defer by default). But I guess there are other
stakes that go beyond my knowledge on this. :)

Cheers,
Antonin

-- 
Antonin Godard, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-11-18 16:04 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-18 15:36 [bitbake-devel PATCH] doc: bitbake-user-manual: document inherit_defer Antonin Godard
2024-11-18 15:44 ` [bitbake-devel] " Quentin Schulz
2024-11-18 16:04   ` Antonin Godard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox