When defining a Bitbake recipe, how does PACKAGECONFIG... work?

161 views Asked by At

I have two Bitbake recipes and I'm using Dunfell Yocto.

Both recipes inherit cmake, ie. poky/meta/classes/cmake.bbclass. As I understand it, this CMake Bitbake class effectively just wraps the CMake config, build, and install commands in Yocto/Bitbake-speak -- Bitbake steps do_configure(), do_compile(), and do_install().

One of my recipes is a library. The other recipe is for the main executable, which DEPENDS on the library recipe. The executable needs the async option turned on in the library, which does it using a CMake define, CMAKE_TURN_ON_ASYNC=libasync when building the library.

To do that in my library recipe, I have found I could go several ways. The easiest I think is to just force my recipe to turn on the async option by using EXTRA_OECMAKE = "-DCMAKE_TURN_ON_ASYNC=libasync". However, since the library has the ability to turn it on and off in CMake, it seems only good practice and due diligence to provide that option to the Bitbake recipe.

So I'm trying to use the PACKAGECONFIG feature to do that and failing repeatedly despite giving my best effort to figure it out with both research and just trial and error. So maybe it's a fair time to ask the community.

The canonical example from the Variables Glossary starts with this. And I feel this is most likely where I'm going wrong, since = and ?= and ??= always throw me for a loop:

PACKAGECONFIG ??= "f1 f2 f3 ..."

I take this to mean that, both in and for my current recipe, I'm both defining and turning on features f1, f2, and f3 (unless otherwise set previously by a = or ?=). So, effectively, this recipe will have all these features turned on by default.

Assuming that's right, I came up with this to add to my lib-with-async-option recipe:

PACKAGECONFIG ??= "async"
PACKAGECONFIG[async] ="\
    -DCMAKE_TURN_ON_ASYNC=libasync, \
    -DCMAKE_TURN_ON_ASYNC=, \
    libasync \
"

Which, as I understand it, will effectively both define and turn on the async feature for this recipe, and thus add the -DCMAKE_TURN_ON_ASYNC=libasync to the configure script, and add libasync to the DEPENDS for this recipe.

To my second, executable recipe, I just add:

DEPENDS += "lib-with-async-option"

And that's it -- the executable recipe will get both lib-with-async-option and libasync added to its dependency tree, and compile lib-with-async-option with the async feature turned on.

Well, from the console output, it doesn't seem to work, though as with most things in Yocto/Bitbake, I can't say that for sure. The executable compiles fine, but then fails at the linking stage, with tell-tale signs that it's missing the libasync library. I thought I'd come up for air for a sanity check before further troubleshooting.

Am I using the PACKAGECONFIG feature correctly to both define and enable a feature by default for my lib-with-async-option recipe?

I don't see async in the list of common features, but I wonder if I'm stomping on one not defined there? Or do I need to be setting async in MACHINE_FEATURES, DISTRO_FEATURES, or IMAGE_FEATURES?

0

There are 0 answers