summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cookerdata.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-16 17:47:06 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-08-18 10:06:27 +0100
commit218b81acb682bf0006afeb1a5c7bc4adf0549796 (patch)
tree4048ec43fa894149678209b9f8ae3f3985341c1f /bitbake/lib/bb/cookerdata.py
parentfac16ff8f7b1090324955e5198996324c6dcdc1d (diff)
downloadpoky-218b81acb682bf0006afeb1a5c7bc4adf0549796.tar.gz
bitbake: bitbake: Initial multi-config support
This patch adds the notion of supporting multiple configurations within a single build. To enable it, set a line in local.conf like: BBMULTICONFIG = "configA configB configC" This would tell bitbake that before it parses the base configuration, it should load conf/configA.conf and so on for each different configuration. These would contain lines like: MACHINE = "A" or other variables which can be set which can be built in the same build directory (or change TMPDIR not to conflict). One downside I've already discovered is that if we want to inherit this file right at the start of parsing, the only place you can put the configurations is in "cwd", since BBPATH isn't constructed until the layers are parsed and therefore using it as a preconf file isn't possible unless its located there. Execution of these targets takes the form "bitbake multiconfig:configA:core-image-minimal core-image-sato" so similar to our virtclass approach for native/nativesdk/multilib using BBCLASSEXTEND. Implementation wise, the implication is that instead of tasks being uniquely referenced with "recipename/fn:task" it now needs to be "configuration:recipename:task". We already started using "virtual" filenames for recipes when we implemented BBCLASSEXTEND and this patch adds a new prefix to these, "multiconfig:<configname>:" and hence avoid changes to a large part of the codebase thanks to this. databuilder has an internal array of data stores and uses the right one depending on the supplied virtual filename. That trick allows us to use the existing parsing code including the multithreading mostly unchanged as well as most of the cache code. For recipecache, we end up with a dict of these accessed by multiconfig (mc). taskdata and runqueue can only cope with one recipecache so for taskdata, we pass in each recipecache and have it compute the result and end up with an array of taskdatas. We can only have one runqueue so there extensive changes there. This initial implementation has some drawbacks: a) There are no inter-multi-configuration dependencies as yet b) There are no sstate optimisations. This means if the build uses the same object twice in say two different TMPDIRs, it will either load from an existing sstate cache at the start or build it twice. We can then in due course look at ways in which it would only build it once and then reuse it. This will likely need significant changes to the way sstate currently works to make that possible. (Bitbake rev: 5287991691578825c847bac2368e9b51c0ede3f0) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cookerdata.py')
-rw-r--r--bitbake/lib/bb/cookerdata.py59
1 files changed, 34 insertions, 25 deletions
diff --git a/bitbake/lib/bb/cookerdata.py b/bitbake/lib/bb/cookerdata.py
index 71021a3510..fa1de7a22f 100644
--- a/bitbake/lib/bb/cookerdata.py
+++ b/bitbake/lib/bb/cookerdata.py
@@ -237,9 +237,9 @@ class CookerDataBuilder(object):
237 237
238 bb.utils.set_context(bb.utils.clean_context()) 238 bb.utils.set_context(bb.utils.clean_context())
239 bb.event.set_class_handlers(bb.event.clean_class_handlers()) 239 bb.event.set_class_handlers(bb.event.clean_class_handlers())
240 self.data = bb.data.init() 240 self.basedata = bb.data.init()
241 if self.tracking: 241 if self.tracking:
242 self.data.enableTracking() 242 self.basedata.enableTracking()
243 243
244 # Keep a datastore of the initial environment variables and their 244 # Keep a datastore of the initial environment variables and their
245 # values from when BitBake was launched to enable child processes 245 # values from when BitBake was launched to enable child processes
@@ -250,15 +250,40 @@ class CookerDataBuilder(object):
250 self.savedenv.setVar(k, cookercfg.env[k]) 250 self.savedenv.setVar(k, cookercfg.env[k])
251 251
252 filtered_keys = bb.utils.approved_variables() 252 filtered_keys = bb.utils.approved_variables()
253 bb.data.inheritFromOS(self.data, self.savedenv, filtered_keys) 253 bb.data.inheritFromOS(self.basedata, self.savedenv, filtered_keys)
254 self.data.setVar("BB_ORIGENV", self.savedenv) 254 self.basedata.setVar("BB_ORIGENV", self.savedenv)
255 255
256 if worker: 256 if worker:
257 self.data.setVar("BB_WORKERCONTEXT", "1") 257 self.basedata.setVar("BB_WORKERCONTEXT", "1")
258
259 self.data = self.basedata
260 self.mcdata = {}
258 261
259 def parseBaseConfiguration(self): 262 def parseBaseConfiguration(self):
260 try: 263 try:
261 self.parseConfigurationFiles() 264 bb.parse.init_parser(self.basedata)
265 self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
266
267 if self.data.getVar("BB_WORKERCONTEXT", False) is None:
268 bb.fetch.fetcher_init(self.data)
269 bb.codeparser.parser_cache_init(self.data)
270
271 bb.event.fire(bb.event.ConfigParsed(), self.data)
272
273 if self.data.getVar("BB_INVALIDCONF", False) is True:
274 self.data.setVar("BB_INVALIDCONF", False)
275 self.data = self.parseConfigurationFiles(self.prefiles, self.postfiles)
276
277 bb.parse.init_parser(self.data)
278 self.data_hash = self.data.get_hash()
279 self.mcdata[''] = self.data
280
281 multiconfig = (self.data.getVar("BBMULTICONFIG", True) or "").split()
282 for config in multiconfig:
283 mcdata = self.parseConfigurationFiles(['conf/multiconfig/%s.conf' % config] + self.prefiles, self.postfiles)
284 bb.event.fire(bb.event.ConfigParsed(), mcdata)
285 self.mcdata[config] = mcdata
286
262 except SyntaxError: 287 except SyntaxError:
263 raise bb.BBHandledException 288 raise bb.BBHandledException
264 except bb.data_smart.ExpansionError as e: 289 except bb.data_smart.ExpansionError as e:
@@ -271,11 +296,8 @@ class CookerDataBuilder(object):
271 def _findLayerConf(self, data): 296 def _findLayerConf(self, data):
272 return findConfigFile("bblayers.conf", data) 297 return findConfigFile("bblayers.conf", data)
273 298
274 def parseConfigurationFiles(self): 299 def parseConfigurationFiles(self, prefiles, postfiles):
275 data = self.data 300 data = bb.data.createCopy(self.basedata)
276 prefiles = self.prefiles
277 postfiles = self.postfiles
278 bb.parse.init_parser(data)
279 301
280 # Parse files for loading *before* bitbake.conf and any includes 302 # Parse files for loading *before* bitbake.conf and any includes
281 for f in prefiles: 303 for f in prefiles:
@@ -338,20 +360,7 @@ class CookerDataBuilder(object):
338 handlerln = int(data.getVarFlag(var, "lineno", False)) 360 handlerln = int(data.getVarFlag(var, "lineno", False))
339 bb.event.register(var, data.getVar(var, False), (data.getVarFlag(var, "eventmask", True) or "").split(), handlerfn, handlerln) 361 bb.event.register(var, data.getVar(var, False), (data.getVarFlag(var, "eventmask", True) or "").split(), handlerfn, handlerln)
340 362
341 if data.getVar("BB_WORKERCONTEXT", False) is None:
342 bb.fetch.fetcher_init(data)
343 bb.codeparser.parser_cache_init(data)
344 bb.event.fire(bb.event.ConfigParsed(), data)
345
346 if data.getVar("BB_INVALIDCONF", False) is True:
347 data.setVar("BB_INVALIDCONF", False)
348 self.parseConfigurationFiles()
349 return
350
351 bb.parse.init_parser(data)
352 data.setVar('BBINCLUDED',bb.parse.get_file_depends(data)) 363 data.setVar('BBINCLUDED',bb.parse.get_file_depends(data))
353 self.data = data
354 self.data_hash = data.get_hash()
355
356 364
365 return data
357 366