]> code.ossystems Code Review - openembedded-core.git/commitdiff
bitbake: Add in code to support the BBCLASSEXTEND variable. Virtual native/sdk recipe...
authorRichard Purdie <rpurdie@linux.intel.com>
Thu, 1 Jan 2009 14:43:54 +0000 (14:43 +0000)
committerRichard Purdie <rpurdie@linux.intel.com>
Sat, 3 Jan 2009 16:25:20 +0000 (16:25 +0000)
bitbake-dev/bin/bitdoc
bitbake-dev/lib/bb/cooker.py
bitbake/lib/bb/cache.py
bitbake/lib/bb/cooker.py
bitbake/lib/bb/parse/parse_py/BBHandler.py
bitbake/lib/bb/shell.py

index 3bcc9b344bbdcefae3aa51467b0ce50e564c3e5f..4940f660a6c2063d2d73765eb5eeff0384562f87 100755 (executable)
@@ -453,6 +453,8 @@ def main():
     except bb.parse.ParseError:
         bb.fatal( "Unable to parse %s" % config_file )
 
+    if isinstance(documentation, dict):
+        documentation = documentation[""]
 
     # Assuming we've the file loaded now, we will initialize the 'tree'
     doc = Documentation()
index 06f3395d7aa445f13de2bbeba92d6f2610e9d725..d19cef328d0a93736ae2e152035e8b8f84fb9238 100644 (file)
@@ -628,13 +628,10 @@ class BBCooker:
         fn = self.matchFile(buildfile)
         self.buildSetVars()
 
-        # Load data into the cache for fn
+        # Load data into the cache for fn and parse the loaded cache data
         self.bb_cache = bb.cache.init(self)
-        self.bb_cache.loadData(fn, self.configuration.data)      
-
-        # Parse the loaded cache data
         self.status = bb.cache.CacheData()
-        self.bb_cache.handle_data(fn, self.status)  
+        self.bb_cache.loadData(fn, self.configuration.data, self.status)      
 
         # Tweak some variables
         item = self.bb_cache.getVar('PN', fn, True)
index a6b81333d18efa9ec91443fbf8775c6af37ef930..1001012e0c2643ad319546d7fdc02019fb2ad1f5 100644 (file)
@@ -63,7 +63,7 @@ class Cache:
 
         self.has_cache = True
         self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
-            
+
         bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir)
         try:
             os.stat( self.cachedir )
@@ -125,30 +125,59 @@ class Cache:
         self.depends_cache[fn][var] = result
         return result
 
-    def setData(self, fn, data):
+    def setData(self, virtualfn, fn, data):
         """
         Called to prime bb_cache ready to learn which variables to cache.
         Will be followed by calls to self.getVar which aren't cached
         but can be fulfilled from self.data.
         """
-        self.data_fn = fn
+        self.data_fn = virtualfn
         self.data = data
 
         # Make sure __depends makes the depends_cache
-        self.getVar("__depends", fn, True)
-        self.depends_cache[fn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
+        self.getVar("__depends", virtualfn, True)
+        self.depends_cache[virtualfn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
+
+    def virtualfn2realfn(self, virtualfn):
+        """
+        Convert a virtual file name to a real one + the associated subclass keyword
+        """
+
+        fn = virtualfn
+        cls = ""
+        if virtualfn.startswith('virtual:'):
+            cls = virtualfn.split(':', 2)[1]
+            fn = virtualfn.replace('virtual:' + cls + ':', '')
+        #bb.msg.debug(2, bb.msg.domain.Cache, "virtualfn2realfn %s to %s %s" % (virtualfn, fn, cls))
+        return (fn, cls)
+
+    def realfn2virtual(self, realfn, cls):
+        """
+        Convert a real filename + the associated subclass keyword to a virtual filename
+        """
+        if cls == "":
+            #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and '%s' to %s" % (realfn, cls, realfn))
+            return realfn
+        #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn))
+        return "virtual:" + cls + ":" + realfn
 
-    def loadDataFull(self, fn, cfgData):
+    def loadDataFull(self, virtualfn, cfgData):
         """
         Return a complete set of data for fn.
         To do this, we need to parse the file.
         """
+
+        (fn, cls) = self.virtualfn2realfn(virtualfn)
+
         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
 
-    def loadData(self, fn, cfgData):
+    def loadData(self, fn, cfgData, cacheData):
         """
         Load a subset of data for fn.
         If the cached data is valid we do nothing,
@@ -161,12 +190,36 @@ class Cache:
         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
 
         bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn)
 
         bb_data, skipped = self.load_bbfile(fn, cfgData)
-        self.setData(fn, bb_data)
+
+        if skipped:
+           if isinstance(bb_data, dict):
+               self.setData(fn, fn, bb_data[""])
+           else:
+               self.setData(fn, fn, bb_data)
+           return False, skipped
+
+        if isinstance(bb_data, dict):
+            for data in bb_data:
+                virtualfn = self.realfn2virtual(fn, data)
+                self.setData(virtualfn, fn, bb_data[data])
+                self.handle_data(virtualfn, cacheData)
+            return False, skipped
+
+        self.setData(fn, fn, bb_data)
+        self.handle_data(fn, cacheData)
         return False, skipped
 
     def cacheValid(self, fn):
@@ -384,6 +437,7 @@ class Cache:
 
         # Touch this to make sure its in the cache
         self.getVar('__BB_DONT_CACHE', file_name, True)
+        self.getVar('BBCLASSEXTEND', file_name, True)
 
     def load_bbfile( self, bbfile , config):
         """
index 6a6d254d7a1188b17256f6f1ef287fcbc44bef8e..9f8c71ff13411cbec64a40773edc5c8aabe36767 100644 (file)
@@ -475,13 +475,10 @@ class BBCooker:
         if not fn:
             return False
 
-        # Load data into the cache for fn
+        # Load data into the cache for fn and parse the loaded cache data
         self.bb_cache = bb.cache.init(self)
-        self.bb_cache.loadData(fn, self.configuration.data)
-
-        # Parse the loaded cache data
         self.status = bb.cache.CacheData()
-        self.bb_cache.handle_data(fn, self.status)
+        self.bb_cache.loadData(fn, self.configuration.data, self.status)
 
         # Tweak some variables
         item = self.bb_cache.getVar('PN', fn, True)
@@ -723,7 +720,7 @@ class BBCooker:
 
             # read a file's metadata
             try:
-                fromCache, skip = self.bb_cache.loadData(f, self.configuration.data)
+                fromCache, skip = self.bb_cache.loadData(f, self.configuration.data, self.status)
                 if skip:
                     skipped += 1
                     bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f)
@@ -731,7 +728,6 @@ class BBCooker:
                     continue
                 elif fromCache: cached += 1
                 else: parsed += 1
-                deps = None
 
                 # Disabled by RP as was no longer functional
                 # allow metadata files to add items to BBFILES
@@ -744,8 +740,6 @@ class BBCooker:
                 #                aof = os.path.join(os.path.dirname(f),aof)
                 #            files.append(aof)
 
-                self.bb_cache.handle_data(f, self.status)
-
                 # now inform the caller
                 if progressCallback is not None:
                     progressCallback( i + 1, len( filelist ), f, fromCache )
index 3a309aed607c92891d8d1a86ba20de78c75251ff..97786c4202f1cfe1c46da539c5a4ae24f79ae01d 100644 (file)
@@ -181,7 +181,21 @@ def handle(fn, d, include = 0):
         classes.remove(__classname__)
     else:
         if include == 0:
-            finalise(fn, d)
+            multi = data.getVar('BBCLASSEXTEND', d, 1)
+            if multi:
+                based = bb.data.createCopy(d)
+                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)
+                    finalise(fn, based)
+                    darray[cls] = based
+                return darray
+            else:
+                finalise(fn, d)
         bbpath.pop(0)
     if oldfile:
         bb.data.setVar("FILE", oldfile, d)
index feba3f2b442340421e115a20e1db8e5fc03fbb83..c902f15a6ba94fccb5f444023598cc7d2b12cf44 100644 (file)
@@ -276,7 +276,7 @@ class BitBakeShellCommands:
         print "SHELL: Parsing '%s'" % bbfile
         parse.update_mtime( bbfile )
         cooker.bb_cache.cacheValidUpdate(bbfile)
-        fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data)
+        fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status)
         cooker.bb_cache.sync()
         if False: #fromCache:
             print "SHELL: File has not been updated, not reparsing"