From ac704918e4e3a43bab7305464cfc11d6a8975fb6 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 11 Jul 2011 14:38:50 +0100 Subject: [PATCH] bitbake/utils: Add contains helper function from lib.oe.utils This function is needed by some of the early .conf setup we need to improve the machine/tune files in Openembedded. We need to add it here since the location in oe.utils can't be accessed until after base.bbclass parses which is too late for our needs. (Bitbake rev: abc67ed6921c98ed581f101ec1acc589fd9ce7e9) Signed-off-by: Richard Purdie --- bitbake/lib/bb/utils.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py index 82e5dc4277..075ca88ab5 100644 --- a/bitbake/lib/bb/utils.py +++ b/bitbake/lib/bb/utils.py @@ -856,3 +856,17 @@ def to_boolean(string, default=None): return False else: raise ValueError("Invalid value for to_boolean: %s" % string) + +def contains(variable, checkvalues, truevalue, falsevalue, d): + val = d.getVar(variable, True) + if not val: + return falsevalue + matches = 0 + if type(checkvalues).__name__ == "str": + checkvalues = [checkvalues] + for value in checkvalues: + if val.find(value) != -1: + matches = matches + 1 + if matches == len(checkvalues): + return truevalue + return falsevalue