summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cache.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-15 18:03:29 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-18 10:06:26 +0100
commitb50b14e37249fb23b8e4f3a86f9b245cba85ca86 (patch)
tree9e7becee9892a76b9468513414c2e257290fde22 /bitbake/lib/bb/cache.py
parentb176189df1163d92aaec8b565bf69dcf76bab458 (diff)
downloadpoky-b50b14e37249fb23b8e4f3a86f9b245cba85ca86.tar.gz
bitbake: cache: Build datastores from databuilder object
Rather than passing in a datastore to build on top of, use the data builder object in the cache and base the parsed recipe from this. This turns things into proper objects building from one another rather than messy mixes of static and class functions. This sets things up so we can support parsing and building multiple configurations. (Bitbake rev: fef18b445c0cb6b266cd939b9c78d7cbce38663f) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r--bitbake/lib/bb/cache.py46
1 files changed, 27 insertions, 19 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 8c1fe11317..5f302d68b4 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -271,35 +271,44 @@ class NoCache(object):
271 self.databuilder = databuilder 271 self.databuilder = databuilder
272 self.data = databuilder.data 272 self.data = databuilder.data
273 273
274 @classmethod 274 def loadDataFull(self, virtualfn, appends):
275 def loadDataFull(cls, virtualfn, appends, cfgData):
276 """ 275 """
277 Return a complete set of data for fn. 276 Return a complete set of data for fn.
278 To do this, we need to parse the file. 277 To do this, we need to parse the file.
279 """ 278 """
280 279 logger.debug(1, "Parsing %s (full)" % virtualfn)
281 (fn, virtual) = virtualfn2realfn(virtualfn) 280 (fn, virtual) = virtualfn2realfn(virtualfn)
282 281 bb_data = self.load_bbfile(virtualfn, appends, virtonly=True)
283 logger.debug(1, "Parsing %s (full)", fn)
284
285 cfgData.setVar("__ONLYFINALISE", virtual or "default")
286 bb_data = cls.load_bbfile(fn, appends, cfgData)
287 return bb_data[virtual] 282 return bb_data[virtual]
288 283
289 @staticmethod 284 def load_bbfile(self, bbfile, appends, virtonly = False):
290 def load_bbfile(bbfile, appends, config):
291 """ 285 """
292 Load and parse one .bb build file 286 Load and parse one .bb build file
293 Return the data and whether parsing resulted in the file being skipped 287 Return the data and whether parsing resulted in the file being skipped
294 """ 288 """
289
290 if virtonly:
291 (bbfile, virtual) = virtualfn2realfn(bbfile)
292 bb_data = self.data.createCopy()
293 bb_data.setVar("__BBMULTICONFIG", mc)
294 bb_data.setVar("__ONLYFINALISE", virtual or "default")
295 datastores = self._load_bbfile(bb_data, bbfile, appends)
296 return datastores
297
298 bb_data = self.data.createCopy()
299 datastores = self._load_bbfile(bb_data, bbfile, appends)
300
301 return datastores
302
303 def _load_bbfile(self, bb_data, bbfile, appends):
295 chdir_back = False 304 chdir_back = False
296 305
297 # expand tmpdir to include this topdir 306 # expand tmpdir to include this topdir
298 config.setVar('TMPDIR', config.getVar('TMPDIR', True) or "") 307 bb_data.setVar('TMPDIR', bb_data.getVar('TMPDIR', True) or "")
299 bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) 308 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
300 oldpath = os.path.abspath(os.getcwd()) 309 oldpath = os.path.abspath(os.getcwd())
301 bb.parse.cached_mtime_noerror(bbfile_loc) 310 bb.parse.cached_mtime_noerror(bbfile_loc)
302 bb_data = config.createCopy() 311
303 # The ConfHandler first looks if there is a TOPDIR and if not 312 # The ConfHandler first looks if there is a TOPDIR and if not
304 # then it would call getcwd(). 313 # then it would call getcwd().
305 # Previously, we chdir()ed to bbfile_loc, called the handler 314 # Previously, we chdir()ed to bbfile_loc, called the handler
@@ -431,12 +440,11 @@ class Cache(NoCache):
431 len(self.depends_cache)), 440 len(self.depends_cache)),
432 self.data) 441 self.data)
433 442
434 @classmethod 443 def parse(self, filename, appends):
435 def parse(cls, filename, appends, configdata, caches_array):
436 """Parse the specified filename, returning the recipe information""" 444 """Parse the specified filename, returning the recipe information"""
437 logger.debug(1, "Parsing %s", filename) 445 logger.debug(1, "Parsing %s", filename)
438 infos = [] 446 infos = []
439 datastores = cls.load_bbfile(filename, appends, configdata) 447 datastores = self.load_bbfile(filename, appends)
440 depends = [] 448 depends = []
441 variants = [] 449 variants = []
442 # Process the "real" fn last so we can store variants list 450 # Process the "real" fn last so we can store variants list
@@ -451,14 +459,14 @@ class Cache(NoCache):
451 if virtualfn == filename: 459 if virtualfn == filename:
452 data.setVar("__VARIANTS", " ".join(variants)) 460 data.setVar("__VARIANTS", " ".join(variants))
453 info_array = [] 461 info_array = []
454 for cache_class in caches_array: 462 for cache_class in self.caches_array:
455 info = cache_class(filename, data) 463 info = cache_class(filename, data)
456 info_array.append(info) 464 info_array.append(info)
457 infos.append((virtualfn, info_array)) 465 infos.append((virtualfn, info_array))
458 466
459 return infos 467 return infos
460 468
461 def load(self, filename, appends, configdata): 469 def load(self, filename, appends):
462 """Obtain the recipe information for the specified filename, 470 """Obtain the recipe information for the specified filename,
463 using cached values if available, otherwise parsing. 471 using cached values if available, otherwise parsing.
464 472
@@ -479,13 +487,13 @@ class Cache(NoCache):
479 487
480 return cached, infos 488 return cached, infos
481 489
482 def loadData(self, fn, appends, cfgData, cacheData): 490 def loadData(self, fn, appends, cacheData):
483 """Load the recipe info for the specified filename, 491 """Load the recipe info for the specified filename,
484 parsing and adding to the cache if necessary, and adding 492 parsing and adding to the cache if necessary, and adding
485 the recipe information to the supplied CacheData instance.""" 493 the recipe information to the supplied CacheData instance."""
486 skipped, virtuals = 0, 0 494 skipped, virtuals = 0, 0
487 495
488 cached, infos = self.load(fn, appends, cfgData) 496 cached, infos = self.load(fn, appends)
489 for virtualfn, info_array in infos: 497 for virtualfn, info_array in infos:
490 if info_array[0].skipped: 498 if info_array[0].skipped:
491 logger.debug(1, "Skipping %s: %s", virtualfn, info_array[0].skipreason) 499 logger.debug(1, "Skipping %s: %s", virtualfn, info_array[0].skipreason)