Search code examples
yoctobitbake

How can I generate a Parsing Error in BitBake on intent?


I use Anonymous Python Functions in BitBake recipes to set variables during parsing. Now I wonder if I can check if a specific variable is set or not. If not, then I want to generate a BitBake Error, which stops the build process.

Pseudo code, that I want to create:

python __anonymous () {
    if d.getVar('MY_VARIABLE', True) == "":
        <BITBAKE ERROR with custom message "MY_VARIABLE not found">
}

Solution

  • You can call bb.fatal("MY_VARIABLE not set") which will print that error and abort the build by throwing an exception.

    Beware that d.getVar() returns None when the variable is unset. You only get the empty string if that's your default value.