@@ -326,6 +326,34 @@ class InheritDeferredNode(AstNode):
inherits.append(self.inherit)
data.setVar('__BBDEFINHERITS', inherits)
+class AddFragmentsNode(AstNode):
+ def __init__(self, filename, lineno, fragments_path_prefix, fragments_variable):
+ AstNode.__init__(self, filename, lineno)
+ self.fragments_path_prefix = fragments_path_prefix
+ self.fragments_variable = fragments_variable
+
+ def eval(self, data):
+ def find_fragment(layers, layerid, full_fragment_name):
+ for layerpath in layers.split():
+ candidate_fragment_path = os.path.join(layerpath, full_fragment_name)
+ if os.path.exists(candidate_fragment_path) and bb.utils.get_file_layer(candidate_fragment_path, data) == layerid:
+ return candidate_fragment_path
+ return None
+
+ fragments = data.getVar(self.fragments_variable)
+ layers = data.getVar('BBLAYERS')
+
+ if not fragments:
+ return
+ for f in fragments.split():
+ 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)
+ if fragment_path:
+ bb.parse.ConfHandler.include(self.filename, fragment_path, self.lineno, data, "include fragment")
+ else:
+ bb.error("Could not find fragment {} in enabled layers: {}".format(f, layers))
+
def handleInclude(statements, filename, lineno, m, force):
statements.append(IncludeNode(filename, lineno, m.group(1), force))
@@ -370,6 +398,11 @@ def handleInheritDeferred(statements, filename, lineno, m):
classes = m.group(1)
statements.append(InheritDeferredNode(filename, lineno, classes))
+def handleAddFragments(statements, filename, lineno, m):
+ fragments_path_prefix = m.group(1)
+ fragments_variable = m.group(2)
+ statements.append(AddFragmentsNode(filename, lineno, fragments_path_prefix, fragments_variable))
+
def runAnonFuncs(d):
code = []
for funcname in d.getVar("__BBANONFUNCS", False) or []:
@@ -47,6 +47,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+(.+)" )
def init(data):
return
@@ -197,6 +198,11 @@ def feeder(lineno, s, fn, statements, baseconfig=False, conffile=True):
ast.handlePyLib(statements, fn, lineno, m)
return
+ m = __addfragments_regexp__.match(s)
+ if m:
+ ast.handleAddFragments(statements, fn, lineno, m)
+ return
+
raise ParseError("unparsed line: '%s'" % s, fn, lineno);
# Add us to the handlers list