I set a debug flag in my local.conf
IS_DEBUG_BUILD = "1"
but a if condition in a Yocto recipe outputs False
all the time when I run bitbake -C compile my-recipe
do_install:append() {
bbwarn ${@d.getVar("IS_DEBUG_BUILD")}
if [ ${@d.getVar("IS_DEBUG_BUILD")} == '1' ]; then
bbwarn "True"
else
bbwarn "False"
fi
}
The line bbwarn ${@d.getVar("IS_DEBUG_BUILD")}
returns the correct values (0
and 1
).
What is wrong here?
Please try this code:
IS_DEBUG_BUILD_VALUE=${@d.getVar("IS_DEBUG_BUILD")}
if [ "$IS_DEBUG_BUILD_VALUE" = "1" ]; then
bbwarn "True"
else
bbwarn "False"
fi
The difference is in " " (double quotes) or ' ' (single quotes). They are used for respectively string or char type literals.
In your sample code, you first set the IS_DEBUG_BUILD to "1" (string) and then checked with ==
but you compared it to '1' (char).
String and char are never the same.