summaryrefslogtreecommitdiffstats
path: root/bitbake-dev/lib/bb
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-01-03 16:33:11 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-01-03 16:33:11 +0000
commit772ec7db089f5fefd85e1e37695a22009e76d3bc (patch)
tree4f3f9066803f61b1f1898c1d39dff4f800239b40 /bitbake-dev/lib/bb
parentee0faf1346cabb0c90f43891ede3f88878f87b8b (diff)
downloadpoky-772ec7db089f5fefd85e1e37695a22009e76d3bc.tar.gz
bitbake-dev: Add BBCLASSEXTEND support
Diffstat (limited to 'bitbake-dev/lib/bb')
-rw-r--r--bitbake-dev/lib/bb/cache.py70
-rw-r--r--bitbake-dev/lib/bb/cooker.py5
-rw-r--r--bitbake-dev/lib/bb/parse/parse_py/BBHandler.py17
-rw-r--r--bitbake-dev/lib/bb/shell.py2
4 files changed, 79 insertions, 15 deletions
diff --git a/bitbake-dev/lib/bb/cache.py b/bitbake-dev/lib/bb/cache.py
index a6b81333d1..1001012e0c 100644
--- a/bitbake-dev/lib/bb/cache.py
+++ b/bitbake-dev/lib/bb/cache.py
@@ -63,7 +63,7 @@ class Cache:
63 63
64 self.has_cache = True 64 self.has_cache = True
65 self.cachefile = os.path.join(self.cachedir,"bb_cache.dat") 65 self.cachefile = os.path.join(self.cachedir,"bb_cache.dat")
66 66
67 bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir) 67 bb.msg.debug(1, bb.msg.domain.Cache, "Using cache in '%s'" % self.cachedir)
68 try: 68 try:
69 os.stat( self.cachedir ) 69 os.stat( self.cachedir )
@@ -125,30 +125,59 @@ class Cache:
125 self.depends_cache[fn][var] = result 125 self.depends_cache[fn][var] = result
126 return result 126 return result
127 127
128 def setData(self, fn, data): 128 def setData(self, virtualfn, fn, data):
129 """ 129 """
130 Called to prime bb_cache ready to learn which variables to cache. 130 Called to prime bb_cache ready to learn which variables to cache.
131 Will be followed by calls to self.getVar which aren't cached 131 Will be followed by calls to self.getVar which aren't cached
132 but can be fulfilled from self.data. 132 but can be fulfilled from self.data.
133 """ 133 """
134 self.data_fn = fn 134 self.data_fn = virtualfn
135 self.data = data 135 self.data = data
136 136
137 # Make sure __depends makes the depends_cache 137 # Make sure __depends makes the depends_cache
138 self.getVar("__depends", fn, True) 138 self.getVar("__depends", virtualfn, True)
139 self.depends_cache[fn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn) 139 self.depends_cache[virtualfn]["CACHETIMESTAMP"] = bb.parse.cached_mtime(fn)
140
141 def virtualfn2realfn(self, virtualfn):
142 """
143 Convert a virtual file name to a real one + the associated subclass keyword
144 """
145
146 fn = virtualfn
147 cls = ""
148 if virtualfn.startswith('virtual:'):
149 cls = virtualfn.split(':', 2)[1]
150 fn = virtualfn.replace('virtual:' + cls + ':', '')
151 #bb.msg.debug(2, bb.msg.domain.Cache, "virtualfn2realfn %s to %s %s" % (virtualfn, fn, cls))
152 return (fn, cls)
153
154 def realfn2virtual(self, realfn, cls):
155 """
156 Convert a real filename + the associated subclass keyword to a virtual filename
157 """
158 if cls == "":
159 #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and '%s' to %s" % (realfn, cls, realfn))
160 return realfn
161 #bb.msg.debug(2, bb.msg.domain.Cache, "realfn2virtual %s and %s to %s" % (realfn, cls, "virtual:" + cls + ":" + realfn))
162 return "virtual:" + cls + ":" + realfn
140 163
141 def loadDataFull(self, fn, cfgData): 164 def loadDataFull(self, virtualfn, cfgData):
142 """ 165 """
143 Return a complete set of data for fn. 166 Return a complete set of data for fn.
144 To do this, we need to parse the file. 167 To do this, we need to parse the file.
145 """ 168 """
169
170 (fn, cls) = self.virtualfn2realfn(virtualfn)
171
146 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn) 172 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s (full)" % fn)
147 173
148 bb_data, skipped = self.load_bbfile(fn, cfgData) 174 bb_data, skipped = self.load_bbfile(fn, cfgData)
175 if isinstance(bb_data, dict):
176 return bb_data[cls]
177
149 return bb_data 178 return bb_data
150 179
151 def loadData(self, fn, cfgData): 180 def loadData(self, fn, cfgData, cacheData):
152 """ 181 """
153 Load a subset of data for fn. 182 Load a subset of data for fn.
154 If the cached data is valid we do nothing, 183 If the cached data is valid we do nothing,
@@ -161,12 +190,36 @@ class Cache:
161 if self.cacheValid(fn): 190 if self.cacheValid(fn):
162 if "SKIPPED" in self.depends_cache[fn]: 191 if "SKIPPED" in self.depends_cache[fn]:
163 return True, True 192 return True, True
193 self.handle_data(fn, cacheData)
194 multi = self.getVar('BBCLASSEXTEND', fn, True)
195 if multi:
196 for cls in multi.split():
197 virtualfn = self.realfn2virtual(fn, cls)
198 # Pretend we're clean so getVar works
199 self.clean[virtualfn] = ""
200 self.handle_data(virtualfn, cacheData)
164 return True, False 201 return True, False
165 202
166 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn) 203 bb.msg.debug(1, bb.msg.domain.Cache, "Parsing %s" % fn)
167 204
168 bb_data, skipped = self.load_bbfile(fn, cfgData) 205 bb_data, skipped = self.load_bbfile(fn, cfgData)
169 self.setData(fn, bb_data) 206
207 if skipped:
208 if isinstance(bb_data, dict):
209 self.setData(fn, fn, bb_data[""])
210 else:
211 self.setData(fn, fn, bb_data)
212 return False, skipped
213
214 if isinstance(bb_data, dict):
215 for data in bb_data:
216 virtualfn = self.realfn2virtual(fn, data)
217 self.setData(virtualfn, fn, bb_data[data])
218 self.handle_data(virtualfn, cacheData)
219 return False, skipped
220
221 self.setData(fn, fn, bb_data)
222 self.handle_data(fn, cacheData)
170 return False, skipped 223 return False, skipped
171 224
172 def cacheValid(self, fn): 225 def cacheValid(self, fn):
@@ -384,6 +437,7 @@ class Cache:
384 437
385 # Touch this to make sure its in the cache 438 # Touch this to make sure its in the cache
386 self.getVar('__BB_DONT_CACHE', file_name, True) 439 self.getVar('__BB_DONT_CACHE', file_name, True)
440 self.getVar('BBCLASSEXTEND', file_name, True)
387 441
388 def load_bbfile( self, bbfile , config): 442 def load_bbfile( self, bbfile , config):
389 """ 443 """
diff --git a/bitbake-dev/lib/bb/cooker.py b/bitbake-dev/lib/bb/cooker.py
index d19cef328d..bbae4f03b5 100644
--- a/bitbake-dev/lib/bb/cooker.py
+++ b/bitbake-dev/lib/bb/cooker.py
@@ -868,7 +868,7 @@ class BBCooker:
868 868
869 # read a file's metadata 869 # read a file's metadata
870 try: 870 try:
871 fromCache, skip = self.bb_cache.loadData(f, self.configuration.data) 871 fromCache, skip = self.bb_cache.loadData(f, self.configuration.data, self.status)
872 if skip: 872 if skip:
873 skipped += 1 873 skipped += 1
874 bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f) 874 bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f)
@@ -876,7 +876,6 @@ class BBCooker:
876 continue 876 continue
877 elif fromCache: cached += 1 877 elif fromCache: cached += 1
878 else: parsed += 1 878 else: parsed += 1
879 deps = None
880 879
881 # Disabled by RP as was no longer functional 880 # Disabled by RP as was no longer functional
882 # allow metadata files to add items to BBFILES 881 # allow metadata files to add items to BBFILES
@@ -889,8 +888,6 @@ class BBCooker:
889 # aof = os.path.join(os.path.dirname(f),aof) 888 # aof = os.path.join(os.path.dirname(f),aof)
890 # files.append(aof) 889 # files.append(aof)
891 890
892 self.bb_cache.handle_data(f, self.status)
893
894 except IOError, e: 891 except IOError, e:
895 error += 1 892 error += 1
896 self.bb_cache.remove(f) 893 self.bb_cache.remove(f)
diff --git a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
index 00ad6ef4fe..5a128e8673 100644
--- a/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake-dev/lib/bb/parse/parse_py/BBHandler.py
@@ -181,8 +181,21 @@ def handle(fn, d, include = 0):
181 classes.remove(__classname__) 181 classes.remove(__classname__)
182 else: 182 else:
183 if include == 0: 183 if include == 0:
184 finalise(fn, d) 184 multi = data.getVar('BBCLASSEXTEND', d, 1)
185 185 if multi:
186 based = bb.data.createCopy(d)
187 finalise(fn, based)
188 darray = {"": based}
189 for cls in multi.split():
190 pn = data.getVar('PN', d, True)
191 based = bb.data.createCopy(d)
192 data.setVar('PN', pn + '-' + cls, based)
193 inherit([cls], based)
194 finalise(fn, based)
195 darray[cls] = based
196 return darray
197 else:
198 finalise(fn, d)
186 bbpath.pop(0) 199 bbpath.pop(0)
187 if oldfile: 200 if oldfile:
188 bb.data.setVar("FILE", oldfile, d) 201 bb.data.setVar("FILE", oldfile, d)
diff --git a/bitbake-dev/lib/bb/shell.py b/bitbake-dev/lib/bb/shell.py
index 55bae25d44..9d47effd69 100644
--- a/bitbake-dev/lib/bb/shell.py
+++ b/bitbake-dev/lib/bb/shell.py
@@ -268,7 +268,7 @@ class BitBakeShellCommands:
268 print "SHELL: Parsing '%s'" % bbfile 268 print "SHELL: Parsing '%s'" % bbfile
269 parse.update_mtime( bbfile ) 269 parse.update_mtime( bbfile )
270 cooker.bb_cache.cacheValidUpdate(bbfile) 270 cooker.bb_cache.cacheValidUpdate(bbfile)
271 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data) 271 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status)
272 cooker.bb_cache.sync() 272 cooker.bb_cache.sync()
273 if False: #fromCache: 273 if False: #fromCache:
274 print "SHELL: File has not been updated, not reparsing" 274 print "SHELL: File has not been updated, not reparsing"