The yocto project allows the use of relative path in most of its configuration files but not within the ./build/conf/bblayers.conf
file. What is the reason for blocking the use of anything but absolute paths for the BBLAYERS
and BBLAYERS_NON_REMOVABLE
variables?
I have looked at the BitBake user manual for yocto version 2.0 (current release) but that does not explain the reasoning. I also checked some of the older manual versions but they do not seem to mention the reasoning when talking of the bblayers.conf
file or the BBLAYERS
variable. The same file also contains BBPATH = "${TOPDIR}"
which is at least dynamically assigned and not that far away from the root yotco directory.
My best guess is that the bblayers.conf file is specific to the system it is being run on. That would make it unsuitable for sharing between developers via source control and the absolute paths would force people to edit the file whenever they received a copy. That did not seem like a very good reason though, hence the question.
conf file tells bitbake what layers you want to be considered during the build. By default, the layers listed in this file include layers minimally needed by the build system. However, you must manually add any custom layers you have created. E.g: BBLAYERS = "\ /home/jamal/poky/meta \
local. conf . It is a modified INI format file that introduces a meta-section header to carry additional information regarding the configuration files to be changed. A sample is provided in devstack/samples. The new header is similar to a normal INI section header but with double brackets ( [[ ...
I found a way to use relative paths.
You can use inline python to traverse the file system. The following script uses the provided TOPDIR
variable and then navigates to its parent via python's os.path
api.
# LAYER_CONF_VERSION is increased each time build/conf/bblayers.conf
# changes incompatibly
LCONF_VERSION = "6"
BBPATH = "${TOPDIR}"
BBFILES ?= ""
YOCTOROOT = "${@os.path.abspath(os.path.join("${TOPDIR}", os.pardir))}"
BBLAYERS ?= " \
${YOCTOROOT}/poky/meta \
${YOCTOROOT}/poky/meta-yocto \
${YOCTOROOT}/poky/meta-yocto-bsp \
"
BBLAYERS_NON_REMOVABLE ?= " \
${YOCTOROOT}/poky/meta \
${YOCTOROOT}/poky/meta-yocto \
"
I have managed to get "relative paths" in bblayers.conf
files working by replacing
BBLAYERS ?= " \
/home/username/poky/meta \
...
with
BBLAYERS ?= " \
${TOPDIR}/../meta \
...
I guess one caveat with this approach is that I'm relying on the meta-XXX
layer directories always being in the parent folder of TOPDIR
. This seems to be the case with the default way of using yocto, but might not be so for more customized build setups.
All the existing answers are answering "how to use relative paths" but the question is "why are absolute paths used". As far as I know the "why" is simple, it is done that way so that the build directory can be moved anywhere on the filesystem. Think about it: you can source poky/oe-init-build-env from anywhere on the filesystem and the build directory will be created there, so relying on paths relative to the build directory is very fragile.
Edit:
maybe this is clearer, I think you are assuming that the file bblayers.conf is always in poky/build/conf/bblayers.conf
and that you can therefore use a path like ../../meta-layer-foo
to refer so some layer which would be in poky/meta-layer-foo
, but the layer will not be found if I instantiate "build" in another path poky/foo/bar
:
etienne@ubuntu:~/repos/poky-tx2$ mkdir -p foo/bar
etienne@ubuntu:~/repos/poky-tx2$ cd foo/bar/
etienne@ubuntu:~/repos/poky-tx2/foo/bar$ ls
etienne@ubuntu:~/repos/poky-tx2/foo/bar$ source ../../oe-init-build-env
You had no conf/local.conf file. This configuration file has therefore been
created for you with some default values. You may wish to edit it to, for
example, select a different MACHINE (target hardware). See conf/local.conf
for more information as common configuration options are commented.
You had no conf/bblayers.conf file. This configuration file has therefore been
created for you with some default values. To add additional metadata layers
into your configuration please add entries to conf/bblayers.conf.
The Yocto Project has extensive documentation about OE including a reference
manual which can be found at:
http://yoctoproject.org/documentation
For more information about OpenEmbedded see their website:
http://www.openembedded.org/
### Shell environment set up for builds. ###
You can now run 'bitbake <target>'
Common targets are:
core-image-minimal
core-image-sato
meta-toolchain
meta-ide-support
You can also run generated qemu images with a command like 'runqemu qemux86'
etienne@ubuntu:~/repos/poky-tx2/foo/bar/build$ ls
conf
You can use relative paths in bblayers.conf
.
There is probably this line in your bblayers.conf
:
BBPATH = "${TOPDIR}"
When you want to find out this variable's content, you will probably find the top-level directory of your build directory:
bitbake -e | grep ^TOPDIR
# searches for bitbake variables
Inside this directory you could create a layer meta-test
and add it in bblayers.conf
with a relative path:
BBLAYERS ?= " \
meta-test \
[...]
"
So the answer on your question why there are absolute paths in bblayers.conf
is that you can place your build directory anywhere on the system and not dependant from Yocto.
Relative Paths to Layers must always be relative to the build directory.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With