From patchwork Mon Nov 30 15:28:42 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Purdie X-Patchwork-Id: 106525 Received: from mail-wm1-f52.google.com (mail-wm1-f52.google.com [209.85.128.52]) by mx.groups.io with SMTP id smtpd.msgproc01-g2.34605.1796052546905390916 for ; Mon, 30 Nov 2026 07:29:07 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@linuxfoundation.org header.s=google header.b=S29PxFdy; spf=pass (domain: linuxfoundation.org, ip: 209.85.128.52, mailfrom: richard.purdie@linuxfoundation.org) Received: by mail-wm1-f52.google.com with SMTP id 5b1f17b1804b1-4bb61185057so67401265e9.1 for ; Mon, 30 Nov 2026 07:29:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=google; t=1796052545; x=1796657345; darn=lists.openembedded.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to:content-type; bh=EQeLQkxkKWT+HNKptZqtLeRx7GK940/J0xUnmHmteDI=; b=S29PxFdyCu0ElgVcFVkRLu+xlT4XXp664Bk58jjjm22HN0MjulAmroguuw3DjCjIWa fsVoaLZV3Z77tP8SBtb0NYtb12A969dS5ybwYKxQA2CHn6GJcLGTHlL5qFmZETG75TTv F8a057rHTixEVNjpcFXjee+uky7Wf744Zrj/4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796052545; x=1796657345; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to:content-type; bh=EQeLQkxkKWT+HNKptZqtLeRx7GK940/J0xUnmHmteDI=; b=svf1sXEauGdCjpLGPfQkdr04NaLyri82s84DNfsj4bWEsQf1wDWskHGvXggwQ1PGO4 q1kEU+cpQON/mEZcws69O17tR7KDE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:3b99:b0:4a1:777b:8a12 with SMTP id 5b1f17b1804b1-4bb8880b984mr772493745e9.14.1796052544980; Mon, 30 Nov 2026 07:29:04 -0800 (PST) Return-Path: Received: from max.int.rpsys.net ([2001:8b0:aba:5f3c:2444:81bb:2aff:8d84]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6baa397asm66033172f8f.48.2026.11.30.07.29.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 07:29:03 -0800 (PST) From: Richard Purdie To: bitbake-devel@lists.openembedded.org Subject: [PATCH 12/17] bblayers: Switch to use layerdata and new format layers Date: Mon, 30 Nov 2026 15:28:42 +0000 Message-ID: <20261130152847.3472849-12-richard.purdie@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20261130152847.3472849-1-richard.purdie@linuxfoundation.org> References: <20261130152847.3472849-1-richard.purdie@linuxfoundation.org> MIME-Version: 1.0 List-Id: X-Webhook-Received: from 45-33-107-173.ip.linodeusercontent.com [45.33.107.173] by lin-tor-korg-lkml-alma10-1 with HTTPS for ; Mon, 30 Nov 2026 15:29:12 -0000 X-Groupsio-URL: https://lists.openembedded.org/g/bitbake-devel/message/20501 Switch to use the new layerdata structure after the layer changes. The output does change as layers no longer have priorities. Signed-off-by: Richard Purdie --- lib/bblayers/action.py | 65 +++++++++++------------------------------- lib/bblayers/common.py | 20 +++++++++++-- lib/bblayers/query.py | 41 +++++++------------------- 3 files changed, 44 insertions(+), 82 deletions(-) diff --git a/lib/bblayers/action.py b/lib/bblayers/action.py index a14f19948e1..7ee326946fa 100644 --- a/lib/bblayers/action.py +++ b/lib/bblayers/action.py @@ -4,7 +4,6 @@ # SPDX-License-Identifier: GPL-2.0-only # -import fnmatch import logging import os import shutil @@ -103,16 +102,17 @@ cleanup may still be necessary afterwards, in particular: * where non-recipe files (such as patches) are overwritten (the flatten command will show a warning for these) * where anything beyond the normal layer setup has been added to - layer.conf (only the lowest priority number layer's layer.conf is used) + layer.conf (only the first layer's layer.conf is used, so the + flattened layer takes that layer's LAYERNAME and LAYERDEPENDS) * overridden/appended items from bbappends will need to be tidied up * when the flattened layers do not have the same directory structure (the flatten command should show a warning when this will cause a problem) Warning: if you flatten several layers where another layer is intended to -be used "inbetween" them (in layer priority order) such that recipes / -bbappends in the layers interact, and then attempt to use the new output -layer together with that other layer, you may no longer get the same -build results (as the layer priority order has effectively changed). +be used "inbetween" them such that recipes / bbappends in the layers +interact, and then attempt to use the new output layer together with that +other layer, you may no longer get the same build results (as the layer +ordering has effectively changed). """ if len(args.layer) == 1: logger.error('If you specify layers to flatten you must specify at least two') @@ -212,53 +212,20 @@ build results (as the layer priority order has effectively changed). bb.utils.copyfile(appendname, fdest) first_append = fdest - # Get the regex for the first layer in our list (which is where the conf/layer.conf file will - # have come from) - first_regex = None - layerdir = layers[0] - for layername, pattern, regex, _ in self.tinfoil.cooker.bbfile_config_priorities: - if regex.match(os.path.join(layerdir, 'test')): - first_regex = regex - break - - if first_regex: - # Find the BBFILES entries that match (which will have come from this conf/layer.conf file) - bbfiles = str(self.tinfoil.config_data.getVar('BBFILES')).split() - bbfiles_layer = [] - for item in bbfiles: - if first_regex.match(item): - newpath = os.path.join(outputdir, item[len(layerdir)+1:]) - bbfiles_layer.append(newpath) - - if bbfiles_layer: - # Check that all important layer files match BBFILES - for root, dirs, files in os.walk(outputdir): - for f1 in files: - ext = os.path.splitext(f1)[1] - if ext in ['.bb', '.bbappend']: - f1full = os.sep.join([root, f1]) - entry_found = False - for item in bbfiles_layer: - if fnmatch.fnmatch(f1full, item): - entry_found = True - break - if not entry_found: - logger.warning("File %s does not match the flattened layer's BBFILES setting, you may need to edit conf/layer.conf or move the file elsewhere" % f1full) + # Bitbake only looks for recipes and bbappends within a layer's recipes* + # directories (and dynamic-recipes//), check the flattened + # layer's files will still be found + for root, dirs, files in os.walk(outputdir): + for f1 in files: + if f1.endswith(('.bb', '.bbappend')): + f1full = os.path.join(root, f1) + topdir = os.path.relpath(f1full, outputdir).split(os.sep)[0] + if not (topdir.startswith('recipes') or topdir == 'dynamic-recipes'): + logger.warning("File %s is not within a recipes* directory of the flattened layer so will not be found, you may need to move it" % f1full) self.tinfoil.modified_files() - def get_file_layer(self, filename): - layerdir = self.get_file_layerdir(filename) - if layerdir: - return self.get_layer_name(layerdir) - else: - return '?' - - def get_file_layerdir(self, filename): - layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data) - return self.bbfile_collections.get(layer, None) - def apply_append(self, appendname, recipename): with open(appendname, 'r') as appendfile: with open(recipename, 'a') as recipefile: diff --git a/lib/bblayers/common.py b/lib/bblayers/common.py index f7b9cee3717..6a97476aa2a 100644 --- a/lib/bblayers/common.py +++ b/lib/bblayers/common.py @@ -8,6 +8,8 @@ import argparse import logging import os +import bb.utils + logger = logging.getLogger('bitbake-layers') @@ -15,12 +17,12 @@ class LayerPlugin(): def __init__(self): self.tinfoil = None self.bblayers = [] + self.layerdata = {} def tinfoil_init(self, tinfoil): self.tinfoil = tinfoil self.bblayers = (self.tinfoil.config_data.getVar('BBLAYERS') or "").split() - layerconfs = self.tinfoil.config_data.varhistory.get_variable_items_files('BBFILE_COLLECTIONS') - self.bbfile_collections = {layer: os.path.dirname(os.path.dirname(path)) for layer, path in layerconfs.items()} + self.layerdata = self.tinfoil.config_data.getVar('layerdata', False) or {} @staticmethod def add_command(subparsers, cmdname, function, parserecipes=True, *args, **kwargs): @@ -37,3 +39,17 @@ class LayerPlugin(): def get_layer_name(self, layerdir): return os.path.basename(layerdir.rstrip(os.sep)) + + def get_file_layerdir(self, filename): + """Return the directory of the configured layer containing filename, or None""" + layername = bb.utils.get_file_layer_from_layerdata(filename, self.layerdata) + if layername: + return self.layerdata[layername].path + return None + + def get_file_layer(self, filename): + layerdir = self.get_file_layerdir(filename) + if layerdir: + return self.get_layer_name(layerdir) + else: + return '?' diff --git a/lib/bblayers/query.py b/lib/bblayers/query.py index 7b8d1afd719..385e965e9ca 100644 --- a/lib/bblayers/query.py +++ b/lib/bblayers/query.py @@ -25,16 +25,14 @@ def plugin_init(plugins): class QueryPlugin(LayerPlugin): def __init__(self): super(QueryPlugin, self).__init__() - self.collection_res = {} def do_show_layers(self, args): """show current configured layers.""" - logger.plain("%s %s %s" % ("layer".ljust(20), "path".ljust(70), "priority")) - logger.plain('=' * 104) - for layer, _, regex, pri in self.tinfoil.cooker.bbfile_config_priorities: - layerdir = self.bbfile_collections.get(layer, None) - layername = layer - logger.plain("%s %s %s" % (layername.ljust(20), layerdir.ljust(70), pri)) + logger.plain("%s %s %s %s" % ("layer".ljust(20), "path".ljust(70), "version".ljust(7), "depends")) + logger.plain('=' * 113) + for layername, layer in self.layerdata.items(): + depends = bb.utils.join_deps(layer.depends, commasep=False) + logger.plain("%s %s %s %s" % (layername.ljust(20), layer.path.ljust(70), str(layer.version).ljust(7), depends)) def version_str(self, pe, pv, pr = None): verstr = "%s" % pv @@ -65,12 +63,9 @@ are overlayed will also be listed, with a " (skipped)" suffix. classes[classfile].append(classdir) # Locating classes and other files is a bit more complicated than recipes - - # layer priority is not a factor; instead BitBake uses the first matching - # file in BBPATH, which is manipulated directly by each layer's - # conf/layer.conf in turn, thus the order of layers in bblayers.conf is a - # factor - however, each layer.conf is free to either prepend or append to - # BBPATH (or indeed do crazy stuff with it). Thus the order in BBPATH might - # not be exactly the order present in bblayers.conf either. + # BitBake uses the first matching file in BBPATH, which is constructed + # from the layer dependencies (layers come before the layers they depend + # upon) so the order may not match the order present in bblayers.conf. bbpath = str(self.tinfoil.config_data.getVar('BBPATH')) overlayed_class_found = False for (classfile, classdirs) in classes.items(): @@ -255,22 +250,6 @@ skipped recipes will also be listed, with a " (skipped)" suffix. return items_listed - def get_file_layer(self, filename): - layerdir = self.get_file_layerdir(filename) - if layerdir: - return self.get_layer_name(layerdir) - else: - return '?' - - def get_collection_res(self): - if not self.collection_res: - self.collection_res = bb.utils.get_collection_res(self.tinfoil.config_data) - return self.collection_res - - def get_file_layerdir(self, filename): - layer = bb.utils.get_file_layer(filename, self.tinfoil.config_data, self.get_collection_res()) - return self.bbfile_collections.get(layer, None) - def remove_layer_prefix(self, f): """Remove the layer_dir prefix, e.g., f = /path/to/layer_dir/foo/blah, the return value will be: layer_dir/foo/blah""" @@ -527,12 +506,12 @@ NOTE: .bbappend files can impact the dependencies. self.add_command(sp, 'show-layers', self.do_show_layers, parserecipes=False) parser_show_overlayed = self.add_command(sp, 'show-overlayed', self.do_show_overlayed) - parser_show_overlayed.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of higher priority recipes with the ones they overlay indented underneath', action='store_true') + parser_show_overlayed.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of preferred recipes with the ones they overlay indented underneath', action='store_true') parser_show_overlayed.add_argument('-s', '--same-version', help='only list overlayed recipes where the version is the same', action='store_true') parser_show_overlayed.add_argument('--mc', help='use specified multiconfig', default='') parser_show_recipes = self.add_command(sp, 'show-recipes', self.do_show_recipes) - parser_show_recipes.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of higher priority recipes with the ones they overlay indented underneath', action='store_true') + parser_show_recipes.add_argument('-f', '--filenames', help='instead of the default formatting, list filenames of preferred recipes with the ones they overlay indented underneath', action='store_true') parser_show_recipes.add_argument('-r', '--recipes-only', help='instead of the default formatting, list recipes only', action='store_true') parser_show_recipes.add_argument('-m', '--multiple', help='only list where multiple recipes (in the same layer or different layers) exist for the same recipe name', action='store_true') parser_show_recipes.add_argument('-i', '--inherits', help='only list recipes that inherit the named class(es) - separate multiple classes using , (without spaces)', metavar='CLASS', default='')