From 1bfd6edef9db9c9175058ae801d1b601e4f15263 Mon Sep 17 00:00:00 2001
From: Richard Purdie <rpurdie@linux.intel.com>
Date: Wed, 20 Jan 2010 18:39:00 +0000
Subject: bitbake-dev: Sync with bitbake upstream

Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
---
 bitbake-dev/lib/bb/cache.py                    | 89 +++++++++++++-------------
 bitbake-dev/lib/bb/cooker.py                   | 21 +++---
 bitbake-dev/lib/bb/event.py                    |  5 +-
 bitbake-dev/lib/bb/parse/parse_py/BBHandler.py | 28 +++++---
 bitbake-dev/lib/bb/ui/knotty.py                |  4 +-
 5 files changed, 79 insertions(+), 68 deletions(-)

(limited to 'bitbake-dev')

diff --git a/bitbake-dev/lib/bb/cache.py b/bitbake-dev/lib/bb/cache.py
index d30d57d33..2f1b8fa60 100644
--- a/bitbake-dev/lib/bb/cache.py
+++ b/bitbake-dev/lib/bb/cache.py
@@ -134,7 +134,18 @@ class Cache:
         self.data = data
 
         # Make sure __depends makes the depends_cache
-        self.getVar("__depends", virtualfn, True)
+        # If we're a virtual class we need to make sure all our depends are appended 
+        # to the depends of fn.
+        depends = self.getVar("__depends", virtualfn, True) or []
+        if "__depends" not in self.depends_cache[fn] or not self.depends_cache[fn]["__depends"]:
+            self.depends_cache[fn]["__depends"] = depends
+        for dep in depends:
+            if dep not in self.depends_cache[fn]["__depends"]:
+                self.depends_cache[fn]["__depends"].append(dep)
+
+        # Make sure BBCLASSEXTEND always makes the cache too
+        self.getVar('BBCLASSEXTEND', virtualfn, True)
+
         self.depends_cache[virtualfn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
 
     def virtualfn2realfn(self, virtualfn):
@@ -170,11 +181,8 @@ class Cache:
 
         bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn)
 
-        bb_data, skipped = self.load_bbfile(fn, cfgData)
-        if isinstance(bb_data, dict):
-            return bb_data[cls]
-
-        return bb_data
+        bb_data = self.load_bbfile(fn, cfgData)
+        return bb_data[cls]
 
     def loadData(self, fn, cfgData, cacheData):
         """
@@ -184,42 +192,39 @@ class Cache:
         to record the variables accessed.
         Return the cache status and whether the file was skipped when parsed
         """
+        skipped = 0
+        virtuals = 0
+
         if fn not in self.checked:
             self.cacheValidUpdate(fn)
+
         if self.cacheValid(fn):
-            if "SKIPPED" in self.depends_cache[fn]:
-                return True, True
-            self.handle_data(fn, cacheData)
             multi = self.getVar('BBCLASSEXTEND', fn, True)
-            if multi:
-                for cls in multi.split():
-                    virtualfn = self.realfn2virtual(fn, cls)
-                    # Pretend we're clean so getVar works
-                    self.clean[virtualfn] = ""
-                    self.handle_data(virtualfn, cacheData)
-            return True, False
+            for cls in (multi or "").split() + [""]:
+                virtualfn = self.realfn2virtual(fn, cls)
+                if self.depends_cache[virtualfn]["__SKIPPED"]:
+                    skipped += 1
+                    bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn)
+                    continue
+                self.handle_data(virtualfn, cacheData)
+                virtuals += 1
+            return True, skipped, virtuals
 
         bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn)
 
-        bb_data, skipped = self.load_bbfile(fn, cfgData)
-
-        if skipped:
-           if isinstance(bb_data, dict):
-               self.setData(fn, fn, bb_data[""])
-           else:
-               self.setData(fn, fn, bb_data)
-           return False, skipped
+        bb_data = self.load_bbfile(fn, cfgData)
 
-        if isinstance(bb_data, dict):
-            for data in bb_data:
-                virtualfn = self.realfn2virtual(fn, data)
-                self.setData(virtualfn, fn, bb_data[data])
+        for data in bb_data:
+            virtualfn = self.realfn2virtual(fn, data)
+            self.setData(virtualfn, fn, bb_data[data])
+            if self.getVar("__SKIPPED", virtualfn, True):
+                skipped += 1
+                bb.msg.debug(1, bb.msg.domain.Cache, "Skipping %s" % virtualfn)
+            else:
                 self.handle_data(virtualfn, cacheData)
-            return False, skipped
+                virtuals += 1
+        return False, skipped, virtuals
 
-        self.setData(fn, fn, bb_data)
-        self.handle_data(fn, cacheData)
-        return False, skipped
 
     def cacheValid(self, fn):
         """
@@ -286,16 +291,13 @@ class Cache:
         if not fn in self.clean:
             self.clean[fn] = ""
 
-        return True
+        # Mark extended class data as clean too
+        multi = self.getVar('BBCLASSEXTEND', fn, True)
+        for cls in (multi or "").split():
+            virtualfn = self.realfn2virtual(fn, cls)
+            self.clean[virtualfn] = ""
 
-    def skip(self, fn):
-        """
-        Mark a fn as skipped
-        Called from the parser
-        """
-        if not fn in self.depends_cache:
-            self.depends_cache[fn] = {}
-        self.depends_cache[fn]["SKIPPED"] = "1"
+        return True
 
     def remove(self, fn):
         """
@@ -462,10 +464,7 @@ class Cache:
         try:
             bb_data = parse.handle(bbfile, bb_data) # read .bb data
             os.chdir(oldpath)
-            return bb_data, False
-        except bb.parse.SkipPackage:
-            os.chdir(oldpath)
-            return bb_data, True
+            return bb_data
         except:
             os.chdir(oldpath)
             raise
diff --git a/bitbake-dev/lib/bb/cooker.py b/bitbake-dev/lib/bb/cooker.py
index 25131b740..8036d7e9d 100644
--- a/bitbake-dev/lib/bb/cooker.py
+++ b/bitbake-dev/lib/bb/cooker.py
@@ -923,11 +923,13 @@ class CookerParser:
         # Accounting statistics
         self.parsed = 0
         self.cached = 0
-        self.skipped = 0
         self.error = 0
         self.masked = masked
         self.total = len(filelist)
 
+        self.skipped = 0
+        self.virtuals = 0
+
         # Pointer to the next file to parse
         self.pointer = 0
 
@@ -937,13 +939,14 @@ class CookerParser:
             cooker = self.cooker
 
             try:
-                fromCache, skip = cooker.bb_cache.loadData(f, cooker.configuration.data, cooker.status)
-                if skip:
-                    self.skipped += 1
-                    bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f)
-                    cooker.bb_cache.skip(f)
-                elif fromCache: self.cached += 1
-                else: self.parsed += 1
+                fromCache, skipped, virtuals = cooker.bb_cache.loadData(f, cooker.configuration.data, cooker.status)
+                if fromCache:
+                    self.cached += 1
+                else:
+                    self.parsed += 1
+
+                self.skipped += skipped
+                self.virtuals += virtuals
 
             except IOError, e:
                 self.error += 1
@@ -962,7 +965,7 @@ class CookerParser:
                 cooker.bb_cache.remove(f)
                 raise
             finally:
-                bb.event.fire(bb.event.ParseProgress(self.cached, self.parsed, self.skipped, self.masked, self.error, self.total), cooker.configuration.event_data)
+                bb.event.fire(bb.event.ParseProgress(self.cached, self.parsed, self.skipped, self.masked, self.virtuals, self.error, self.total), cooker.configuration.event_data)
 
             self.pointer += 1
 
diff --git a/bitbake-dev/lib/bb/event.py b/bitbake-dev/lib/bb/event.py
index 3062dc51b..7251d7871 100644
--- a/bitbake-dev/lib/bb/event.py
+++ b/bitbake-dev/lib/bb/event.py
@@ -253,14 +253,15 @@ class ParseProgress(Event):
     Parsing Progress Event
     """
 
-    def __init__(self, cached, parsed, skipped, masked, errors, total):
+    def __init__(self, cached, parsed, skipped, masked, virtuals, errors, total):
         Event.__init__(self)
         self.cached = cached
         self.parsed = parsed
         self.skipped = skipped
+        self.virtuals = virtuals
         self.masked = masked
         self.errors = errors
-        self.sofar = cached + parsed + skipped
+        self.sofar = cached + parsed
         self.total = total
 
 class DepTreeGenerated(Event):
diff --git a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
index 9b353634e..86fa18ebd 100644
--- a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
@@ -185,18 +185,26 @@ def handle(fn, d, include = 0):
             multi = data.getVar('BBCLASSEXTEND', d, 1)
             if multi:
                 based = bb.data.createCopy(d)
+            else:
+                based = d
+            try:
                 finalise(fn, based)
-                darray = {"": based}
-                for cls in multi.split():
-                    pn = data.getVar('PN', d, True)
-                    based = bb.data.createCopy(d)
-                    data.setVar('PN', pn + '-' + cls, based)
-                    inherit([cls], based)
+            except bb.parse.SkipPackage:
+                bb.data.setVar("__SKIPPED", True, based)
+            darray = {"": based}
+
+            for cls in (multi or "").split():
+                pn = data.getVar('PN', d, True)
+                based = bb.data.createCopy(d)
+                data.setVar('PN', pn + '-' + cls, based)
+                inherit([cls], based)
+                try:
                     finalise(fn, based)
-                    darray[cls] = based
-                return darray
-            else:
-                finalise(fn, d)
+                except bb.parse.SkipPackage:
+                    bb.data.setVar("__SKIPPED", True, based)
+                darray[cls] = based
+            return darray
+   
         bbpath.pop(0)
     if oldfile:
         bb.data.setVar("FILE", oldfile, d)
diff --git a/bitbake-dev/lib/bb/ui/knotty.py b/bitbake-dev/lib/bb/ui/knotty.py
index 6baed836a..c69fd6ca6 100644
--- a/bitbake-dev/lib/bb/ui/knotty.py
+++ b/bitbake-dev/lib/bb/ui/knotty.py
@@ -114,8 +114,8 @@ def init(server, eventHandler):
                         sys.stdout.write("done.")
                         sys.stdout.flush()
                 if x == y:
-                    print("\nParsing finished. %d cached, %d parsed, %d skipped, %d masked, %d errors." 
-                        % ( event.cached, event.parsed, event.skipped, event.masked, event.errors))
+                    print("\nParsing of %d .bb files complete (%d cached, %d parsed). %d targets, %d skipped, %d masked, %d errors." 
+                        % ( event.total, event.cached, event.parsed, event.virtuals, event.skipped, event.masked, event.errors))
                 continue
 
             if isinstance(event, bb.command.CookerCommandCompleted):
-- 
cgit v1.2.3