]> code.ossystems Code Review - openembedded-core.git/commitdiff
cooker: stop loading the cache for -b
authorChris Larson <chris_larson@mentor.com>
Fri, 19 Nov 2010 18:46:42 +0000 (11:46 -0700)
committerRichard Purdie <rpurdie@linux.intel.com>
Tue, 4 Jan 2011 14:46:43 +0000 (14:46 +0000)
Previously, the cache was actually being loaded from disk twice whenever using
-b or -e -b.  This also moves the bb_cache instance into the CookerParser, as
it's not needed by the cooker itself at all.

(Bitbake rev: dd0ec2f7b18e2a9ab06c499b775670516bd06ac8)

Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
bitbake/lib/bb/cache.py
bitbake/lib/bb/cooker.py
bitbake/lib/bb/runqueue.py
bitbake/lib/bb/shell.py

index 5adce594f08e345cd157b14cecbf905fb7dd0067..2b92ed01f03fe4a2ff1bbc3226b124e7c358c6fe 100644 (file)
@@ -172,7 +172,7 @@ class Cache(object):
         # If any of configuration.data's dependencies are newer than the
         # cache there isn't even any point in loading it...
         newest_mtime = 0
-        deps = bb.data.getVar("__depends", data)
+        deps = bb.data.getVar("__base_depends", data)
 
         old_mtimes = [old_mtime for _, old_mtime in deps]
         old_mtimes.append(newest_mtime)
index 53f88b253c4b23a7e5ef21d9da33d9282d2ee57f..b573c32ed9bf7d7ff734d89ecb5258870a4e3db5 100644 (file)
@@ -75,9 +75,7 @@ class BBCooker:
 
     def __init__(self, configuration, server):
         self.status = None
-
-        self.cache = None
-        self.bb_cache = None
+        self.appendlist = {}
 
         if server:
             self.server = server.BitBakeServer(self)
@@ -217,8 +215,6 @@ class BBCooker:
         envdata = None
 
         if buildfile:
-            self.cb = None
-            self.bb_cache = bb.cache.init(self)
             fn = self.matchFile(buildfile)
         elif len(pkgs_to_build) == 1:
             self.updateCache()
@@ -239,7 +235,7 @@ class BBCooker:
 
         if fn:
             try:
-                envdata = self.bb_cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
+                envdata = bb.cache.Cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
             except Exception, e:
                 parselog.exception("Unable to read %s", fn)
                 raise
@@ -601,7 +597,7 @@ class BBCooker:
         """
 
         bf = os.path.abspath(buildfile)
-        (filelist, masked) = self.collect_bbfiles()
+        filelist, masked = self.collect_bbfiles()
         try:
             os.stat(bf)
             return [bf]
@@ -640,21 +636,25 @@ class BBCooker:
         if (task == None):
             task = self.configuration.cmd
 
-        self.bb_cache = bb.cache.init(self)
         self.status = bb.cache.CacheData()
 
-        (fn, cls) = self.bb_cache.virtualfn2realfn(buildfile)
+        (fn, cls) = bb.cache.Cache.virtualfn2realfn(buildfile)
         buildfile = self.matchFile(fn)
-        fn = self.bb_cache.realfn2virtual(buildfile, cls)
+        fn = bb.cache.Cache.realfn2virtual(buildfile, cls)
 
         self.buildSetVars()
 
-        # Load data into the cache for fn and parse the loaded cache data
-        the_data = self.bb_cache.loadDataFull(fn, self.get_file_appends(fn), self.configuration.data)
-        self.bb_cache.add(fn, the_data, self.status)
+        self.status = bb.cache.CacheData()
+        infos = bb.cache.Cache.parse(fn, self.get_file_appends(fn), \
+                                     self.configuration.data)
+        maininfo = None
+        for vfn, info in infos:
+            self.status.add_from_recipeinfo(vfn, info)
+            if vfn == fn:
+                maininfo = info
 
         # Tweak some variables
-        item = self.bb_cache.getVar('PN', fn, True)
+        item = maininfo.pn
         self.status.ignored_dependencies = set()
         self.status.bbfile_priority[fn] = 1
 
@@ -852,7 +852,6 @@ class BBCooker:
     def collect_bbfiles( self ):
         """Collect all available .bb build files"""
         parsed, cached, skipped, masked = 0, 0, 0, 0
-        self.bb_cache = bb.cache.init(self)
 
         collectlog.debug(1, "collecting .bb files")
 
@@ -901,7 +900,6 @@ class BBCooker:
                 collectlog.debug(1, "skipping %s: unknown file extension", f)
 
         # Build a list of .bbappend files for each .bb file
-        self.appendlist = {}
         for f in bbappend:
             base = os.path.basename(f).replace('.bbappend', '.bb')
             if not base in self.appendlist:
@@ -913,7 +911,7 @@ class BBCooker:
     def get_file_appends(self, fn):
         """
         Returns a list of .bbappend files to apply to fn
-        NB: collect_files() must have been called prior to this
+        NB: collect_bbfiles() must have been called prior to this
         """
         f = os.path.basename(fn)
         if f in self.appendlist:
@@ -981,10 +979,10 @@ class CookerExit(bb.event.Event):
 
 class CookerParser(object):
     def __init__(self, cooker, filelist, masked):
-        # Internal data
         self.filelist = filelist
         self.cooker = cooker
         self.cfgdata = cooker.configuration.data
+        self.bb_cache = bb.cache.Cache(self.cfgdata)
 
         # Accounting statistics
         self.parsed = 0
@@ -996,7 +994,6 @@ class CookerParser(object):
         self.virtuals = 0
         self.total = len(filelist)
 
-        # current to the next file to parse
         self.current = 0
         self.result_queue = None
         self.fromcache = None
@@ -1010,7 +1007,7 @@ class CookerParser(object):
         self.fromcache = []
         for filename in self.filelist:
             appends = self.cooker.get_file_appends(filename)
-            if not self.cooker.bb_cache.cacheValid(filename):
+            if not self.bb_cache.cacheValid(filename):
                 self.task_queue.put((filename, appends))
             else:
                 self.fromcache.append((filename, appends))
@@ -1042,13 +1039,19 @@ class CookerParser(object):
         self.task_queue.close()
         for process in self.processes:
             process.join()
-        threading.Thread(target=self.cooker.bb_cache.sync).start()
+        threading.Thread(target=self.bb_cache.sync).start()
         threading.Thread(target=bb.codeparser.parser_cache_save(self.cooker.configuration.data)).start()
         if self.error > 0:
             raise ParsingErrorsFound()
 
+    def reparse(self, filename):
+        infos = self.bb_cache.parse(filename,
+                                    self.cooker.get_file_appends(filename),
+                                    self.cfgdata)
+        for vfn, info in infos:
+            self.cooker.status.add_from_recipeinfo(vfn, info)
+
     def parse_next(self):
-        cooker = self.cooker
         if self.current >= self.total:
             event = bb.event.ParseCompleted(self.cached, self.parsed,
                                             self.skipped, self.masked,
@@ -1064,7 +1067,7 @@ class CookerParser(object):
         try:
             if self.result_queue.empty() and self.fromcache:
                 filename, appends = self.fromcache.pop()
-                _, infos = cooker.bb_cache.load(filename, appends, self.cfgdata)
+                _, infos = self.bb_cache.load(filename, appends, self.cfgdata)
                 parsed = False
             else:
                 infos = self.result_queue.get()
@@ -1083,8 +1086,8 @@ class CookerParser(object):
             self.virtuals += len(infos)
 
             for virtualfn, info in infos:
-                cooker.bb_cache.add_info(virtualfn, info, cooker.status,
-                                         parsed=parsed)
+                self.bb_cache.add_info(virtualfn, info, self.cooker.status,
+                                       parsed=parsed)
                 if info.skipped:
                     self.skipped += 1
         finally:
index a80feb9504c952bb5bf3a6d70dbfc692b822099e..6282e5cf9b722b6ce141b7c100133f76983956ad 100644 (file)
@@ -1015,7 +1015,7 @@ class RunQueue:
         for task in range(len(self.rqdata.runq_fnid)):
             if self.rqdata.runq_fnid[task] not in done:
                 fn = self.rqdata.taskData.fn_index[self.rqdata.runq_fnid[task]] 
-                the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
+                the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
                 done.add(self.rqdata.runq_fnid[task])
 
         bb.parse.siggen.dump_sigs(self.rqdata.dataCache)
@@ -1088,7 +1088,7 @@ class RunQueueExecute:
         return
 
     def fork_off_task(self, fn, task, taskname):
-        the_data = self.cooker.bb_cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
+        the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
 
         env = bb.data.export_vars(the_data)
         env = bb.data.export_envvars(env, the_data)
index c61e93a1cb1d99609118be45be6304da90457183..3319e2d1cceff68265f7ef77df667b946d04c1f2 100644 (file)
@@ -272,9 +272,7 @@ class BitBakeShellCommands:
         bbfile = params[0]
         print("SHELL: Parsing '%s'" % bbfile)
         parse.update_mtime( bbfile )
-        cooker.bb_cache.cacheValidUpdate(bbfile)
-        fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status)
-        cooker.bb_cache.sync()
+        cooker.parser.reparse(bbfile)
         if False: #fromCache:
             print("SHELL: File has not been updated, not reparsing")
         else:
@@ -443,7 +441,7 @@ SRC_URI = ""
         name, var = params
         bbfile = self._findProvider( name )
         if bbfile is not None:
-            the_data = cooker.bb_cache.loadDataFull(bbfile, cooker.configuration.data)
+            the_data = cache.Cache.loadDataFull(bbfile, cooker.configuration.data)
             value = the_data.getVar( var, 1 )
             print(value)
         else: