I am trying to configure a Yocto build and would like to be able to specify the path to a layer in bblayers.conf
via an environment variable. This will allow engineers to checkout a configuration and build without needing to manually modify bblayers.conf
so to specify the absolute path to their checkout of the kernel module.
I have tried exporting a variable in my .zshrc
file, e.g.
export TRIALS=~/TRIALS
Unfortunately, when I attempt to access it in bblayers.conf
the value is not set:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
TRIALS_DIR = "${@os.environ['TRIALS']}"
BBLAYERS ?= " \
/home/ahk/poky/meta \
/home/ahk/poky/meta-poky \
/home/ahk/poky/meta-yocto-bsp \
/home/ahk/poky/meta-amd/meta-amd-bsp \
/home/ahk/poky/meta-amd/meta-amd-distro \
/home/ahk/poky/meta-congatec-amd \
/home/ahk/poky/meta-dpdk \
/home/ahk/poky/meta-openembedded/meta-oe \
/home/ahk/poky/meta-openembedded/meta-networking \
/home/ahk/poky/meta-openembedded/meta-python \
${TRIALS_DIR}/hello-layer \
"
The error I get is
bb.BBHandledException
ERROR: Failure expanding variable TRIALS_DIR, expression was
${@os.environ['TRIALS']} which triggered exception KeyError: 'TRIALS'
How do I set an environment variable in my shell that can be accessed from belayers.conf
Bitbake tightly controls the build environment to prevent unwanted contamination. This can be overridden by including any variables that you need to access to the BB_ENV_WHITELIST
.
For my example above I added the $TRIALS
variable to BB_ENV_WHITELIST
via
export BB_ENV_WHITELIST="$BB_ENV_WHITELIST TRIALS"
After setting BB_ENV_WHITELIST
it was necessary to re-initialise bitbake
via:
cd ~/poky
source oe-init-build-env
The $TRIALS
environment variable could then be accessed directly in bblayers.conf
:
# POKY_BBLAYERS_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
POKY_BBLAYERS_CONF_VERSION = "2"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
BBLAYERS ?= " \
/home/ahk/poky/meta \
/home/ahk/poky/meta-poky \
/home/ahk/poky/meta-yocto-bsp \
/home/ahk/poky/meta-amd/meta-amd-bsp \
/home/ahk/poky/meta-amd/meta-amd-distro \
/home/ahk/poky/meta-congatec-amd \
/home/ahk/poky/meta-dpdk \
/home/ahk/poky/meta-openembedded/meta-oe \
/home/ahk/poky/meta-openembedded/meta-networking \
/home/ahk/poky/meta-openembedded/meta-python \
${TRIALS}/hello-layer \
"