meta: simplify conditional operations with bb.utils.filter
PATCH 1/1 meta: simplify conditional operations with bb.utils.filter
Some recipes and configuration files use bb.utils.contains to check for a string inside a variable, and return the exact same string if true.
This can be simplified by a call to bb.utils.filter, since the result is the same, and the inline is shorter.
Replace "bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".
--- meta/classes-global/insane.bbclass | 2 +- meta/conf/machine/include/arm/feature-arm-neon.inc | 8 ++++---- meta/conf/machine/include/arm/feature-arm-vfp.inc | 2 +- meta/recipes-connectivity/connman/connman_2.0.bb | 2 +- meta/recipes-core/coreutils/coreutils_9.10.bb | 2 +- meta/recipes-core/ovmf/ovmf_git.bb | 2 +- meta/recipes-extended/at/at_3.2.5.bb | 2 +- meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb | 2 +- meta/recipes-graphics/waffle/waffle_1.8.1.bb | 2 +- .../gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-)
meta/classes-global/insane.bbclass +1 -1
@@ -46,7 +46,7 @@ ERROR_QA ?= "\ ${CHECKLAYER_REQUIRED_TESTS}" # Add usrmerge QA check based on distro feature -ERROR_QA:append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" +ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}" WARN_QA:append:layer-core = " missing-metadata missing-maintainer" FAKEROOT_QA = "host-user-contaminated"
meta/conf/machine/include/arm/feature-arm-neon.inc +4 -4
@@ -5,16 +5,16 @@ # 'vfp', -mfloat-abi parameter and 'hf' suffix is implemented in feature-arm-vfp.inc TUNEVALID[neon] = "Enable Neon SIMD accelerator unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'neon', ' neon', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'neon', d)}" TUNEVALID[vfpv3d16] = "Enable Vector Floating Point Version 3 with 16 registers (vfpv3-d16) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" TUNEVALID[vfpv3] = "Enable Vector Floating Point Version 3 with 32 registers (vfpv3) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3', ' vfpv3', '' , d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv3', d)}" TUNEVALID[vfpv4] = "Enable Vector Floating Point Version 4 (vfpv4) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv4', ' vfpv4', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv4', d)}" TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', [ 'vfpv4', 'neon' ], ' neon-vfpv4', '', d)}" TUNEVALID[vfpv4d16] = "Enable Vector Floating Point Version 4 with 16 registers (vfpv4-d16) unit."
meta/conf/machine/include/arm/feature-arm-vfp.inc +1 -1
@@ -3,7 +3,7 @@ # and this .inc file is included from armv5 TUNEVALID[vfp] = "Enable Vector Floating Point (vfp) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfp', ' vfp', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfp', d)}" # simd is special, we don't pass this to the -mfpu, it's implied TUNE_CCARGS .= "${@ (' -mfpu=%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU') != '') else ''}"
meta/recipes-connectivity/connman/connman_2.0.bb +1 -1
@@ -169,7 +169,7 @@ FILES:${PN}-tools = "${bindir}/wispr" RDEPENDS:${PN}-tools = "${PN}" FILES:${PN}-tests = "${bindir}/*-test" -RDEPENDS:${PN}-tests = "${@bb.utils.contains('PACKAGECONFIG', 'iptables', 'iptables', '', d)}" +RDEPENDS:${PN}-tests = "${@bb.utils.filter('PACKAGECONFIG', 'iptables', d)}" FILES:${PN}-client = "${bindir}/connmanctl" RDEPENDS:${PN}-client = "${PN}"
meta/recipes-core/coreutils/coreutils_9.10.bb +1 -1
@@ -222,6 +222,6 @@ do_install_ptest:append:libc-musl () { } RDEPENDS:${PN}-ptest += "xz \ - ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'acl', '', d)} \ + ${@bb.utils.filter('PACKAGECONFIG', 'acl', d)} \ ${@bb.utils.contains('PACKAGECONFIG', 'xattr', 'attr', '', d)}" FILES:${PN}-ptest += "${bindir}/getlimits"
meta/recipes-core/ovmf/ovmf_git.bb +1 -1
@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://OvmfPkg/License.txt;md5=06357ddc23f46577c2aeaeaf7b776 # compiling OVMF twice, so it is disabled by default. Distros # may change that default. PACKAGECONFIG ??= "" -PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm', 'tpm', '', d)}" +PACKAGECONFIG += "${@bb.utils.filter('MACHINE_FEATURES', 'tpm', d)}" PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)}" PACKAGECONFIG[debug] = ",,," PACKAGECONFIG[secureboot] = ",,,"
meta/recipes-extended/at/at_3.2.5.bb +1 -1
@@ -9,7 +9,7 @@ DEPENDS = "flex flex-native bison-native \ ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" PACKAGECONFIG ?= "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \ " PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux,"
meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb +1 -1
@@ -14,7 +14,7 @@ REQUIRED_DISTRO_FEATURES = "opengl glvnd" inherit meson pkgconfig features_check PACKAGECONFIG ?= "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'egl gles1 gles2', '', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl x11', 'glx', '', d)} \ "
meta/recipes-graphics/waffle/waffle_1.8.1.bb +1 -1
@@ -21,7 +21,7 @@ DEPENDS:append = " python3" # This should be overridden per-machine to reflect the capabilities of the GL # stack. PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'glx x11-egl', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'wayland', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gbm surfaceless-egl', '', d)} \ "
meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb +1 -1
@@ -25,7 +25,7 @@ PACKAGECONFIG ??= " \ ${GSTREAMER_ORC} \ ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \ ${@bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan x11', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'wayland', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)} \ bz2 closedcaption curl dash dtls hls openssl sbc smoothstreaming \ sndfile ttml uvch264 webp analytics \
Signature · 1 line
2.47.0
Hi João,
Quoted 65 lines · Joao Marcos Costa via lists.openembedded.org
Some recipes and configuration files use bb.utils.contains to check for a string inside a variable, and return the exact same string if true.
This can be simplified by a call to bb.utils.filter, since the result is the same, and the inline is shorter.
Replace "
bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".Signed-off-by João Marcos Costa <[email protected]>--- meta/classes-global/insane.bbclass | 2 +- meta/conf/machine/include/arm/feature-arm-neon.inc | 8 ++++---- meta/conf/machine/include/arm/feature-arm-vfp.inc | 2 +- meta/recipes-connectivity/connman/connman_2.0.bb | 2 +- meta/recipes-core/coreutils/coreutils_9.10.bb | 2 +- meta/recipes-core/ovmf/ovmf_git.bb | 2 +- meta/recipes-extended/at/at_3.2.5.bb | 2 +- meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb | 2 +- meta/recipes-graphics/waffle/waffle_1.8.1.bb | 2 +- .../gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-)meta/classes-global/insane.bbclass +1
-1@@ -46,7 +46,7 @@ ERROR_QA ?= "\ ${CHECKLAYER_REQUIRED_TESTS}" # Add usrmerge QA check based on distro feature -ERROR_QA:append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" +ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}" WARN_QA:append:layer-core = " missing-metadata missing-maintainer" FAKEROOT_QA = "host-user-contaminated"meta/conf/machine/include/arm/feature-arm-neon.inc +4
-4@@ -5,16 +5,16 @@ # 'vfp', -mfloat-abi parameter and 'hf' suffix is implemented in feature-arm-vfp.inc TUNEVALID[neon] = "Enable Neon SIMD accelerator unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'neon', ' neon', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'neon', d)}" TUNEVALID[vfpv3d16] = "Enable Vector Floating Point Version 3 with 16 registers (vfpv3-d16) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" TUNEVALID[vfpv3] = "Enable Vector Floating Point Version 3 with 32 registers (vfpv3) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3', ' vfpv3', '' , d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv3', d)}" TUNEVALID[vfpv4] = "Enable Vector Floating Point Version 4 (vfpv4) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv4', ' vfpv4', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv4', d)}" TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', [ 'vfpv4', 'neon' ], ' neon-vfpv4', '', d)}" TUNEVALID[vfpv4d16] = "Enable Vector Floating Point Version 4 with 16 registers (vfpv4-d16) unit."meta/conf/machine/include/arm/feature-arm-vfp.inc +0
-0
meta/conf/machine/include/arm/feature-arm-vfp.inc line 9
Quoted 8 lines
meta/conf/machine/include/arm/feature-arm-vfp.inc +1
-1@@ -3,7 +3,7 @@ # and this .inc file is included from armv5 TUNEVALID[vfp] = "Enable Vector Floating Point (vfp) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfp', ' vfp', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfp', d)}" # simd is special, we don't pass this to the -mfpu, it's implied TUNE_CCARGS .= "${@ (' -mfpu=%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU') != '') else ''}"
I'm pretty sure your changes in the conf files won't work, but maybe I'm wrong?
Before, we only added a space if there was a new tune to add. Now, it's always added.
Considering TUNE_CCARGS_MFPU can now possibly contain only spaces, the check if TUNE_CCARGS_MFPU is not the empty string to access the last element in the list returned by split(), which will now be the empty list, will raise an IndexError exception.
You need to adapt anything that's using this variable to check if it only contains spaces or at least remove spurious ones, possibly with str.strip() for example. Unfortunately, if TUNE_CCARGS_MFPU doesn't exist, d.getVar() will return None and you cannot strip() on None. Of course, considering TUNE_CCARGS_MFPU is declared just above in the file, it'll always be defined, so maybe that's fine to not check for None.
If the space didn't matter, we probably would have used += instead of .=, so I'm wary of this change (the rest looks fine).
Cheers,
Quentin
Hello, Quentin
Quoted 13 lines · Quentin Schulz via lists.openembedded.org
Hi João,
Quoted 10 lines · Joao Marcos Costa via lists.openembedded.org
Some recipes and configuration files use bb.utils.contains to check for a string inside a variable, and return the exact same string if true.
This can be simplified by a call to bb.utils.filter, since the result is the same, and the inline is shorter.
Replace "
bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".Signed-off-by João Marcos Costa <[email protected]>---
(...)
Quoted 4 lines
I'm pretty sure your changes in the conf files won't work, but maybe I'm wrong?
Before, we only added a space if there was a new tune to add. Now, it's always added.
Quoted 8 lines
Considering
TUNE_CCARGS_MFPUcan now possibly contain only spaces, the check ifTUNE_CCARGS_MFPUis not the empty string to access the last element in the list returned bysplit(), which will now be the empty list, will raise an IndexError exception.You need to adapt anything that's using this variable to check if it only contains spaces or at least remove spurious ones, possibly with
str.strip()for example. Unfortunately, ifTUNE_CCARGS_MFPUdoesn't exist,d.getVar()will return None and you cannotstrip()on None. Of course, consideringTUNE_CCARGS_MFPUis declared just above in the file, it'll always be defined, so maybe that's fine to not check for None.If the space didn't matter, we probably would have used += instead of .=, so I'm wary of this change (the rest looks fine).
Cheers,
Quentin
Thanks for your review. And yes, I'm looking at this part of the patch again, and I'm considering two things:
a) Add the strip() as you said, here, and keep my changes:
-TUNE_CCARGS .= "${@ (' -mfpu=%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU') != '') else ''}" +TUNE_CCARGS .= "${@ (' -mfpu=%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU').strip() != '') else ''}"
# The following deals with both vfpv3-d16 and vfpv4-d16
-ARMPKGSFX_FPU = "${@ ('-%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1].replace('-d16', 'd16')) if (d.getVar('TUNE_CCARGS_MFPU') != '') else ''}"
+ARMPKGSFX_FPU = "${@ ('-%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1].replace('-d16', 'd16')) if (d.getVar('TUNE_CCARGS_MFPU').strip() != '') else ''}"
b) Simply remove those changes, then send another patch keeping only the changes in recipes.
What do you think?
Signature · 2 lines
Best regards, João Marcos Costa
Hi João,
Quoted 36 lines · Joao Marcos Costa
Hello, Quentin
Quoted 13 lines · Quentin Schulz via lists.openembedded.org
Hi João,
Quoted 10 lines · Joao Marcos Costa via lists.openembedded.org
Some recipes and configuration files use bb.utils.contains to check for a string inside a variable, and return the exact same string if true.
This can be simplified by a call to bb.utils.filter, since the result is the same, and the inline is shorter.
Replace "
bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".Signed-off-by João Marcos Costa <[email protected]>---
(...)
Quoted 4 lines
I'm pretty sure your changes in the conf files won't work, but maybe I'm wrong?
Before, we only added a space if there was a new tune to add. Now, it's always added.
Quoted 8 lines
Considering
TUNE_CCARGS_MFPUcan now possibly contain only spaces, the check ifTUNE_CCARGS_MFPUis not the empty string to access the last element in the list returned bysplit(), which will now be the empty list, will raise an IndexError exception.You need to adapt anything that's using this variable to check if it only contains spaces or at least remove spurious ones, possibly with
str.strip()for example. Unfortunately, ifTUNE_CCARGS_MFPUdoesn't exist,d.getVar()will return None and you cannotstrip()on None. Of course, consideringTUNE_CCARGS_MFPUis declared just above in the file, it'll always be defined, so maybe that's fine to not check for None.If the space didn't matter, we probably would have used += instead of .=, so I'm wary of this change (the rest looks fine).
Cheers,
QuentinThanks for your review. And yes, I'm looking at this part of the patch again, and I'm considering two things:
a) Add the
strip()as you said, here, and keep my changes:
Quoted 10 lines
-TUNE_CCARGS .= "${@ (' -mfpu=%s' %
d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU')!= '') else ''}" +TUNE_CCARGS .= "${@ (' -mfpu=%s' %
d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU').strip() != '') else ''}"
# The following deals with both vfpv3-d16 and vfpv4-d16
-ARMPKGSFX_FPU = "${@ ('-%s' %
d.getVar('TUNE_CCARGS_MFPU').split()[-1].replace('-d16', 'd16')) if (d.getVar('TUNE_CCARGS_MFPU')!= '') else ''}" +ARMPKGSFX_FPU = "${@ ('-%s' %
d.getVar('TUNE_CCARGS_MFPU').split()[-1].replace('-d16', 'd16')) if (d.getVar('TUNE_CCARGS_MFPU').strip() != '') else ''}"
Yet another option is to do
(d.getVar('TUNE_CCARGS_MFPU') or '').strip() != ''
but it's a bit eww :)
Quoted 2 lines
b) Simply remove those changes, then send another patch keeping only the changes in recipes.
Yeah that works too. It's the same change but the implications are different. So maybe three patches (one for machihes, one for QA, one for recipes (maybe even in two, one for PACKAGECONFIG, one for RDEPENDS since Chen Qi doesn't seem to like the latter too much :) ) so everybody can bikeshed as much as they want on one and still have the rest merged :)
Cheers,
Quentin
Hello again,
(...)
Quoted 6 lines
Yet another option is to do
(
d.getVar('TUNE_CCARGS_MFPU')or '').strip() != ''but it's a bit eww :)
I'm pretty sure that's how ERROR_QA is handled, actually:
meta/lib/oe/qa.py: if error_class in (d.getVar("ERROR_QA") or "").split():
Unless this is different in a way I simply cannot see :)
Quoted 8 lines
Quoted 3 lines
b) Simply remove those changes, then send another patch keeping only the changes in recipes.
Yeah that works too. It's the same change but the implications are different. So maybe three patches (one for machihes, one for QA, one for recipes (maybe even in two, one for PACKAGECONFIG, one for RDEPENDS since Chen Qi doesn't seem to like the latter too much :) ) so everybody can bikeshed as much as they want on one and still have the rest merged :)
Cheers,
Quentin
I'll do that. Maybe that's what I should have done in the first place, but I didn't want to spam N different patches that essentially do the same replacement.
Thanks!
Signature · 2 lines
Best regards, João Marcos Costa
When using filter for two different things, isn't it a little strange?
Take the first change you made as an example:
-ERROR_QA:append ="${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" +ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"
Previously, the line is very clear. It reads like: if DISTRO_FEATURES contains 'usrmerge', append ' usrmerge' to ERROR_QA. After the change, it reads like: filter usrmerge from DISTRO_FEATRUES to ERROR_QA.
By doing this, you're connecting these two variables (DISTRO_FEATURES & ERROR_QA) conceptually.
And the leading space is also a tiny problem.
Regards,
Qi
Quoted 172 lines · Joao Marcos Costa via lists.openembedded.org
Some recipes and configuration files use bb.utils.contains to check for a string inside a variable, and return the exact same string if true.
This can be simplified by a call to bb.utils.filter, since the result is the same, and the inline is shorter.
Replace "
bb.utils.contains(A, 'a', 'a', '', d)" by "bb.utils.filter(A, 'a', d)".Signed-off-by João Marcos Costa <[email protected]>--- meta/classes-global/insane.bbclass | 2 +- meta/conf/machine/include/arm/feature-arm-neon.inc | 8 ++++---- meta/conf/machine/include/arm/feature-arm-vfp.inc | 2 +- meta/recipes-connectivity/connman/connman_2.0.bb | 2 +- meta/recipes-core/coreutils/coreutils_9.10.bb | 2 +- meta/recipes-core/ovmf/ovmf_git.bb | 2 +- meta/recipes-extended/at/at_3.2.5.bb | 2 +- meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb | 2 +- meta/recipes-graphics/waffle/waffle_1.8.1.bb | 2 +- .../gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-)meta/classes-global/insane.bbclass +1
-1@@ -46,7 +46,7 @@ ERROR_QA ?= "\ ${CHECKLAYER_REQUIRED_TESTS}" # Add usrmerge QA check based on distro feature -ERROR_QA:append = "${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" +ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}" WARN_QA:append:layer-core = " missing-metadata missing-maintainer" FAKEROOT_QA = "host-user-contaminated"meta/conf/machine/include/arm/feature-arm-neon.inc +4
-4@@ -5,16 +5,16 @@ # 'vfp', -mfloat-abi parameter and 'hf' suffix is implemented in feature-arm-vfp.inc TUNEVALID[neon] = "Enable Neon SIMD accelerator unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'neon', ' neon', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'neon', d)}" TUNEVALID[vfpv3d16] = "Enable Vector Floating Point Version 3 with 16 registers (vfpv3-d16) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.contains('TUNE_FEATURES', 'vfpv3d16', ' vfpv3-d16', '', d)}" TUNEVALID[vfpv3] = "Enable Vector Floating Point Version 3 with 32 registers (vfpv3) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv3', ' vfpv3', '' , d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv3', d)}" TUNEVALID[vfpv4] = "Enable Vector Floating Point Version 4 (vfpv4) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfpv4', ' vfpv4', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfpv4', d)}" TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', [ 'vfpv4', 'neon' ], ' neon-vfpv4', '', d)}" TUNEVALID[vfpv4d16] = "Enable Vector Floating Point Version 4 with 16 registers (vfpv4-d16) unit."meta/conf/machine/include/arm/feature-arm-vfp.inc +1
-1@@ -3,7 +3,7 @@ # and this .inc file is included from armv5 TUNEVALID[vfp] = "Enable Vector Floating Point (vfp) unit." -TUNE_CCARGS_MFPU .= "${@bb.utils.contains('TUNE_FEATURES', 'vfp', ' vfp', '', d)}" +TUNE_CCARGS_MFPU .= " ${@bb.utils.filter('TUNE_FEATURES', 'vfp', d)}" # simd is special, we don't pass this to the -mfpu, it's implied TUNE_CCARGS .= "${@ (' -mfpu=%s' % d.getVar('TUNE_CCARGS_MFPU').split()[-1]) if (d.getVar('TUNE_CCARGS_MFPU') != '') else ''}"meta/recipes-connectivity/connman/connman_2.0.bb +1
-1@@ -169,7 +169,7 @@ FILES:${PN}-tools = "${bindir}/wispr" RDEPENDS:${PN}-tools = "${PN}" FILES:${PN}-tests = "${bindir}/*-test" -RDEPENDS:${PN}-tests = "${@bb.utils.contains('PACKAGECONFIG', 'iptables', 'iptables', '', d)}" +RDEPENDS:${PN}-tests = "${@bb.utils.filter('PACKAGECONFIG', 'iptables', d)}" FILES:${PN}-client = "${bindir}/connmanctl" RDEPENDS:${PN}-client = "${PN}"meta/recipes-core/coreutils/coreutils_9.10.bb +1
-1@@ -222,6 +222,6 @@ do_install_ptest:append:libc-musl () { } RDEPENDS:${PN}-ptest += "xz \ - ${@bb.utils.contains('PACKAGECONFIG', 'acl', 'acl', '', d)} \ + ${@bb.utils.filter('PACKAGECONFIG', 'acl', d)} \ ${@bb.utils.contains('PACKAGECONFIG', 'xattr', 'attr', '', d)}" FILES:${PN}-ptest += "${bindir}/getlimits"meta/recipes-core/ovmf/ovmf_git.bb +1
-1@@ -10,7 +10,7 @@ LIC_FILES_CHKSUM = "file://OvmfPkg/License.txt;md5=06357ddc23f46577c2aeaeaf7b776 # compiling OVMF twice, so it is disabled by default. Distros # may change that default. PACKAGECONFIG ??= "" -PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm', 'tpm', '', d)}" +PACKAGECONFIG += "${@bb.utils.filter('MACHINE_FEATURES', 'tpm', d)}" PACKAGECONFIG += "${@bb.utils.contains('MACHINE_FEATURES', 'tpm2', 'tpm', '', d)}" PACKAGECONFIG[debug] = ",,," PACKAGECONFIG[secureboot] = ",,,"meta/recipes-extended/at/at_3.2.5.bb +1
-1@@ -9,7 +9,7 @@ DEPENDS = "flex flex-native bison-native \ ${@bb.utils.contains('DISTRO_FEATURES', 'pam', 'libpam', '', d)}" PACKAGECONFIG ?= "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \ " PACKAGECONFIG[selinux] = "--with-selinux,--without-selinux,libselinux,"meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb +1
-1@@ -14,7 +14,7 @@ REQUIRED_DISTRO_FEATURES = "opengl glvnd" inherit meson pkgconfig features_check PACKAGECONFIG ?= "\ - ${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'x11', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'x11', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'egl gles1 gles2', '', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl x11', 'glx', '', d)} \ "meta/recipes-graphics/waffle/waffle_1.8.1.bb +1
-1@@ -21,7 +21,7 @@ DEPENDS:append = " python3" # This should be overridden per-machine to reflect the capabilities of the GL # stack. PACKAGECONFIG ??= "${@bb.utils.contains('DISTRO_FEATURES', 'x11', 'glx x11-egl', '', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'wayland', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gbm surfaceless-egl', '', d)} \ "meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb +1
-2@@ -25,7 +25,7 @@ PACKAGECONFIG ??= " \ ${GSTREAMER_ORC} \ ${@bb.utils.contains('DISTRO_FEATURES', 'bluetooth', 'bluez', '', d)} \ ${@bb.utils.filter('DISTRO_FEATURES', 'directfb vulkan x11', d)} \ - ${@bb.utils.contains('DISTRO_FEATURES', 'wayland', 'wayland', '', d)} \ + ${@bb.utils.filter('DISTRO_FEATURES', 'wayland', d)} \ ${@bb.utils.contains('DISTRO_FEATURES', 'opengl', 'gl', '', d)} \ bz2 closedcaption curl dash dtls hls openssl sbc smoothstreaming \ sndfile ttml uvch264 webp analytics \ -=-=-=-=-=-=-=-=-=-=-=-Links: You receive all messages sent to this group.
View/Reply Online (#235868): https://lists.openembedded.org/g/openembedded-core/message/235868
Mute This Topic: https://lists.openembedded.org/mt/118989280/7304865
Group Owner: [email protected]
Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [[email protected]]
-=-=-=-=-=-=-=-=-=-=-=-
Hello, Chen
Quoted 9 lines · Chen Qi via lists.openembedded.org
When using filter for two different things, isn't it a little strange?
Take the first change you made as an example:
-ERROR_QA:append ="${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}"
+ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"Previously, the line is very clear. It reads like: if
DISTRO_FEATUREScontains 'usrmerge', append ' usrmerge' toERROR_QA.
So far, this applies to bb.utils.filter() as a whole. Unless your point is about the space in ' usrmerge'.
Quoted 2 lines
After the change, it reads like: filter usrmerge from
DISTRO_FEATRUEStoERROR_QA. By doing this, you're connecting these two variables (DISTRO_FEATURES&ERROR_QA) conceptually.
I'm not sure I interpret/read this line the same way you do. Once again, unless I misunderstood your point, the way you read bb.utils.filter() applies to every use of such helper.
How different is this ERROR_QA case from the other occurences of bb.utils.filter() in my patch (i.e., in the *.bb), or even in oe-core?
Quoted 1 line
And the leading space is also a tiny problem.
After Quentin's comment, I double-checked and ERROR_QA is not handled in the same way as TUNE_CCARGS_MFPU, so the extra leading space should be fine. I agree, however, that it's not very nice to add it unconditionally.
One more thing: could you please clarify what you mean by "two different things"? I'm not sure to follow, even with the example. The use case is still one and only: check if the string is in the variable, and if so, return it.
Quoted 2 lines
Regards,
Qi
Thanks!
Signature · 2 lines
Best regards, João Marcos Costa
Quoted 21 lines · Joao Marcos Costa
Hello, Chen
Quoted 10 lines · Chen Qi via lists.openembedded.org
When using filter for two different things, isn't it a little strange?
Take the first change you made as an example:
-ERROR_QA:append ="${@bb.utils.contains('DISTRO_FEATURES', 'usrmerge', ' usrmerge', '', d)}" +ERROR_QA:append = " ${@bb.utils.filter('DISTRO_FEATURES', 'usrmerge', d)}"
Previously, the line is very clear. It reads like: if
DISTRO_FEATUREScontains 'usrmerge', append ' usrmerge' toERROR_QA.So far, this applies to
bb.utils.filter()as a whole. Unless your point is about the space in ' usrmerge'.Quoted 2 lines
After the change, it reads like: filter usrmerge from
DISTRO_FEATRUEStoERROR_QA. By doing this, you're connecting these two variables (DISTRO_FEATURES&ERROR_QA) conceptually.I'm not sure I interpret/read this line the same way you do. Once again, unless I misunderstood your point, the way you read
bb.utils.filter()applies to every use of such helper.
Quoted 7 lines
How different is this
ERROR_QAcase from the other occurences ofbb.utils.filter()in my patch (i.e., in the *.bb), or even in oe-core?Quoted 1 line
And the leading space is also a tiny problem.
After Quentin's comment, I double-checked and
ERROR_QAis not handled in the same way asTUNE_CCARGS_MFPU, so the extra leading space should be fine. I agree, however, that it's not very nice to add it unconditionally.One more thing: could you please clarify what you mean by "two different things"? I'm not sure to follow, even with the example. The use case is still one and only: check if the string is in the variable, and if so, return it.
VAR_1 = bb.utils.filter(VAR_2, ....)
When you do this, this gives people an impression that VAR1 and VAR2 are conceptually related.
For example, PACKAGECONFIG & DISTRO_FEATURES both control the way recipes are built, they are switches for recipes, and they are related. Many PACKAEGECONFIG items' names are selected to be the same with DISTRO_FEAETURES, e.g., pam, acl., because they are the most reasonable names.
But if you look at ERROR_QA, the items names really have no relations with DISTRO_FEATURES. The usrmerge QA check was actually checking filesystem hierarchy. If we consider the possible sbin -> bin merge in the future, the QA check name should be something like "filesystem-hierarchy-check".
To be clear, I'm not against *all* parts of this patch. For example, you have:
PACKAGECONFIG ?= "\
- ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
+ ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \
"
And I think it's a correct change.
I think the problematic ones are ERROR_QA and RDEPENDS.
Regards,
Qi
Quoted 6 lines
Quoted 3 lines
Regards,
QiThanks!
Hello,
(...)
Quoted 6 lines
VAR_1=bb.utils.filter(VAR_2, ....)When you do this, this gives people an impression that VAR1 and VAR2 are conceptually related.
For example, PACKAGECONFIG &
DISTRO_FEATURESboth control the way recipes are built, they are switches for recipes, and they are related. Many PACKAEGECONFIG items' names are selected to be the same withDISTRO_FEAETURES, e.g., pam, acl., because they are the most reasonable names.
I see what you mean now, thanks!
Quoted 1 line
But if you look at
ERROR_QA, the items names really have no relations withDISTRO_FEATURES. The usrmerge QA check was actually checking filesystem hierarchy. If we consider the possible sbin -> bin merge in the future, the QA check name should be something like "filesystem-hierarchy-check".
Indeed.
Quoted 9 lines
To be clear, I'm not against *all* parts of this patch. For example, you have:
PACKAGECONFIG ?= "\
- ${@bb.utils.contains('DISTRO_FEATURES', 'selinux', 'selinux', '', d)} \
+ ${@bb.utils.filter('DISTRO_FEATURES', 'selinux', d)} \
"
Quoted 3 lines
And I think it's a correct change.
I think the problematic ones are
ERROR_QAand RDEPENDS.
Well, PACKAGECONFIG is also related to runtime, not only build-time. What I mean is you can specify additional runtime dependencies in the PACKAGECONFIG declaration/definition [1], so one could argue that RDEPENDS and PACKAGECONFIG are not so conceptually distant as the ERROR_QA and DISTRO_FEATURES example.
Quoted 2 lines
Regards,
Qi
Thanks for the review, and for the clarification as well.
[1] https://docs.yoctoproject.org/ref-manual/variables.html#term-PACKAGECONFIG
Signature · 2 lines
Best regards, João Marcos Costa