summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/utils.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-25 19:02:48 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-07-26 12:05:22 +0100
commitb163a0bca6115ec5983ab5ba9277f3214d64287d (patch)
tree9332424fce98c28fb1133b363a358e7a0a37b884 /bitbake/lib/bb/utils.py
parent819f18f8bc000f13b644edc194d2a12b4ea5fecf (diff)
downloadpoky-b163a0bca6115ec5983ab5ba9277f3214d64287d.tar.gz
bitbake/utils: 'Fix' bb.utils.contains() behaviour
Currently bb.utils.contains(X, "A", true, false) will return true for substring matches, e.g. if X = "ABC". This is not what most users expect from the function. In the common OE use of this function there is the case of "touchscreen" and "screen" being used as independent variables. Whilst it could be argued there isn't a problem in that specific case (touchscreens are usually on screens), there is no substring usage of this function is OE-Core so this patch changes the behaviour to match only full strings. It also fixes a bug where duplicate entries would confuse multiple matches, e.g. contains(X, ["A", "B"], ...) would match X = "A A" which is clearly wrong. (Bitbake rev: 3d8647b68a8e66c7b240ed5fed7406e1b78fabf6) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/utils.py')
-rw-r--r--bitbake/lib/bb/utils.py13
1 files changed, 6 insertions, 7 deletions
diff --git a/bitbake/lib/bb/utils.py b/bitbake/lib/bb/utils.py
index 075ca88ab5..4eac2852ed 100644
--- a/bitbake/lib/bb/utils.py
+++ b/bitbake/lib/bb/utils.py
@@ -861,12 +861,11 @@ def contains(variable, checkvalues, truevalue, falsevalue, d):
861 val = d.getVar(variable, True) 861 val = d.getVar(variable, True)
862 if not val: 862 if not val:
863 return falsevalue 863 return falsevalue
864 matches = 0 864 val = set(val.split())
865 if type(checkvalues).__name__ == "str": 865 if isinstance(checkvalues, basestring):
866 checkvalues = [checkvalues] 866 checkvalues = set(checkvalues.split())
867 for value in checkvalues: 867 else:
868 if val.find(value) != -1: 868 checkvalues = set(checkvalues)
869 matches = matches + 1 869 if checkvalues.issubset(val):
870 if matches == len(checkvalues):
871 return truevalue 870 return truevalue
872 return falsevalue 871 return falsevalue