summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cache.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/cache.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/cache.py')
-rw-r--r--bitbake/lib/bb/cache.py53
1 files changed, 42 insertions, 11 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 5f302d68b4..0d5a034b53 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -248,6 +248,11 @@ def virtualfn2realfn(virtualfn):
248 """ 248 """
249 Convert a virtual file name to a real one + the associated subclass keyword 249 Convert a virtual file name to a real one + the associated subclass keyword
250 """ 250 """
251 mc = ""
252 if virtualfn.startswith('multiconfig:'):
253 elems = virtualfn.split(':')
254 mc = elems[1]
255 virtualfn = ":".join(elems[2:])
251 256
252 fn = virtualfn 257 fn = virtualfn
253 cls = "" 258 cls = ""
@@ -255,15 +260,32 @@ def virtualfn2realfn(virtualfn):
255 elems = virtualfn.split(':') 260 elems = virtualfn.split(':')
256 cls = ":".join(elems[1:-1]) 261 cls = ":".join(elems[1:-1])
257 fn = elems[-1] 262 fn = elems[-1]
258 return (fn, cls)
259 263
260def realfn2virtual(realfn, cls): 264 return (fn, cls, mc)
265
266def realfn2virtual(realfn, cls, mc):
267 """
268 Convert a real filename + the associated subclass keyword to a virtual filename
269 """
270 if cls:
271 realfn = "virtual:" + cls + ":" + realfn
272 if mc:
273 realfn = "multiconfig:" + mc + ":" + realfn
274 return realfn
275
276def variant2virtual(realfn, variant):
261 """ 277 """
262 Convert a real filename + the associated subclass keyword to a virtual filename 278 Convert a real filename + the associated subclass keyword to a virtual filename
263 """ 279 """
264 if cls == "": 280 if variant == "":
265 return realfn 281 return realfn
266 return "virtual:" + cls + ":" + realfn 282 if variant.startswith("multiconfig:"):
283 elems = variant.split(":")
284 if elems[2]:
285 return "multiconfig:" + elems[1] + ":virtual:" + ":".join(elems[2:]) + ":" + realfn
286 return "multiconfig:" + elems[1] + ":" + realfn
287 return "virtual:" + variant + ":" + realfn
288
267 289
268class NoCache(object): 290class NoCache(object):
269 291
@@ -277,7 +299,7 @@ class NoCache(object):
277 To do this, we need to parse the file. 299 To do this, we need to parse the file.
278 """ 300 """
279 logger.debug(1, "Parsing %s (full)" % virtualfn) 301 logger.debug(1, "Parsing %s (full)" % virtualfn)
280 (fn, virtual) = virtualfn2realfn(virtualfn) 302 (fn, virtual, mc) = virtualfn2realfn(virtualfn)
281 bb_data = self.load_bbfile(virtualfn, appends, virtonly=True) 303 bb_data = self.load_bbfile(virtualfn, appends, virtonly=True)
282 return bb_data[virtual] 304 return bb_data[virtual]
283 305
@@ -288,8 +310,8 @@ class NoCache(object):
288 """ 310 """
289 311
290 if virtonly: 312 if virtonly:
291 (bbfile, virtual) = virtualfn2realfn(bbfile) 313 (bbfile, virtual, mc) = virtualfn2realfn(bbfile)
292 bb_data = self.data.createCopy() 314 bb_data = self.databuilder.mcdata[mc].createCopy()
293 bb_data.setVar("__BBMULTICONFIG", mc) 315 bb_data.setVar("__BBMULTICONFIG", mc)
294 bb_data.setVar("__ONLYFINALISE", virtual or "default") 316 bb_data.setVar("__ONLYFINALISE", virtual or "default")
295 datastores = self._load_bbfile(bb_data, bbfile, appends) 317 datastores = self._load_bbfile(bb_data, bbfile, appends)
@@ -298,6 +320,15 @@ class NoCache(object):
298 bb_data = self.data.createCopy() 320 bb_data = self.data.createCopy()
299 datastores = self._load_bbfile(bb_data, bbfile, appends) 321 datastores = self._load_bbfile(bb_data, bbfile, appends)
300 322
323 for mc in self.databuilder.mcdata:
324 if not mc:
325 continue
326 bb_data = self.databuilder.mcdata[mc].createCopy()
327 bb_data.setVar("__BBMULTICONFIG", mc)
328 newstores = self._load_bbfile(bb_data, bbfile, appends)
329 for ns in newstores:
330 datastores["multiconfig:%s:%s" % (mc, ns)] = newstores[ns]
331
301 return datastores 332 return datastores
302 333
303 def _load_bbfile(self, bb_data, bbfile, appends): 334 def _load_bbfile(self, bb_data, bbfile, appends):
@@ -451,7 +482,7 @@ class Cache(NoCache):
451 for variant, data in sorted(datastores.items(), 482 for variant, data in sorted(datastores.items(),
452 key=lambda i: i[0], 483 key=lambda i: i[0],
453 reverse=True): 484 reverse=True):
454 virtualfn = realfn2virtual(filename, variant) 485 virtualfn = variant2virtual(filename, variant)
455 variants.append(variant) 486 variants.append(variant)
456 depends = depends + (data.getVar("__depends", False) or []) 487 depends = depends + (data.getVar("__depends", False) or [])
457 if depends and not variant: 488 if depends and not variant:
@@ -480,7 +511,7 @@ class Cache(NoCache):
480 # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo] 511 # info_array item is a list of [CoreRecipeInfo, XXXRecipeInfo]
481 info_array = self.depends_cache[filename] 512 info_array = self.depends_cache[filename]
482 for variant in info_array[0].variants: 513 for variant in info_array[0].variants:
483 virtualfn = realfn2virtual(filename, variant) 514 virtualfn = variant2virtual(filename, variant)
484 infos.append((virtualfn, self.depends_cache[virtualfn])) 515 infos.append((virtualfn, self.depends_cache[virtualfn]))
485 else: 516 else:
486 return self.parse(filename, appends, configdata, self.caches_array) 517 return self.parse(filename, appends, configdata, self.caches_array)
@@ -601,7 +632,7 @@ class Cache(NoCache):
601 632
602 invalid = False 633 invalid = False
603 for cls in info_array[0].variants: 634 for cls in info_array[0].variants:
604 virtualfn = realfn2virtual(fn, cls) 635 virtualfn = variant2virtual(fn, cls)
605 self.clean.add(virtualfn) 636 self.clean.add(virtualfn)
606 if virtualfn not in self.depends_cache: 637 if virtualfn not in self.depends_cache:
607 logger.debug(2, "Cache: %s is not cached", virtualfn) 638 logger.debug(2, "Cache: %s is not cached", virtualfn)
@@ -613,7 +644,7 @@ class Cache(NoCache):
613 # If any one of the variants is not present, mark as invalid for all 644 # If any one of the variants is not present, mark as invalid for all
614 if invalid: 645 if invalid:
615 for cls in info_array[0].variants: 646 for cls in info_array[0].variants:
616 virtualfn = realfn2virtual(fn, cls) 647 virtualfn = variant2virtual(fn, cls)
617 if virtualfn in self.clean: 648 if virtualfn in self.clean:
618 logger.debug(2, "Cache: Removing %s from cache", virtualfn) 649 logger.debug(2, "Cache: Removing %s from cache", virtualfn)
619 self.clean.remove(virtualfn) 650 self.clean.remove(virtualfn)