From b50b14e37249fb23b8e4f3a86f9b245cba85ca86 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Mon, 15 Aug 2016 18:03:29 +0100 Subject: 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 --- bitbake/lib/bb/cache.py | 46 +++++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 19 deletions(-) (limited to 'bitbake/lib/bb/cache.py') 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): self.databuilder = databuilder self.data = databuilder.data - @classmethod - def loadDataFull(cls, virtualfn, appends, cfgData): + def loadDataFull(self, virtualfn, appends): """ Return a complete set of data for fn. To do this, we need to parse the file. """ - + logger.debug(1, "Parsing %s (full)" % virtualfn) (fn, virtual) = virtualfn2realfn(virtualfn) - - logger.debug(1, "Parsing %s (full)", fn) - - cfgData.setVar("__ONLYFINALISE", virtual or "default") - bb_data = cls.load_bbfile(fn, appends, cfgData) + bb_data = self.load_bbfile(virtualfn, appends, virtonly=True) return bb_data[virtual] - @staticmethod - def load_bbfile(bbfile, appends, config): + def load_bbfile(self, bbfile, appends, virtonly = False): """ Load and parse one .bb build file Return the data and whether parsing resulted in the file being skipped """ + + if virtonly: + (bbfile, virtual) = virtualfn2realfn(bbfile) + bb_data = self.data.createCopy() + bb_data.setVar("__BBMULTICONFIG", mc) + bb_data.setVar("__ONLYFINALISE", virtual or "default") + datastores = self._load_bbfile(bb_data, bbfile, appends) + return datastores + + bb_data = self.data.createCopy() + datastores = self._load_bbfile(bb_data, bbfile, appends) + + return datastores + + def _load_bbfile(self, bb_data, bbfile, appends): chdir_back = False # expand tmpdir to include this topdir - config.setVar('TMPDIR', config.getVar('TMPDIR', True) or "") + bb_data.setVar('TMPDIR', bb_data.getVar('TMPDIR', True) or "") bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) oldpath = os.path.abspath(os.getcwd()) bb.parse.cached_mtime_noerror(bbfile_loc) - bb_data = config.createCopy() + # The ConfHandler first looks if there is a TOPDIR and if not # then it would call getcwd(). # Previously, we chdir()ed to bbfile_loc, called the handler @@ -431,12 +440,11 @@ class Cache(NoCache): len(self.depends_cache)), self.data) - @classmethod - def parse(cls, filename, appends, configdata, caches_array): + def parse(self, filename, appends): """Parse the specified filename, returning the recipe information""" logger.debug(1, "Parsing %s", filename) infos = [] - datastores = cls.load_bbfile(filename, appends, configdata) + datastores = self.load_bbfile(filename, appends) depends = [] variants = [] # Process the "real" fn last so we can store variants list @@ -451,14 +459,14 @@ class Cache(NoCache): if virtualfn == filename: data.setVar("__VARIANTS", " ".join(variants)) info_array = [] - for cache_class in caches_array: + for cache_class in self.caches_array: info = cache_class(filename, data) info_array.append(info) infos.append((virtualfn, info_array)) return infos - def load(self, filename, appends, configdata): + def load(self, filename, appends): """Obtain the recipe information for the specified filename, using cached values if available, otherwise parsing. @@ -479,13 +487,13 @@ class Cache(NoCache): return cached, infos - def loadData(self, fn, appends, cfgData, cacheData): + def loadData(self, fn, appends, cacheData): """Load the recipe info for the specified filename, parsing and adding to the cache if necessary, and adding the recipe information to the supplied CacheData instance.""" skipped, virtuals = 0, 0 - cached, infos = self.load(fn, appends, cfgData) + cached, infos = self.load(fn, appends) for virtualfn, info_array in infos: if info_array[0].skipped: logger.debug(1, "Skipping %s: %s", virtualfn, info_array[0].skipreason) -- cgit v1.2.3-54-g00ecf