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 <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie 2013-05-24 09:27:25 +00:00
parent 7cf87fc083
commit fa4b1fa257
4 changed files with 16 additions and 16 deletions

View File

@ -387,7 +387,9 @@ class CommandsAsync:
""" """
prefiles = params[0] prefiles = params[0]
postfiles = params[1] postfiles = params[1]
command.cooker.databuilder.parseConfigurationFiles(prefiles, postfiles) command.cooker.configuration.prefile = prefiles
command.cooker.configuration.postfile = postfiles
command.cooker.loadConfigurationData()
command.finishAsyncCommand() command.finishAsyncCommand()
parseConfigurationFiles.needcache = False parseConfigurationFiles.needcache = False

View File

@ -165,7 +165,7 @@ class BBCooker:
if not self.configuration.server_register_idlecallback: if not self.configuration.server_register_idlecallback:
worker = True 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 self.configuration.data = self.databuilder.data
def enableDataTracking(self): def enableDataTracking(self):

View File

@ -38,7 +38,7 @@ class ConfigParameters(object):
self.options.pkgs_to_build = targets or [] self.options.pkgs_to_build = targets or []
self.options.tracking = False self.options.tracking = False
if self.options.show_environment: if hasattr(self.options, "show_environment") and self.options.show_environment:
self.options.tracking = True self.options.tracking = True
for key, val in self.options.__dict__.items(): for key, val in self.options.__dict__.items():
@ -125,12 +125,16 @@ class CookerConfiguration(object):
self.invalidate_stamp = False self.invalidate_stamp = False
self.dump_signatures = False self.dump_signatures = False
self.dry_run = False self.dry_run = False
self.tracking = False
self.env = {}
def setConfigParameters(self, parameters): def setConfigParameters(self, parameters):
self.params = parameters
for key in self.__dict__.keys(): for key in self.__dict__.keys():
if key in parameters.options.__dict__: if key in parameters.options.__dict__:
setattr(self, key, parameters.options.__dict__[key]) setattr(self, key, parameters.options.__dict__[key])
self.env = parameters.environment.copy()
self.tracking = parameters.tracking
def setServerRegIdleCallback(self, srcb): def setServerRegIdleCallback(self, srcb):
self.server_register_idlecallback = srcb self.server_register_idlecallback = srcb
@ -167,11 +171,11 @@ def findConfigFile(configfile):
class CookerDataBuilder(object): class CookerDataBuilder(object):
def __init__(self, params, worker = False): def __init__(self, cookercfg, worker = False):
self.prefiles = params.prefile self.prefiles = cookercfg.prefile
self.postfiles = params.postfile self.postfiles = cookercfg.postfile
self.tracking = params.tracking self.tracking = cookercfg.tracking
bb.utils.set_context(bb.utils.clean_context()) bb.utils.set_context(bb.utils.clean_context())
bb.event.set_class_handlers(bb.event.clean_class_handlers()) 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 # to use environment variables which have been cleaned from the
# BitBake processes env # BitBake processes env
self.savedenv = bb.data.init() self.savedenv = bb.data.init()
savedenv = params.environment for k in cookercfg.env:
for k in savedenv: self.savedenv.setVar(k, cookercfg.env[k])
self.savedenv.setVar(k, savedenv[k])
filtered_keys = bb.utils.approved_variables() filtered_keys = bb.utils.approved_variables()
bb.data.inheritFromOS(self.data, self.savedenv, filtered_keys) bb.data.inheritFromOS(self.data, self.savedenv, filtered_keys)

View File

@ -90,11 +90,6 @@ class TinfoilConfigParameters(ConfigParameters):
def parseCommandLine(self): def parseCommandLine(self):
class DummyOptions: class DummyOptions:
def __init__(self, initial_options): 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(): for key, val in initial_options.items():
setattr(self, key, val) setattr(self, key, val)