From 941ac7d2562ddc39ffcb85ebcc64621b132cf1d3 Mon Sep 17 00:00:00 2001 From: Alexander Kanavin Date: Wed, 18 Jun 2025 11:20:53 +0200 Subject: bitbake: parse/ast: add support for 'built-in' fragments When reviewing proposed fragments to add settings for DISTRO and MACHINE, RP noted that such fragments only add clutter and overhead, and there's no need to maintain them as separate files. Rather when bitbake sees 'fragmentvar/fragmentvalue' it can expand that into FRAGMENTVAR = "fragmentvalue". To achieve that, 'addfragments' directive is extended with a parameter that sets the name of the variable that holds definitions of such built-in fragments, for example like this: "machine:MACHINE distro:DISTRO" Then each enabled fragment name is matched against these definitions and the respective variable is set, e.g. 'machine/qemuarm' would match 'machine:MACHINE' and result in MACHINE set to 'qemuarm'. This happens before any fragment files are looked up on disk, and no such lookup happens if there was a match, which should prevent possible misuse of the feature. So the builtin fragment definition is also an allowlist for them. Please also see the patches for oe-core that show an application of the feature. (Bitbake rev: 3b9d7bea915dc7f10e845854f1dae325743f9456) Signed-off-by: Alexander Kanavin Signed-off-by: Richard Purdie --- .../bitbake-user-manual-metadata.rst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'bitbake/doc') diff --git a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst index a27b7758d9..f60a9d8312 100644 --- a/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst +++ b/bitbake/doc/bitbake-user-manual/bitbake-user-manual-metadata.rst @@ -998,9 +998,9 @@ This directive allows fine-tuning local configurations with configuration snippets contained in layers in a structured, controlled way. Typically it would go into ``bitbake.conf``, for example:: - addfragments conf/fragments OE_FRAGMENTS OE_FRAGMENTS_METADATA_VARS + addfragments conf/fragments OE_FRAGMENTS OE_FRAGMENTS_METADATA_VARS OE_BUILTIN_FRAGMENTS -``addfragments`` takes three parameters: +``addfragments`` takes four parameters: - path prefix for fragment files inside the layer file tree that bitbake uses to construct full paths to the fragment files @@ -1011,6 +1011,8 @@ go into ``bitbake.conf``, for example:: - name of variable that contains a list of variable names containing fragment-specific metadata (such as descriptions) +- name of variable that contains definitions for built-in fragments + This allows listing enabled configuration fragments in ``OE_FRAGMENTS`` variable like this:: @@ -1035,6 +1037,19 @@ The implementation will add a flag containing the fragment name to each of those when parsing fragments, so that the variables are namespaced by fragment name, and do not override each other when several fragments are enabled. +The variable containing a built-in fragment definitions could look like this:: + + OE_BUILTIN_FRAGMENTS = "someprefix:SOMEVARIABLE anotherprefix:ANOTHERVARIABLE" + +and then if 'someprefix/somevalue' is added to the variable that holds the list +of enabled fragments: + + OE_FRAGMENTS = "... someprefix/somevalue" + +bitbake will treat that as direct value assignment in its configuration:: + + SOMEVARIABLE = "somevalue" + Functions ========= -- cgit v1.2.3-54-g00ecf