summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cooker.py
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:39:52 +0100
commitb3c41b1f469a1d4d558e5dbef827322444d3ba54 (patch)
tree9c0d61af42e440abd6094f454205c054d40a3782 /bitbake/lib/bb/cooker.py
parent43eb7d956333b07108c89995148d17341b9561f6 (diff)
downloadpoky-b3c41b1f469a1d4d558e5dbef827322444d3ba54.tar.gz
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. (Bitbake rev: d50389ae692377c957afec7c846fc2ce2c070a09) Signed-off-by: Liping Ke <liping.ke@intel.com>
Diffstat (limited to 'bitbake/lib/bb/cooker.py')
-rw-r--r--bitbake/lib/bb/cooker.py52
1 files changed, 44 insertions, 8 deletions
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 0b52f182ea..89da7e99cf 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -72,6 +72,41 @@ class BBCooker:
72 72
73 self.configuration = configuration 73 self.configuration = configuration
74 74
75 self.caches_array = []
76 # Currently, only Image Creator hob ui needs extra cache.
77 # So, we save Extra Cache class name and container file
78 # information into a extraCaches field in hob UI.
79 # TODO: In future, bin/bitbake should pass information into cooker,
80 # instead of getting information from configuration.ui. Also, some
81 # UI start up issues need to be addressed at the same time.
82 caches_name_array = ['bb.cache:CoreRecipeInfo']
83 if configuration.ui:
84 try:
85 module = __import__('bb.ui', fromlist=[configuration.ui])
86 name_array = (getattr(module, configuration.ui)).extraCaches
87 for recipeInfoName in name_array:
88 caches_name_array.append(recipeInfoName)
89 except ImportError, exc:
90 # bb.ui.XXX is not defined and imported. It's an error!
91 logger.critical("Unable to import '%s' interface from bb.ui: %s" % (configuration.ui, exc))
92 sys.exit("FATAL: Failed to import '%s' interface." % configuration.ui)
93 except AttributeError:
94 # This is not an error. If the field is not defined in the ui,
95 # this interface might need no extra cache fields, so
96 # just skip this error!
97 logger.debug("UI '%s' does not require extra cache!" % (configuration.ui))
98
99 # At least CoreRecipeInfo will be loaded, so caches_array will never be empty!
100 # This is the entry point, no further check needed!
101 for var in caches_name_array:
102 try:
103 module_name, cache_name = var.split(':')
104 module = __import__(module_name, fromlist=(cache_name,))
105 self.caches_array.append(getattr(module, cache_name))
106 except ImportError, exc:
107 logger.critical("Unable to import extra RecipeInfo '%s' from '%s': %s" % (cache_name, module_name, exc))
108 sys.exit("FATAL: Failed to import extra cache class '%s'." % cache_name)
109
75 self.configuration.data = bb.data.init() 110 self.configuration.data = bb.data.init()
76 111
77 if not server: 112 if not server:
@@ -730,9 +765,10 @@ class BBCooker:
730 765
731 self.buildSetVars() 766 self.buildSetVars()
732 767
733 self.status = bb.cache.CacheData() 768 self.status = bb.cache.CacheData(self.caches_array)
734 infos = bb.cache.Cache.parse(fn, self.get_file_appends(fn), \ 769 infos = bb.cache.Cache.parse(fn, self.get_file_appends(fn), \
735 self.configuration.data) 770 self.configuration.data,
771 self.caches_array)
736 infos = dict(infos) 772 infos = dict(infos)
737 773
738 fn = bb.cache.Cache.realfn2virtual(fn, cls) 774 fn = bb.cache.Cache.realfn2virtual(fn, cls)
@@ -876,7 +912,7 @@ class BBCooker:
876 else: 912 else:
877 collectlog.info("You have disabled Psyco. This decreases performance.") 913 collectlog.info("You have disabled Psyco. This decreases performance.")
878 914
879 self.status = bb.cache.CacheData() 915 self.status = bb.cache.CacheData(self.caches_array)
880 916
881 ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or "" 917 ignore = bb.data.getVar("ASSUME_PROVIDED", self.configuration.data, 1) or ""
882 self.status.ignored_dependencies = set(ignore.split()) 918 self.status.ignored_dependencies = set(ignore.split())
@@ -1091,9 +1127,9 @@ class ParsingFailure(Exception):
1091 self.args = (realexception, recipe) 1127 self.args = (realexception, recipe)
1092 1128
1093def parse_file(task): 1129def parse_file(task):
1094 filename, appends = task 1130 filename, appends, caches_array = task
1095 try: 1131 try:
1096 return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg) 1132 return True, bb.cache.Cache.parse(filename, appends, parse_file.cfg, caches_array)
1097 except Exception, exc: 1133 except Exception, exc:
1098 exc.recipe = filename 1134 exc.recipe = filename
1099 raise exc 1135 raise exc
@@ -1123,13 +1159,13 @@ class CookerParser(object):
1123 self.num_processes = int(self.cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or 1159 self.num_processes = int(self.cfgdata.getVar("BB_NUMBER_PARSE_THREADS", True) or
1124 multiprocessing.cpu_count()) 1160 multiprocessing.cpu_count())
1125 1161
1126 self.bb_cache = bb.cache.Cache(self.cfgdata) 1162 self.bb_cache = bb.cache.Cache(self.cfgdata, cooker.caches_array)
1127 self.fromcache = [] 1163 self.fromcache = []
1128 self.willparse = [] 1164 self.willparse = []
1129 for filename in self.filelist: 1165 for filename in self.filelist:
1130 appends = self.cooker.get_file_appends(filename) 1166 appends = self.cooker.get_file_appends(filename)
1131 if not self.bb_cache.cacheValid(filename): 1167 if not self.bb_cache.cacheValid(filename):
1132 self.willparse.append((filename, appends)) 1168 self.willparse.append((filename, appends, cooker.caches_array))
1133 else: 1169 else:
1134 self.fromcache.append((filename, appends)) 1170 self.fromcache.append((filename, appends))
1135 self.toparse = self.total - len(self.fromcache) 1171 self.toparse = self.total - len(self.fromcache)
@@ -1205,6 +1241,6 @@ class CookerParser(object):
1205 def reparse(self, filename): 1241 def reparse(self, filename):
1206 infos = self.bb_cache.parse(filename, 1242 infos = self.bb_cache.parse(filename,
1207 self.cooker.get_file_appends(filename), 1243 self.cooker.get_file_appends(filename),
1208 self.cfgdata) 1244 self.cfgdata, self.cooker.caches_array)
1209 for vfn, info in infos: 1245 for vfn, info in infos:
1210 self.cooker.status.add_from_recipeinfo(vfn, info) 1246 self.cooker.status.add_from_recipeinfo(vfn, info)