From: ChenQi <Qi.Chen@windriver.com>
To: joaomarcos.costa@bootlin.com, openembedded-core@lists.openembedded.org
Cc: thomas.petazzoni@bootlin.com
Subject: Re: [OE-core] [PATCH] meta: simplify conditional operations with bb.utils.filter
Date: Mon, 27 Apr 2026 16:49:18 +0800 [thread overview]
Message-ID: <25ab1432-5860-4985-8827-e1a672f66a9a@windriver.com> (raw)
In-Reply-To: <20260424151718.13081-1-joaomarcos.costa@bootlin.com>
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
On 4/24/26 23:17, Joao Marcos Costa via lists.openembedded.org wrote:
> 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 <joaomarcos.costa@bootlin.com>
> ---
> 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(-)
>
> diff --git a/meta/classes-global/insane.bbclass b/meta/classes-global/insane.bbclass
> index feddfe0335..04700be71c 100644
> --- a/meta/classes-global/insane.bbclass
> +++ b/meta/classes-global/insane.bbclass
> @@ -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"
> diff --git a/meta/conf/machine/include/arm/feature-arm-neon.inc b/meta/conf/machine/include/arm/feature-arm-neon.inc
> index 174b9b9f2a..2ec354bfeb 100644
> --- a/meta/conf/machine/include/arm/feature-arm-neon.inc
> +++ b/meta/conf/machine/include/arm/feature-arm-neon.inc
> @@ -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."
> diff --git a/meta/conf/machine/include/arm/feature-arm-vfp.inc b/meta/conf/machine/include/arm/feature-arm-vfp.inc
> index d020100daa..be0c19bd03 100644
> --- a/meta/conf/machine/include/arm/feature-arm-vfp.inc
> +++ b/meta/conf/machine/include/arm/feature-arm-vfp.inc
> @@ -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 ''}"
> diff --git a/meta/recipes-connectivity/connman/connman_2.0.bb b/meta/recipes-connectivity/connman/connman_2.0.bb
> index 6f7093301b..e9873f3163 100644
> --- a/meta/recipes-connectivity/connman/connman_2.0.bb
> +++ b/meta/recipes-connectivity/connman/connman_2.0.bb
> @@ -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}"
> diff --git a/meta/recipes-core/coreutils/coreutils_9.10.bb b/meta/recipes-core/coreutils/coreutils_9.10.bb
> index 984c5b5292..744d930272 100644
> --- a/meta/recipes-core/coreutils/coreutils_9.10.bb
> +++ b/meta/recipes-core/coreutils/coreutils_9.10.bb
> @@ -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"
> diff --git a/meta/recipes-core/ovmf/ovmf_git.bb b/meta/recipes-core/ovmf/ovmf_git.bb
> index d731bca7f2..38d5d090b4 100644
> --- a/meta/recipes-core/ovmf/ovmf_git.bb
> +++ b/meta/recipes-core/ovmf/ovmf_git.bb
> @@ -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] = ",,,"
> diff --git a/meta/recipes-extended/at/at_3.2.5.bb b/meta/recipes-extended/at/at_3.2.5.bb
> index 112d1c4adc..ee485f67ec 100644
> --- a/meta/recipes-extended/at/at_3.2.5.bb
> +++ b/meta/recipes-extended/at/at_3.2.5.bb
> @@ -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,"
> diff --git a/meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb b/meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb
> index 18eeaa5523..c76763f811 100644
> --- a/meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb
> +++ b/meta/recipes-graphics/libglvnd/libglvnd_1.7.0.bb
> @@ -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)} \
> "
> diff --git a/meta/recipes-graphics/waffle/waffle_1.8.1.bb b/meta/recipes-graphics/waffle/waffle_1.8.1.bb
> index aefa0069cf..5d993cf254 100644
> --- a/meta/recipes-graphics/waffle/waffle_1.8.1.bb
> +++ b/meta/recipes-graphics/waffle/waffle_1.8.1.bb
> @@ -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)} \
> "
>
> diff --git a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb
> index cdf3a20dff..9945e79bf7 100644
> --- a/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb
> +++ b/meta/recipes-multimedia/gstreamer/gstreamer1.0-plugins-bad_1.28.2.bb
> @@ -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: openembedded-core+owner@lists.openembedded.org
> Unsubscribe: https://lists.openembedded.org/g/openembedded-core/unsub [Qi.Chen@eng.windriver.com]
> -=-=-=-=-=-=-=-=-=-=-=-
>
next prev parent reply other threads:[~2026-04-27 8:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 15:17 [PATCH] meta: simplify conditional operations with bb.utils.filter João Marcos Costa
2026-04-24 15:40 ` [OE-core] " Quentin Schulz
2026-04-27 8:38 ` Joao Marcos Costa
2026-04-27 10:45 ` Quentin Schulz
2026-04-27 10:53 ` Joao Marcos Costa
2026-04-27 8:49 ` ChenQi [this message]
2026-04-27 9:30 ` Joao Marcos Costa
2026-04-27 10:05 ` ChenQi
2026-04-27 11:01 ` Joao Marcos Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=25ab1432-5860-4985-8827-e1a672f66a9a@windriver.com \
--to=qi.chen@windriver.com \
--cc=joaomarcos.costa@bootlin.com \
--cc=openembedded-core@lists.openembedded.org \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox