From 540bf592be0be3834a9e55d92263b1bbdaa25d11 Mon Sep 17 00:00:00 2001 From: Yoann Congal Date: Thu, 2 Oct 2025 12:09:27 +0200 Subject: bitbake: bitbake-setup: allow using {THISDIR}/my-layer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This implement the ability to use "{THISDIR}/my-layer" in the "bb-layers" list. "{THISDIR}" is remplaced by the directory containing the configuration file. In small projects, we try to keep the setup a simple as possible: a single git repo containing both the build confguration (e.g. a bitbake-setup configuration file) and the meta layer with project recipes/machine/distro. This change allows this kind of setup: ├── meta-my-project/ # the project layer └── my-project.conf.json # the bb-setup configuration file by writing, in my-project.conf.json: "bitbake-setup": { "configurations": [{ "bb-layers": [ "{THISDIR}/meta-my-project" Note: in this case meta-my-project is not present as a "source", so, not handled by bb-setup update/status. It is expected of the user to handle this on their own (is our case, a simple git workflow). (Bitbake rev: 61fbdeb358979bb13c9e50d807f43e554497dc9c) Signed-off-by: Yoann Congal Signed-off-by: Richard Purdie --- bitbake/bin/bitbake-setup | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) (limited to 'bitbake/bin/bitbake-setup') diff --git a/bitbake/bin/bitbake-setup b/bitbake/bin/bitbake-setup index 36a1bbd91a..de83d780bf 100755 --- a/bitbake/bin/bitbake-setup +++ b/bitbake/bin/bitbake-setup @@ -114,10 +114,23 @@ def checkout_layers(layers, layerdir, d): os.remove(symlink) os.symlink(os.path.relpath(t,layerdir),symlink) -def setup_bitbake_build(bitbake_config, layerdir, builddir): +def setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir): def _setup_build_conf(layers, build_conf_dir): os.makedirs(build_conf_dir) - layers_s = "\n".join([" {} \\".format(os.path.join(layerdir,l)) for l in layers]) + layers_s = [] + for l in layers: + if l.startswith("{THISDIR}/"): + if thisdir: + l = l.format(THISDIR=thisdir) + else: + raise Exception("Configuration is using {THISDIR} to specify " \ + "a layer path relative to itself. This can be done only " \ + "when the configuration is specified by its path on local " \ + "disk, not when it's in a registry or is fetched over http.") + if not os.path.isabs(l): + l = os.path.join(layerdir, l) + layers_s.append(" {} \\".format(l)) + layers_s = "\n".join(layers_s) bblayers_conf = """BBLAYERS ?= " \\ {} " @@ -237,7 +250,8 @@ def update_build(config, confdir, builddir, layerdir, d): layer_config[k]["git-remote"] = v["git-remote"] checkout_layers(layer_config, layerdir, d) bitbake_config = config["bitbake-config"] - setup_bitbake_build(bitbake_config, layerdir, builddir) + thisdir = os.path.dirname(config["path"]) if config["type"] == 'local' else None + setup_bitbake_build(bitbake_config, layerdir, builddir, thisdir) def int_input(allowed_values): n = None -- cgit v1.2.3-54-g00ecf