[OE-core] [PATCH 1/2] oe.utils, utils.bbclass: Add any_contains and base_any_contains
Otavio Salvador
otavio at ossystems.com.br
Tue Apr 1 18:38:29 UTC 2014
On Tue, Apr 1, 2014 at 2:53 PM, Richard Purdie
<richard.purdie at 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 at 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?
--
Otavio Salvador O.S. Systems
http://www.ossystems.com.br http://code.ossystems.com.br
Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
More information about the Openembedded-core
mailing list