Search code examples
yocto

In yocto, is Variables such as RDEPENDS:${PN} and FILES:${PN} related to OVERRIDES?


I want to know exactly about the role of : between variables and PN.

I understand that it is related to OVERRIDES variables and if the value after : was in OVERRIDES, the variables will be selected.

If so, how can I think variables like RDEPENDS:${PN} and FILES:${PN} ?

When I check OVERRIDES by bitbake -e, it shows the value as:

OVERRIDES="runtime-gnu:toolchain-gcc:linux:aarch64:pn-XXXX

but I cant't find ${PN} in that value.


Solution

  • Think of OVERRIDES as a feature that you can use to conditionally assign values to variables.

    Example:

    If you have a recipe that can work on various machines, and for each machine you have to select one specific file only:

    List of machines you have:

    • machine1 needs file1
    • machine2 needs file2

    Now in your recipes.bb

    SRC_URI:append:machine1 = " file1"
    SRC_URI:append:machine2 = " file2"
    

    Now, since your machine is automatically exist in OVERRIDESvariable, Bitbake will, at the end of the parsing process, override the variable with the value that is only compatible with the current machine.

    So, if your MACHINE = "machine1", SRC_URI will be appended with file1.

    • The PN variable:

    OVERRIDES variable contains pn-${PN} and not ${PN}, and this is useful for recipes only if you want to set a varible with a value that is only related to that recipe and not any other recipe.

    Actually, this is not useful inside the recipe itself:

    Let's assume we have a variable called DEMO_OVERRIDE in a recipe called recipe:

    DEMO_OVERRIDE:pn-${PN} = "${PN}"
    

    Now, in local.conf we set a default value for it:

    DEMO_OVERRIDE = "default_value"
    

    Now, bitbake -e | grep ^DEMO_OVERRIDE will give: default_value, but:

    bitbake -e <recipe> | grep ^DEMO_OVERRIDE will give recipe.

    This is useful when you want to change a variable of a recipe from a .conf file like following:

    SRC_URI:append:pn-<recipe> = " <value>"
    
    • Regarding RPROVIDES and FILES:

    The specification of PN with these variables are only used to split the package list to created at the end of the packaging task. Generally used in do_package_split and other tasks like following:

    d.getVar('FILES:' + pkg)
    
    ...
    
    d.getVar('RPROVIDES:' + pkg)
    

    and pkg is from: PACKAGES variable.

    • For general overview about OVERRIDES check this link.
    • For detailed overview about OVERRIDES check this link.