summaryrefslogtreecommitdiff
path: root/meta
diff options
context:
space:
mode:
authorRoss Burton <ross.burton@intel.com>2015-05-22 12:30:26 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-05-23 07:56:21 +0100
commitc5b6f672b88f5f42fe0bd59d28104b8dc9ee9a6e (patch)
tree6c3582a9022b2225830c25216441a0657e6e5cbc /meta
parentf7d186abca6ed9b48ae7393b8f244e1bfb46cb41 (diff)
downloadopenembedded-core-c5b6f672b88f5f42fe0bd59d28104b8dc9ee9a6e.tar.gz
openembedded-core-c5b6f672b88f5f42fe0bd59d28104b8dc9ee9a6e.tar.bz2
openembedded-core-c5b6f672b88f5f42fe0bd59d28104b8dc9ee9a6e.zip
utils: add helper to perform the intersection of two string lists
Useful for e.g. generating a COMBINED_FEATURES list from DISTRO_FEATURES and MACHINE_FEATURES. Signed-off-by: Ross Burton <ross.burton@intel.com>
Diffstat (limited to 'meta')
-rw-r--r--meta/lib/oe/utils.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/meta/lib/oe/utils.py b/meta/lib/oe/utils.py
index b8224de20b..7173e106f5 100644
--- a/meta/lib/oe/utils.py
+++ b/meta/lib/oe/utils.py
@@ -55,6 +55,21 @@ def both_contain(variable1, variable2, checkvalue, d):
else:
return ""
+def set_intersect(variable1, variable2, d):
+ """
+ Expand both variables, interpret them as lists of strings, and return the
+ intersection as a flattened string.
+
+ For example:
+ s1 = "a b c"
+ s2 = "b c d"
+ s3 = set_intersect(s1, s2)
+ => s3 = "b c"
+ """
+ val1 = set(d.getVar(variable1, True).split())
+ val2 = set(d.getVar(variable2, True).split())
+ return " ".join(val1 & val2)
+
def prune_suffix(var, suffixes, d):
# See if var ends with any of the suffixes listed and
# remove it if found