Search code examples
yoctobitbake

Override variable from other recipe that is not soft assigned (?=)


I want to change a variable value from another Yocto recipe that is not soft assigned '?='

For example

meta-layerA has a given recipe that sets variable FOO="valueA"

And I want to change FOO either in meta-layerB (custom recipe) or in local.conf

If meta-layerA has FOO?="valueA" I'm able to change FOO from local.conf.

Is there a way to change FOO even if '=' is used as assignment?


Solution

  • If you have a distro configuration you could use overrides (using the conditional syntax), something like:

    FOO:<distro_override> = "valueB"

    to reset the variable when your distro is configured1.

    In a .bbappend, a second assignment parsed after the first would override the original value so:

    FOO = "value2"

    would work too as it would reset the original value due to be parsed later.


    1 Note that the syntax for overrides changed in BitBake 1.52 (Honister 3.4). Prior to this the syntax for OVERRIDES used _ instead of :, so this would have been written as:

    FOO_<distro_override> = "valueB"