amend.bbclass: work with all versions of bitbake
authorChris Larson <chris_larson@mentor.com>
Fri, 20 Aug 2010 01:33:28 +0000 (18:33 -0700)
committerChris Larson <chris_larson@mentor.com>
Fri, 20 Aug 2010 01:34:59 +0000 (18:34 -0700)
Latest bitbake uses a set for __depends, rather than a list, so handle that
when we add the nonexistent files.

Signed-off-by: Chris Larson <chris_larson@mentor.com>
classes/amend.bbclass

index fb67b4e..2d92828 100644 (file)
@@ -14,20 +14,32 @@ python () {
     amendfiles = [os.path.join(fpath, "amend.inc")
                   for fpath in filespath]
 
-    # Adding all amend.incs that can exist to the __depends, to ensure that
-    # creating one of them invalidates the bitbake cache.  Note that it
-    # requires a fix in bitbake.  Without the bitbake fix, the cache will be
-    # completely invalidated on every bitbake execution.
-    depends = d.getVar("__depends", 0) or []
-    d.setVar("__depends", depends + [(file, 0) for file in amendfiles if not os.path.exists(file)])
-
-    # Make sure we don't parse the same amend.inc file more than once, if
-    # there are duplicates in FILESPATH
+    newdata = []
     seen = set()
-
     for file in amendfiles:
+        if file in seen:
+            continue
+        seen.add(file)
+
         if os.path.exists(file):
-            if file not in seen:
-                bb.parse.handle(file, d, 1)
-                seen.add(file)
+            bb.parse.handle(file, d, 1)
+        else:
+            # Manually add amend.inc files that don't exist to the __depends, to
+            # ensure that creating them invalidates the bitbake cache for that recipe.
+            newdata.append((file, 0))
+
+    if not newdata:
+        return
+
+    depends = d.getVar("__depends", False)
+    bbversion = tuple(int(i) for i in bb.__version__.split("."))
+    if bbversion < (1, 11, 0):
+        if depends is None:
+            depends = []
+        depends += newdata
+    else:
+        if depends is None:
+            depends = set()
+        depends |= set(newdata)
+    d.setVar("__depends", depends)
 }