All of lore.kernel.org
 help / color / mirror / Atom feed
From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: louis.rannou@syslinbit.com, bitbake-devel@lists.openembedded.org
Cc: louis.rannou@non.se.com, pascal.eberhard@se.com, yoann.congal@smile.fr
Subject: Re: [bitbake-devel] [PATCH 1/2] bitbake: data_smart: fix ??= operator for getVarFlags
Date: Wed, 12 Feb 2025 14:13:05 +0000	[thread overview]
Message-ID: <1f5455e336cd35e8ffadcad1abd1b0daf782764e.camel@linuxfoundation.org> (raw)
In-Reply-To: <20250212-varflags-v1-1-3a756c7aa95c@syslinbit.com>

On Wed, 2025-02-12 at 13:16 +0100, Louis Rannou via lists.openembedded.org wrote:
> From: Louis Rannou <louis.rannou@non.se.com>
> 
> Variable flags have been fixed in commit
> 0329a7e3ac694737f2d2c1861f65492551360663 which introduces the
> "_defaultval_flag_" prefix for default values. This must not be ignored as
> others "_"-prefixed flags names.
> 
> Split the processing of default values to be sure they are overwritted by the
> others operators disregarding of their order.
> 
> Fixes [YOCTO #15685]
> 
> Signed-off-by: Louis Rannou <louis.rannou@non.se.com>
> ---
>  lib/bb/data_smart.py | 16 +++++++++++++---
>  1 file changed, 13 insertions(+), 3 deletions(-)
> 
> diff --git a/lib/bb/data_smart.py b/lib/bb/data_smart.py
> index 897ceeb32c7ce0acb8ed44c25e1bf2f2f28aa9dc..7663f28c5071a77c8452c1016e5ee0d969c84bec 100644
> --- a/lib/bb/data_smart.py
> +++ b/lib/bb/data_smart.py
> @@ -952,12 +952,22 @@ class DataSmart(MutableMapping):
>      def getVarFlags(self, var, expand = False, internalflags=False):
>          local_var = self._findVar(var)
>          flags = {}
> +        flags_set = {}
>  
>          if local_var:
> -            for i in local_var:
> -                if i.startswith(("_", ":")) and not internalflags:
> +            for i, val in local_var.items():
> +                if i.startswith("_defaultval_flag_"):
> +                    i = i[len("_defaultval_flag_"):]
> +                    flags[i] = val
> +                elif i.startswith(("_", ":")) and not internalflags:
>                      continue
> -                flags[i] = local_var[i]
> +                else:
> +                    flags_set[i] = val
> +
> +            # Flags sets take over defaults
> +            flags.update(flags_set)
> +
> +            for i in flags:
>                  if expand and i in expand:
>                      flags[i] = self.expand(flags[i], var + "[" + i + "]")
>          if len(flags) == 0:

I did spend more time looking at this and I had misunderstood the
problem. I think this can still be simplified though and I also suspect
the internalflags handling above isn't correct. If internalflags is
set, I think it probably should return _defaultval_flag_ values
unchanged. The code would therefore look more like:


for i, val in local_var.items():
    if i.startswith("_defaultval_flag_") and not internalflags:
        i = i[len("_defaultval_flag_"):]
        if i not in local_var:
            flags[i] = val
    elif i.startswith(("_", ":")) and not internalflags:
        continue
    else:
        flags_set[i] = val

I'd also add a comment to the test case explaining that we're testing
weak default make it to the getVarFlags output.

Cheers,

Richard

  parent reply	other threads:[~2025-02-12 14:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-12 12:16 [PATCH 0/2] bitbake: fix ??= operator for getVarFlags and test Louis Rannou
2025-02-12 12:16 ` [PATCH 1/2] bitbake: data_smart: fix ??= operator for getVarFlags Louis Rannou
2025-02-12 14:00   ` [bitbake-devel] " Richard Purdie
2025-02-12 14:13   ` Richard Purdie [this message]
2025-02-12 17:01     ` Louis Rannou
2025-02-12 12:16 ` [PATCH 2/2] bitbake: tests/parse: add test " Louis Rannou

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1f5455e336cd35e8ffadcad1abd1b0daf782764e.camel@linuxfoundation.org \
    --to=richard.purdie@linuxfoundation.org \
    --cc=bitbake-devel@lists.openembedded.org \
    --cc=louis.rannou@non.se.com \
    --cc=louis.rannou@syslinbit.com \
    --cc=pascal.eberhard@se.com \
    --cc=yoann.congal@smile.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.