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 ========= diff --git a/bitbake/lib/bb/parse/ast.py b/bitbake/lib/bb/parse/ast.py index ea1096f2de..49a0788038 100644 --- a/bitbake/lib/bb/parse/ast.py +++ b/bitbake/lib/bb/parse/ast.py @@ -343,11 +343,12 @@ class InheritDeferredNode(AstNode): bb.parse.BBHandler.inherit_defer(*self.inherit, data) class AddFragmentsNode(AstNode): - def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable): + def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable, builtin_fragments_variable): AstNode.__init__(self, filename, lineno) self.fragments_path_prefix = fragments_path_prefix self.fragments_variable = fragments_variable self.flagged_variables_list_variable = flagged_variables_list_variable + self.builtin_fragments_variable = builtin_fragments_variable def eval(self, data): # No need to use mark_dependency since we would only match a fragment @@ -360,13 +361,23 @@ class AddFragmentsNode(AstNode): return candidate_fragment_path return None + def check_and_set_builtin_fragment(fragment, data, builtin_fragments): + prefix, value = fragment.split('/', 1) + if prefix in builtin_fragments.keys(): + data.setVar(builtin_fragments[prefix], value) + return True + return False + fragments = data.getVar(self.fragments_variable) layers = data.getVar('BBLAYERS') flagged_variables = data.getVar(self.flagged_variables_list_variable).split() + builtin_fragments = {f[0]:f[1] for f in [f.split(':') for f in data.getVar(self.builtin_fragments_variable).split()] } if not fragments: return for f in fragments.split(): + if check_and_set_builtin_fragment(f, data, builtin_fragments): + continue layerid, fragment_name = f.split('/', 1) full_fragment_name = data.expand("{}/{}.conf".format(self.fragments_path_prefix, fragment_name)) fragment_path = find_fragment(layers, layerid, full_fragment_name) @@ -430,7 +441,8 @@ def handleAddFragments(statements, filename, lineno, m): fragments_path_prefix = m.group(1) fragments_variable = m.group(2) flagged_variables_list_variable = m.group(3) - statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable)) + builtin_fragments_variable = m.group(4) + statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable, flagged_variables_list_variable, builtin_fragments_variable)) def runAnonFuncs(d): code = [] diff --git a/bitbake/lib/bb/parse/parse_py/ConfHandler.py b/bitbake/lib/bb/parse/parse_py/ConfHandler.py index 675838d845..9ddbae123d 100644 --- a/bitbake/lib/bb/parse/parse_py/ConfHandler.py +++ b/bitbake/lib/bb/parse/parse_py/ConfHandler.py @@ -48,7 +48,7 @@ __export_regexp__ = re.compile( r"export\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) __unset_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)$" ) __unset_flag_regexp__ = re.compile( r"unset\s+([a-zA-Z0-9\-_+.${}/~]+)\[([a-zA-Z0-9\-_+.][a-zA-Z0-9\-_+.@]+)\]$" ) __addpylib_regexp__ = re.compile(r"addpylib\s+(.+)\s+(.+)" ) -__addfragments_regexp__ = re.compile(r"addfragments\s+(.+)\s+(.+)\s+(.+)" ) +__addfragments_regexp__ = re.compile(r"addfragments\s+(.+)\s+(.+)\s+(.+)\s+(.+)" ) def init(data): return