]> code.ossystems Code Review - openembedded-core.git/commitdiff
compatlayer/__init__.py: Allow add_layer to process recursive deps
authorMark Hatle <mark.hatle@windriver.com>
Fri, 31 Mar 2017 02:30:28 +0000 (21:30 -0500)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 5 Apr 2017 11:36:44 +0000 (12:36 +0100)
When processing a layer for dependencies, you have to process the layer
itself, it's dependencies, the dependencies dependencies and so forth until
all items have been processed.

i.e.:  LayerA requires LayerB requires LayerC requires layerD

The end result should be LayerB, LayerC and LayerD are all dependencies of
LayerA.

Signed-off-by: Mark Hatle <mark.hatle@windriver.com>
Signed-off-by: Ross Burton <ross.burton@intel.com>
scripts/lib/compatlayer/__init__.py

index 087ac141482542728fd92193cb198225c597c924..8d8bdfe93944f44b1353d064477247aa90fe2f5d 100644 (file)
@@ -143,10 +143,9 @@ def _find_layer_depends(depend, layers):
 def add_layer(bblayersconf, layer, layers, logger):
     logger.info('Adding layer %s' % layer['name'])
 
-    for collection in layer['collections']:
-        depends = layer['collections'][collection]['depends']
-        if not depends:
-            continue
+    def recurse_dependencies(depends, layer, layers, logger, ret = []):
+        logger.debug('Processing dependencies %s for layer %s.' % \
+                    (depends, layer['name']))
 
         for depend in depends.split():
             # core (oe-core) is suppose to be provided
@@ -157,8 +156,39 @@ def add_layer(bblayersconf, layer, layers, logger):
             if not layer_depend:
                 logger.error('Layer %s depends on %s and isn\'t found.' % \
                         (layer['name'], depend))
-                return False
+                ret = None
+                continue
+
+            # We keep processing, even if ret is None, this allows us to report
+            # multiple errors at once
+            if ret is not None and layer_depend not in ret:
+                ret.append(layer_depend)
+
+            # Recursively process...
+            if 'collections' not in layer_depend:
+                continue
+
+            for collection in layer_depend['collections']:
+                collect_deps = layer_depend['collections'][collection]['depends']
+                if not collect_deps:
+                    continue
+                ret = recurse_dependencies(collect_deps, layer_depend, layers, logger, ret)
+
+        return ret
 
+    layer_depends = []
+    for collection in layer['collections']:
+        depends = layer['collections'][collection]['depends']
+        if not depends:
+            continue
+
+        layer_depends = recurse_dependencies(depends, layer, layers, logger, layer_depends)
+
+    # Note: [] (empty) is allowed, None is not!
+    if layer_depends is None:
+        return False
+    else:
+        for layer_depend in layer_depends:
             logger.info('Adding layer dependency %s' % layer_depend['name'])
             with open(bblayersconf, 'a+') as f:
                 f.write("\nBBLAYERS += \"%s\"\n" % layer_depend['path'])