Using OVERRIDES to set variables from outside the recipe file


Andrew Loader
 

In the bitbake user manual it has an example of how to set the variable value using the OVERRIDE variable

 

OVERRIDES = "architecture:os:machine"

TEST = "default"

TEST_os = "osspecific"

TEST_nooverride = "othercondvalue"

 

Lets say this is in the recipe called “test_0.1.bb” and we remove the OVERRIDES line from it

 

If we want to the OVERRIDES value to configure the recipe externally say in local.conf as I do not want to change the recipe how would I do that?

 

Setting the OVERRIDES inside the same recipe seems limited it seems to give me just an easy way of having all the options and selecting one. I could use an append file to set it but I am sure it can be used in a better way.

I see in the Conditional Metadata section of the user manual there is another example using KBANCH with different architures being set but it does not explain how or were the OVERRIDES value is set.  Can some one explain how this works?

 

I have tried adding OVERRIDES_pn-test = “os” in the local.conf file but this results in a mess  or errors

 

Thanks

Andrew

 


Quentin Schulz
 

Hi Andrew,

On Thu, Dec 03, 2020 at 03:45:41AM +0000, Andrew Loader wrote:
In the bitbake user manual it has an example of how to set the variable value using the OVERRIDE variable

OVERRIDES = "architecture:os:machine"
TEST = "default"
TEST_os = "osspecific"
TEST_nooverride = "othercondvalue"

Lets say this is in the recipe called "test_0.1.bb" and we remove the OVERRIDES line from it

If we want to the OVERRIDES value to configure the recipe externally say in local.conf as I do not want to change the recipe how would I do that?
OVERRIDES is set in configuration files usually (always?). It can be
either in a distro if you use DISTROOVERRIDES, in a machine if you use
MACHINEOVERRIDES, and you might be able to add manually to it from
local.conf or other ways but I think you should go with DISTROOVERRIDES
or MACHINEOVERRIDES.

Then, the OVERRIDES (which contains MACHINEOVERRIDES:DISTROOVERRIDES
among other things) will be used in all recipes you can find and it
should just work.

You can use bitbake -e my-recipe | grep -e "^OVERRIDES=" to check the
content of the OVERRIDES variable. Note that righmost "OVERRIDE" is the
one which takes precedence over all others.

Quentin


Robert P. J. Day
 

On Thu, 3 Dec 2020, Quentin Schulz wrote:

Hi Andrew,

On Thu, Dec 03, 2020 at 03:45:41AM +0000, Andrew Loader wrote:
In the bitbake user manual it has an example of how to set the variable value using the OVERRIDE variable

OVERRIDES = "architecture:os:machine"
TEST = "default"
TEST_os = "osspecific"
TEST_nooverride = "othercondvalue"

Lets say this is in the recipe called "test_0.1.bb" and we remove the OVERRIDES line from it

If we want to the OVERRIDES value to configure the recipe externally say in local.conf as I do not want to change the recipe how would I do that?
OVERRIDES is set in configuration files usually (always?). It can be
either in a distro if you use DISTROOVERRIDES, in a machine if you
use MACHINEOVERRIDES, and you might be able to add manually to it
from local.conf or other ways but I think you should go with
DISTROOVERRIDES or MACHINEOVERRIDES.

Then, the OVERRIDES (which contains MACHINEOVERRIDES:DISTROOVERRIDES
among other things) will be used in all recipes you can find and it
should just work.

You can use bitbake -e my-recipe | grep -e "^OVERRIDES=" to check
the content of the OVERRIDES variable. Note that righmost "OVERRIDE"
is the one which takes precedence over all others.
i'm going to weigh in on this, as it *seems* that andrew has the
same misunderstanding i had when, lo those many years ago, i read that
section in the BB manual, and read this:

OVERRIDES = "architecture:os:machine"
TEST = "default"
TEST_os = "osspecific"
TEST_nooverride = "othercondvalue"

my initial problem with that section was that it wasn't clear that
entities like "architecture" and "os" and so on were *replaceable*, in
that one was supposed to put *examples* of those values in those
places. (laugh if you like, but if one is totally new to overrides,
that section can be misinterpreted in a truly tragic way on first
reading.)

i recall extending that section to attempt to make it more
understandable, but i think, over the holidays, i'm going to rewrite
it again with a simpler introduction and more examples straight from
the code base. (i believe i was the one who added the example
involving overriding the value of KBRANCH based on the target arch.)

in any event, i can easily see a much longer and involved
introduction to overrides.

rday


Andrew Loader
 

Thanks for your help
In the example above which I only  used to communicate the problem, without getting all complicated with details of my multiple projects, images and petalinux.
 
The solution would be to set the following in the local.conf file or another conf file or even a append file
OVERRIDES_append = ":os" 

It was a good tip to use "bitbake -e my-recipe | grep -e "^OVERRIDES=""
to show the results of this settings

There is another example using overrides for DEPENDS here https://docs.yoctoproject.org/dev-manual/dev-manual-common-tasks.html?highlight=depends_one
Which does not explain were the "one" machine is added to the OVERRIDES variable but the actual overrides mechanism seems clearly explained in both of the example sections mentioned but where and how this is set could do with a better examples

Thanks
Andrew


Quentin Schulz
 

Hi Andrew,

On Thu, Dec 03, 2020 at 07:23:43PM -0800, Andrew Loader wrote:
Thanks for your help
In the example above which I only  used to communicate the problem, without getting all complicated with details of my multiple projects, images and petalinux.

The solution would be to set the following in the local.conf file or another conf file or even a append file
OVERRIDES_append = ":os"

It was a good tip to use " bitbake -e my-recipe | grep -e "^OVERRIDES=""
to show the results of this settings

There is another example using overrides for DEPENDS here https://docs.yoctoproject.org/dev-manual/dev-manual-common-tasks.html?highlight=depends_one
Which does not explain were the "one" machine is added to the OVERRIDES variable but the actual overrides mechanism seems clearly explained in both of the example sections mentioned but where and how this is set could do with a better examples
MACHINE is automatically added to MACHINEOVERRIDES which in turn is
automatically added to OVERRIDES.

Doc patches welcome if something would benefit more or clearer explanation :)

Quentin