diff options
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/utils.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 2845126293..d6bcfa37e8 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py | |||
@@ -979,6 +979,30 @@ def contains_any(variable, checkvalues, truevalue, falsevalue, d): | |||
979 | return truevalue | 979 | return truevalue |
980 | return falsevalue | 980 | return falsevalue |
981 | 981 | ||
982 | def filter(variable, checkvalues, d): | ||
983 | """Return all words in the variable that are present in the checkvalues. | ||
984 | |||
985 | Arguments: | ||
986 | |||
987 | variable -- the variable name. This will be fetched and expanded (using | ||
988 | d.getVar(variable)) and then split into a set(). | ||
989 | |||
990 | checkvalues -- if this is a string it is split on whitespace into a set(), | ||
991 | otherwise coerced directly into a set(). | ||
992 | |||
993 | d -- the data store. | ||
994 | """ | ||
995 | |||
996 | val = d.getVar(variable) | ||
997 | if not val: | ||
998 | return '' | ||
999 | val = set(val.split()) | ||
1000 | if isinstance(checkvalues, str): | ||
1001 | checkvalues = set(checkvalues.split()) | ||
1002 | else: | ||
1003 | checkvalues = set(checkvalues) | ||
1004 | return ' '.join(sorted(checkvalues & val)) | ||
1005 | |||
982 | def cpu_count(): | 1006 | def cpu_count(): |
983 | return multiprocessing.cpu_count() | 1007 | return multiprocessing.cpu_count() |
984 | 1008 | ||