How to enable/disable a particular bbappend for a specific MACHINE in Yocto
Asked Answered
G

2

9

I'm trying to understand the mechanism Yocto provides to enable/disable a particular bbappend for a specific MACHINE. I read this link (Modifying Variables to Support a Different Machine):

https://www.yoctoproject.org/docs/1.5/dev-manual/dev-manual.html#best-practices-to-follow-when-creating-layers

And also found some information related here on stack overflow:

Machine specific layers in yocto

I have tried putting all this information into practice without any success. This is my particular problem:

A BSP layer for an "x" platform provides a qtbase_%.bbappend that modifies qtbase recipe from meta-qt5. I need this qtbase_%.bbappend only applying when building for MACHINE="x", but not for other different machines.

This is the content of the original qtbase_%.bbappend defined on the x-bsp-layer:

PACKAGECONFIG_GL   = "gles2"
PACKAGECONFIG_FONTS = "fontconfig"
PACKAGECONFIG_APPEND = " \
${@bb.utils.contains("DISTRO_FEATURES", "wayland", "xkbcommon-evdev", \
   bb.utils.contains("DISTRO_FEATURES", "x11", " ", "libinput eglfs gbm", d), d)} \
"
PACKAGECONFIG_append = " ${PACKAGECONFIG_APPEND} kms accessibility sm"
FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
PACKAGECONFIG_remove = "evdev"

Whenever I try to build an image for a MACHINE different from "x", the compilation is broken:

| ERROR: Feature 'opengles2' was enabled, but the pre-condition 'config.win32 || (!config.watchos && !features.opengl-desktop && libs.opengl_es2)' failed.
| ERROR: Feature 'eglfs' was enabled, but the pre-condition '!config.android && !config.darwin && !config.win32 && features.egl' failed.
| ERROR: Feature 'gbm' was enabled, but the pre-condition 'libs.gbm' failed.

Removing the x-BSP-layer from bblayers.conf solves the problem, but that's not the kind of solution I am looking for.

I tried fixing this using information provided in previous links. I modified qtbase_%.bbappend recipe in this way:

PACKAGECONFIG_GL_x   = "gles2"
PACKAGECONFIG_FONTS_x = "fontconfig"
PACKAGECONFIG_APPEND_x = " \
${@bb.utils.contains("DISTRO_FEATURES", "wayland", "xkbcommon-evdev", \
   bb.utils.contains("DISTRO_FEATURES", "x11", " ", "libinput eglfs gbm", d), d)} \
"
PACKAGECONFIG_append_x = " ${PACKAGECONFIG_APPEND} kms accessibility sm"
FILESEXTRAPATHS_prepend_x := "${THISDIR}/${PN}:"
PACKAGECONFIG_remove_x = "evdev"

As you can see, I appended the "_x" suffix to all recipe variables. It's supposed (at least that it's what I understand) those "_x" make the variable being assigned just in case the PLATFORM="x" is defined. Right? But it doesn't work as expected, it generates the same problem. So, in practice, this means I don't understand even the basics of this mechanism.

Can some of you provide a good explanation for this? I think it should be helpful for others with the same issue out there. Thanks a lot for your time! :-)

Gorden answered 12/6, 2018 at 13:42 Comment(0)
P
2

Just add COMPATIBLE_MACHINE = "x" in .bbappend file.

As you can see, I appended "_x" suffix to all recipe variables

Remove all "_x" suffix in .bbappend file.

Priceless answered 15/6, 2018 at 6:11 Comment(1)
For the record, that's documented here: yoctoproject.org/docs/current/ref-manual/…Rondo
B
2

Note adding COMPATIBLE_MACHINE as suggested would change the signatures of the original recipe, which is bad practice, and would result in your layer failing the compatibility test carried out by the yocto-check-layer script. Consult this for details.

The correct way of making a .bbappend file machine-specific is through overrides, as you're already doing in your proposal. Why it still fails is a different question. I suggest you to inspect the variables of the recipe through bitbake, and switch machines to verify they change accordingly.

Betray answered 27/1, 2022 at 14:4 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.