summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
authorRichard Purdie <rpurdie@linux.intel.com>2009-01-01 14:43:54 +0000
committerRichard Purdie <rpurdie@linux.intel.com>2009-01-03 16:25:20 +0000
commitade351e2f4c3693d4c2ecf3891899c2dcd082491 (patch)
tree5087685a70305a6d7792f2e622fca7654b6d0ced /bitbake/lib
parent28fd9dadbdf842d5db32e893be85068f9b2b114a (diff)
downloadpoky-ade351e2f4c3693d4c2ecf3891899c2dcd082491.tar.gz
bitbake: Add in code to support the BBCLASSEXTEND variable. Virtual native/sdk recipes then become possible
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/cache.py70
-rw-r--r--bitbake/lib/bb/cooker.py12
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py16
-rw-r--r--bitbake/lib/bb/shell.py2
4 files changed, 81 insertions, 19 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index a6b81333d1..1001012e0c 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/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/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index 6a6d254d7a..9f8c71ff13 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -475,13 +475,10 @@ class BBCooker:
475 if not fn: 475 if not fn:
476 return False 476 return False
477 477
478 # Load data into the cache for fn 478 # Load data into the cache for fn and parse the loaded cache data
479 self.bb_cache = bb.cache.init(self) 479 self.bb_cache = bb.cache.init(self)
480 self.bb_cache.loadData(fn, self.configuration.data)
481
482 # Parse the loaded cache data
483 self.status = bb.cache.CacheData() 480 self.status = bb.cache.CacheData()
484 self.bb_cache.handle_data(fn, self.status) 481 self.bb_cache.loadData(fn, self.configuration.data, self.status)
485 482
486 # Tweak some variables 483 # Tweak some variables
487 item = self.bb_cache.getVar('PN', fn, True) 484 item = self.bb_cache.getVar('PN', fn, True)
@@ -723,7 +720,7 @@ class BBCooker:
723 720
724 # read a file's metadata 721 # read a file's metadata
725 try: 722 try:
726 fromCache, skip = self.bb_cache.loadData(f, self.configuration.data) 723 fromCache, skip = self.bb_cache.loadData(f, self.configuration.data, self.status)
727 if skip: 724 if skip:
728 skipped += 1 725 skipped += 1
729 bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f) 726 bb.msg.debug(2, bb.msg.domain.Collection, "skipping %s" % f)
@@ -731,7 +728,6 @@ class BBCooker:
731 continue 728 continue
732 elif fromCache: cached += 1 729 elif fromCache: cached += 1
733 else: parsed += 1 730 else: parsed += 1
734 deps = None
735 731
736 # Disabled by RP as was no longer functional 732 # Disabled by RP as was no longer functional
737 # allow metadata files to add items to BBFILES 733 # allow metadata files to add items to BBFILES
@@ -744,8 +740,6 @@ class BBCooker:
744 # aof = os.path.join(os.path.dirname(f),aof) 740 # aof = os.path.join(os.path.dirname(f),aof)
745 # files.append(aof) 741 # files.append(aof)
746 742
747 self.bb_cache.handle_data(f, self.status)
748
749 # now inform the caller 743 # now inform the caller
750 if progressCallback is not None: 744 if progressCallback is not None:
751 progressCallback( i + 1, len( filelist ), f, fromCache ) 745 progressCallback( i + 1, len( filelist ), f, fromCache )
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 3a309aed60..97786c4202 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -181,7 +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 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)
185 bbpath.pop(0) 199 bbpath.pop(0)
186 if oldfile: 200 if oldfile:
187 bb.data.setVar("FILE", oldfile, d) 201 bb.data.setVar("FILE", oldfile, d)
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py
index feba3f2b44..c902f15a6b 100644
--- a/bitbake/lib/bb/shell.py
+++ b/bitbake/lib/bb/shell.py
@@ -276,7 +276,7 @@ class BitBakeShellCommands:
276 print "SHELL: Parsing '%s'" % bbfile 276 print "SHELL: Parsing '%s'" % bbfile
277 parse.update_mtime( bbfile ) 277 parse.update_mtime( bbfile )
278 cooker.bb_cache.cacheValidUpdate(bbfile) 278 cooker.bb_cache.cacheValidUpdate(bbfile)
279 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data) 279 fromCache = cooker.bb_cache.loadData(bbfile, cooker.configuration.data, cooker.status)
280 cooker.bb_cache.sync() 280 cooker.bb_cache.sync()
281 if False: #fromCache: 281 if False: #fromCache:
282 print "SHELL: File has not been updated, not reparsing" 282 print "SHELL: File has not been updated, not reparsing"