summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiping Ke <liping.ke@intel.com>2011-06-03 08:21:44 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2011-06-07 22:37:10 +0100
commitd50389ae692377c957afec7c846fc2ce2c070a09 (patch)
treed82699d040d40ecf5f721acf1dc1d475173aa2e6
parent75d9add923560af9fdd772a363c68337d2c9a97d (diff)
downloadbitbake-d50389ae692377c957afec7c846fc2ce2c070a09.tar.gz
cache: Introduce new param caches_array into Cache impl.
When using hob ui interface, we need extra cache fields. We will save ui required extra cache fields into a separate cache file. This patch introduce this caches_array parameter. It will be used in the extra cache implementation (following patch). Caches_array at least contains CoreRecipeInfo. If users need extra cache fields support, such as 'hob', caches_array will contain more relevant elements such as HobRecipeInfo. Signed-off-by: Liping Ke <liping.ke@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--lib/bb/cache.py15
-rw-r--r--lib/bb/cooker.py52
-rw-r--r--lib/bb/ui/hob.py2
3 files changed, 56 insertions, 13 deletions
diff --git a/lib/bb/cache.py b/lib/bb/cache.py
index 09691d98c..0620621d0 100644
--- a/lib/bb/cache.py
+++ b/lib/bb/cache.py
@@ -245,7 +245,11 @@ class Cache(object):
BitBake Cache implementation
"""
- def __init__(self, data):
+ def __init__(self, data, caches_array):
+ # Pass caches_array information into Cache Constructor
+ # It will be used in later for deciding whether we
+ # need extra cache file dump/load support
+ self.caches_array = caches_array
self.cachedir = bb.data.getVar("CACHE", data, True)
self.clean = set()
self.checked = set()
@@ -360,7 +364,7 @@ class Cache(object):
return bb_data[virtual]
@classmethod
- def parse(cls, filename, appends, configdata):
+ def parse(cls, filename, appends, configdata, caches_array):
"""Parse the specified filename, returning the recipe information"""
infos = []
datastores = cls.load_bbfile(filename, appends, configdata)
@@ -393,7 +397,7 @@ class Cache(object):
infos.append((virtualfn, self.depends_cache[virtualfn]))
else:
logger.debug(1, "Parsing %s", filename)
- return self.parse(filename, appends, configdata)
+ return self.parse(filename, appends, configdata, self.caches_array)
return cached, infos
@@ -623,8 +627,9 @@ class CacheData(object):
The data structures we compile from the cached data
"""
- def __init__(self):
- CoreRecipeInfo.init_cacheData(self)
+ def __init__(self, caches_array):
+ self.caches_array = caches_array
+ CoreRecipeInfo.init_cacheData(self)
# Direct cache variables
self.task_queues = {}
self.preferred = {}
diff --git a/lib/bb/cooker.py b/lib/bb/cooker.py
index 3fbe8ebc7..36792fae6 100644
--- a/lib/bb/cooker.py
+++ b/lib/bb/cooker.py
@@ -71,6 +71,41 @@ class BBCooker:
self.configuration = configuration
+ self.caches_array = []
+ # Currently, only Image Creator hob ui needs extra cache.
+ # So, we save Extra Cache class name and container file
+ # information into a extraCaches field in hob UI.
+ # TODO: In future, bin/bitbake should pass information into cooker,
+ # instead of getting information from configuration.ui. Also, some
+ # UI start up issues need to be addressed at the same time.
+ caches_name_array = ['bb.cache:CoreRecipeInfo']
+ if configuration.ui:
+ try:
+ module = __import__('bb.ui', fromlist=[configuration.ui])
+ name_array = (getattr(module, configuration.ui)).extraCaches
+ for recipeInfoName in name_array:
+ caches_name_array.append(recipeInfoName)
+ except ImportError, exc:
+ # bb.ui.XXX is not defined and imported. It's an error!
+ logger.critical("Unable to import '%s' interface from bb.ui: %s" % (configuration.ui, exc))
+ sys.exit("FATAL: Failed to import '%s' interface." % configuration.ui)
+ except AttributeError:
+ # This is not an error. If the field is not defined in the ui,
+ # this interface might need no extra cache fields, so
+ # just skip this error!
+ logger.debug("UI '%s' does not require extra cache!" % (configuration.ui))
+
+ # At least CoreRecipeInfo will be loaded, so caches_array will never be empty!
+ # This is the entry point, no further check needed!
+ for var in caches_name_array:
+ try:
+ module_name, cache_name = var.split(':')
+ module = __import__(module_name, fromlist=(cache_name,))
+ self.caches_array.append(getattr(module, cache_name))
+ except ImportError, exc:
+ logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc))
+ sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name)
+
self.configuration.data = bb.data.init()
bb.data.inheritFromOS(self.configuration.data)
@@ -727,9 +762,10 @@ class BBCooker:
self.buildSetVars()
- self.status = bb.cache.CacheData()
+ self.status = bb.cache.CacheData(self.caches_array)
infos = bb.cache.Cache.parse(fn, self.get_file_appends(fn), \
- self.configuration.data)
+ self.configuration.data,
+ self.caches_array)
infos = dict(infos)
fn = bb.cache.Cache.realfn2virtual(fn, cls)
@@ -879,7 +915,7 @@ class BBCooker:
else:
collectlog.info("You have disabled Psyco. This decreases performance.")
- self.status = bb.cache.CacheData()
+ self.status = bb.cache.CacheData(self.caches_array)
ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
self.status.ignored_dependencies = set(ignore.split())
@@ -1063,9 +1099,9 @@ class ParsingFailure(Exception):
Exception.__init__(self, realexception, recipe)
def parse_file(task):
- filename, appends = task
+ filename, appends, caches_array = task
try:
- return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg)
+ return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg, caches_array)
except Exception, exc:
tb = sys.exc_info()[2]
exc.recipe = filename
@@ -1097,13 +1133,13 @@ class CookerParser(object):
self.num_processes = int(self.cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or
multiprocessing.cpu_count())
- self.bb_cache = bb.cache.Cache(self.cfgdata)
+ self.bb_cache = bb.cache.Cache(self.cfgdata, cooker.caches_array)
self.fromcache = []
self.willparse = []
for filename in self.filelist:
appends = self.cooker.get_file_appends(filename)
if not self.bb_cache.cacheValid(filename):
- self.willparse.append((filename, appends))
+ self.willparse.append((filename, appends, cooker.caches_array))
else:
self.fromcache.append((filename, appends))
self.toparse = self.total - len(self.fromcache)
@@ -1193,6 +1229,6 @@ class CookerParser(object):
def reparse(self, filename):
infos = self.bb_cache.parse(filename,
self.cooker.get_file_appends(filename),
- self.cfgdata)
+ self.cfgdata, self.cooker.caches_array)
for vfn, info in infos:
self.cooker.status.add_from_recipeinfo(vfn, info)
diff --git a/lib/bb/ui/hob.py b/lib/bb/ui/hob.py
index 52788813c..9a804f123 100644
--- a/lib/bb/ui/hob.py
+++ b/lib/bb/ui/hob.py
@@ -28,6 +28,8 @@ import xmlrpclib
import logging
import Queue
+extraCaches = ['bb.cache_extra:HobRecipeInfo']
+
class MainWindow (gtk.Window):
def __init__(self, taskmodel, handler, curr_mach=None, curr_distro=None):