From fa4b1fa2577fb1a8128154c2f1417df575dbb022 Mon Sep 17 00:00:00 2001 From: Richard Purdie Date: Fri, 24 May 2013 09:27:25 +0000 Subject: [PATCH] bitbake: cooker/cookerdata: Improve configuration object handling Originally it seemed like a good idea to keep the parameters around. Having seen this in real life use, its incorrect, we should pull all the data we need into the cooker's configuguration and then use this to build the datastore. Being able to just build the datastore from the parameters seemed like a good idea but having a dummy cooker configuration object is now looking like the better option. This also fixes failures in hob since the parseFiles command can call into cooker directly now and reset the configuration prefiles and postfiles at will, rather than the indirect calls before which were breaking the datastore (e.g. BBPATH wasn't set). The cleanup this allows in tinfoil illustrates how this change makes more sense. (Bitbake rev: f50df5b891bf318f12fc61c74adfcc626cc6f836) Signed-off-by: Richard Purdie --- bitbake/lib/bb/command.py | 4 +++- bitbake/lib/bb/cooker.py | 2 +- bitbake/lib/bb/cookerdata.py | 21 ++++++++++++--------- bitbake/lib/bb/tinfoil.py | 5 ----- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/bitbake/lib/bb/command.py b/bitbake/lib/bb/command.py index 916eedac19..cc6a981921 100644 --- a/bitbake/lib/bb/command.py +++ b/bitbake/lib/bb/command.py @@ -387,7 +387,9 @@ class CommandsAsync: """ prefiles = params[0] postfiles = params[1] - command.cooker.databuilder.parseConfigurationFiles(prefiles, postfiles) + command.cooker.configuration.prefile = prefiles + command.cooker.configuration.postfile = postfiles + command.cooker.loadConfigurationData() command.finishAsyncCommand() parseConfigurationFiles.needcache = False diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index 4c0b569439..cd9cccdfce 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py @@ -165,7 +165,7 @@ class BBCooker: if not self.configuration.server_register_idlecallback: worker = True - self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration.params, worker) + self.databuilder = bb.cookerdata.CookerDataBuilder(self.configuration, worker) self.configuration.data = self.databuilder.data def enableDataTracking(self): diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py index 2247f8d3bd..11063b4af2 100644 --- a/bitbake/lib/bb/cookerdata.py +++ b/bitbake/lib/bb/cookerdata.py @@ -38,7 +38,7 @@ class ConfigParameters(object): self.options.pkgs_to_build = targets or [] self.options.tracking = False - if self.options.show_environment: + if hasattr(self.options, "show_environment") and self.options.show_environment: self.options.tracking = True for key, val in self.options.__dict__.items(): @@ -125,12 +125,16 @@ class CookerConfiguration(object): self.invalidate_stamp = False self.dump_signatures = False self.dry_run = False + self.tracking = False + + self.env = {} def setConfigParameters(self, parameters): - self.params = parameters for key in self.__dict__.keys(): if key in parameters.options.__dict__: setattr(self, key, parameters.options.__dict__[key]) + self.env = parameters.environment.copy() + self.tracking = parameters.tracking def setServerRegIdleCallback(self, srcb): self.server_register_idlecallback = srcb @@ -167,11 +171,11 @@ def findConfigFile(configfile): class CookerDataBuilder(object): - def __init__(self, params, worker = False): + def __init__(self, cookercfg, worker = False): - self.prefiles = params.prefile - self.postfiles = params.postfile - self.tracking = params.tracking + self.prefiles = cookercfg.prefile + self.postfiles = cookercfg.postfile + self.tracking = cookercfg.tracking bb.utils.set_context(bb.utils.clean_context()) bb.event.set_class_handlers(bb.event.clean_class_handlers()) @@ -184,9 +188,8 @@ class CookerDataBuilder(object): # to use environment variables which have been cleaned from the # BitBake processes env self.savedenv = bb.data.init() - savedenv = params.environment - for k in savedenv: - self.savedenv.setVar(k, savedenv[k]) + for k in cookercfg.env: + self.savedenv.setVar(k, cookercfg.env[k]) filtered_keys = bb.utils.approved_variables() bb.data.inheritFromOS(self.data, self.savedenv, filtered_keys) diff --git a/bitbake/lib/bb/tinfoil.py b/bitbake/lib/bb/tinfoil.py index c05e1465f1..45bac5edcb 100644 --- a/bitbake/lib/bb/tinfoil.py +++ b/bitbake/lib/bb/tinfoil.py @@ -90,11 +90,6 @@ class TinfoilConfigParameters(ConfigParameters): def parseCommandLine(self): class DummyOptions: def __init__(self, initial_options): - self.show_environment = False - self.pkgs_to_build = [] - self.prefile = [] - self.postfile = [] - self.tracking = False for key, val in initial_options.items(): setattr(self, key, val)