From: Richard Purdie <richard.purdie@linuxfoundation.org>
To: Otavio Salvador <otavio@ossystems.com.br>
Cc: OpenEmbedded Core Mailing List
<openembedded-core@lists.openembedded.org>
Subject: Re: [PATCH 1/2] oe.utils, utils.bbclass: Add any_contains and base_any_contains
Date: Tue, 01 Apr 2014 20:07:13 +0100 [thread overview]
Message-ID: <1396379233.2910.31.camel@ted> (raw)
In-Reply-To: <CAP9ODKr29A6LKdALn6c_QVBG7v5jHcc020kva+nU9i+tC=+5ew@mail.gmail.com>
On Tue, 2014-04-01 at 15:38 -0300, Otavio Salvador wrote:
> On Tue, Apr 1, 2014 at 2:53 PM, Richard Purdie
> <richard.purdie@linuxfoundation.org> wrote:
> > On Tue, 2014-04-01 at 14:07 -0300, Otavio Salvador wrote:
> >> This is similar to the contains but matches any of values. This is
> >> useful to match for example several DISTRO_FEATURES which ought to
> >> include a PACKAGECONFIG option.
> >>
> >> For example:
> >>
> >> PACKAGECONFIG ??= "${@base_any_contains('DISTRO_FEATURES', 'x11 wayland', 'gtk+', '', d)}"
> >>
> >> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br>
> >> ---
> >> meta/classes/utils.bbclass | 3 +++
> >> meta/lib/oe/utils.py | 13 +++++++++++++
> >> 2 files changed, 16 insertions(+)
> >>
> >> diff --git a/meta/classes/utils.bbclass b/meta/classes/utils.bbclass
> >> index 0a533af..966eda1 100644
> >> --- a/meta/classes/utils.bbclass
> >> +++ b/meta/classes/utils.bbclass
> >> @@ -26,6 +26,9 @@ def base_version_less_or_equal(variable, checkvalue, truevalue, falsevalue, d):
> >> def base_contains(variable, checkvalues, truevalue, falsevalue, d):
> >> return oe.utils.contains(variable, checkvalues, truevalue, falsevalue, d)
> >>
> >> +def base_any_contains(variable, checkvalues, truevalue, falsevalue, d):
> >> + return oe.utils.any_contains(variable, checkvalues, truevalue, falsevalue, d)
> >> +
> >> def base_both_contain(variable1, variable2, checkvalue, d):
> >> return oe.utils.both_contain(variable1, variable2, checkvalue, d)
> >>
> >> diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
> >> index defa536..029d713 100644
> >> --- a/meta/lib/oe/utils.py
> >> +++ b/meta/lib/oe/utils.py
> >> @@ -54,6 +54,19 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
> >> return truevalue
> >> return falsevalue
> >>
> >> +def any_contains(variable, checkvalues, truevalue, falsevalue, d):
> >> + val = d.getVar(variable, True)
> >> + if not val:
> >> + return falsevalue
> >> + val = set(val.split())
> >> + if isinstance(checkvalues, basestring):
> >> + checkvalues = set(checkvalues.split())
> >> + else:
> >> + checkvalues = set(checkvalues)
> >> + if checkvalues in val:
> >> + return truevalue
> >> + return falsevalue
> >> +
> >> def both_contain(variable1, variable2, checkvalue, d):
> >> if d.getVar(variable1,1).find(checkvalue) != -1 and d.getVar(variable2,1).find(checkvalue) != -1:
> >> return checkvalue
> >
> > A more logical name is perhaps containsany().
> >
> > I'd also add that bitbake has special support for contains() and
> > optimises sstate hashes for its use. We don't have such optimisation for
> > containsany(). I think this is perhaps 1.7 material at this point.
>
> I'd use contains_any. Any problem with this?
>
> I didn't find the place bitbake handles it. Can you point the
> reference for me to look at it and complete this?
It starts at lib/bb/codeparser.py:
containsfuncs = ("bb.utils.contains", "base_contains", "oe.utils.contains")
and then that data gets passed around in various caches and so one and
is eventually used in the checksum dependencies.
Cheers,
Richard
prev parent reply other threads:[~2014-04-01 19:07 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-01 17:07 [PATCH 1/2] oe.utils, utils.bbclass: Add any_contains and base_any_contains Otavio Salvador
2014-04-01 17:08 ` [PATCH 2/2] alsa-tools: Enable GTK support for X11 and Wayland Otavio Salvador
2014-04-01 18:50 ` Denys Dmytriyenko
2014-04-01 18:58 ` Otavio Salvador
2014-04-01 17:53 ` [PATCH 1/2] oe.utils, utils.bbclass: Add any_contains and base_any_contains Richard Purdie
2014-04-01 18:38 ` Otavio Salvador
2014-04-01 19:07 ` Richard Purdie [this message]
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=1396379233.2910.31.camel@ted \
--to=richard.purdie@linuxfoundation.org \
--cc=openembedded-core@lists.openembedded.org \
--cc=otavio@ossystems.com.br \
/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.