utils: add helper to perform the union of two string lists
PATCH 1/2 utils: add helper to perform the union of two string lists
--- meta/lib/oe/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
meta/lib/oe/utils.py +15 -0
@@ -55,6 +55,21 @@ def both_contain(variable1, variable2, checkvalue, d): else: return "" +def set_union(variable1, variable2, d): + """ + Expand both variables, interpret them as lists of strings, and return the + union as a flattened string. + + For example: + s1 = "a b c" + s2 = "b c d" + s3 = set_union(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
Signature · 1 line
2.1.4
PATCH 2/2 bitbake.conf: programatically generate COMBINED_FEATURES
Instead of hard-coding the set of features that can be considered in COMBINED_FEATURES, simply generate the union of DISTRO_FEATURES and MACHINE_FEATURES.
--- meta/conf/bitbake.conf | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
meta/conf/bitbake.conf +1 -11
@@ -735,17 +735,7 @@ IMAGE_FEATURES += "${EXTRA_IMAGE_FEATURES}" DISTRO_FEATURES_BACKFILL = "pulseaudio sysvinit bluez5" MACHINE_FEATURES_BACKFILL = "rtc" -COMBINED_FEATURES = "\ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "alsa", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "bluetooth", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "ext2", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "vfat", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "irda", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "pcmcia", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "pci", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "usbgadget", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "usbhost", d)} \ - ${@base_both_contain("DISTRO_FEATURES", "MACHINE_FEATURES", "wifi", d)}" +COMBINED_FEATURES = "${@oe.utils.set_union('DISTRO_FEATURES', 'MACHINE_FEATURES', d)}" COMBINED_FEATURES[vardeps] += "DISTRO_FEATURES MACHINE_FEATURES" SERIAL_CONSOLE ??= ""
Signature · 1 line
2.1.4
Quoted 10 lines · Ross Burton
Signed-off-by Ross Burton <[email protected]>--- meta/lib/oe/utils.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+)meta/lib/oe/utils.py +0
-0
meta/lib/oe/utils.py def both_contain(variable1, variable2, checkvalue, d): · line 61
Quoted 7 lines
meta/lib/oe/utils.py +4
-0@@ -55,6 +55,21 @@ def both_contain(variable1, variable2, checkvalue, d): else: return "" +def set_union(variable1, variable2, d): + """ + Expand both variables, interpret them as lists of strings, and return the + union as a flattened string.
This function is returning the intersection of the two sets, not the union. Maybe change the name and the comment here?
Quoted 17 lines
meta/lib/oe/utils.py +11
-0+ + For example: + s1 = "a b c" + s2 = "b c d" + s3 = set_union(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 foundSignature · 1 line
2.1.4
-Matt
Re: [PATCH 2/2] bitbake.conf: programatically generate COMBINED_FEATURES
In reply to Ross BurtonQuoted 5 lines · Ross Burton
Instead of hard-coding the set of features that can be considered in
COMBINED_FEATURES, simply generate the union ofDISTRO_FEATURESandMACHINE_FEATURES.Signed-off-by Ross Burton <[email protected]>
Wouldn't this be a intersect?
Signature · 3 lines
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
Re: [PATCH 2/2] bitbake.conf: programatically generate COMBINED_FEATURES
Quoted 2 lines · Otavio Salvador
Wouldn't this be a intersect?
Erm, yes. :)
Ross
Quoted 3 lines · Matt Madison
This function is returning the intersection of the two sets, not the union. Maybe change the name and the comment here?
Union, intersection, what's the difference really. ;) V2 sent.
Ross