summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cache.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-08-30 20:45:09 +1200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-09-02 18:09:48 +0100
commit818a36590a74ad6c461e3af538f405be6a9ef6f0 (patch)
tree677995c4b70af72959b235075d0a03892985216a /bitbake/lib/bb/cache.py
parentf551e67fa79810ac82d5a226a328b8d79ba725fe (diff)
downloadpoky-818a36590a74ad6c461e3af538f405be6a9ef6f0.tar.gz
bitbake: cache: allow parsing a recipe with a custom config datastore
To accommodate the OpenEmbedded layer index recipe parsing, we have to have the ability to pass in a custom config datastore since it constructs a synthetic one. To make this possible after the multi-config changes, rename the internal _load_bbfile() function to parse_recipe(), make it a function at the module level (since it doesn't actually need to access any members of the class or instance) and move setting __BBMULTICONFIG inside it since other code will expect that to be set. Part of the fix for [YOCTO #10192]. (Bitbake rev: 5b3fedfe0822dd7effa4b6d5e96eaf42669a71df) Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r--bitbake/lib/bb/cache.py73
1 files changed, 39 insertions, 34 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 0d5a034b53..dd9cfdfacf 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -286,6 +286,42 @@ def variant2virtual(realfn, variant):
286 return "multiconfig:" + elems[1] + ":" + realfn 286 return "multiconfig:" + elems[1] + ":" + realfn
287 return "virtual:" + variant + ":" + realfn 287 return "virtual:" + variant + ":" + realfn
288 288
289def parse_recipe(bb_data, bbfile, appends, mc=''):
290 """
291 Parse a recipe
292 """
293
294 chdir_back = False
295
296 bb_data.setVar("__BBMULTICONFIG", mc)
297
298 # expand tmpdir to include this topdir
299 bb_data.setVar('TMPDIR', bb_data.getVar('TMPDIR', True) or "")
300 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
301 oldpath = os.path.abspath(os.getcwd())
302 bb.parse.cached_mtime_noerror(bbfile_loc)
303
304 # The ConfHandler first looks if there is a TOPDIR and if not
305 # then it would call getcwd().
306 # Previously, we chdir()ed to bbfile_loc, called the handler
307 # and finally chdir()ed back, a couple of thousand times. We now
308 # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
309 if not bb_data.getVar('TOPDIR', False):
310 chdir_back = True
311 bb_data.setVar('TOPDIR', bbfile_loc)
312 try:
313 if appends:
314 bb_data.setVar('__BBAPPEND', " ".join(appends))
315 bb_data = bb.parse.handle(bbfile, bb_data)
316 if chdir_back:
317 os.chdir(oldpath)
318 return bb_data
319 except:
320 if chdir_back:
321 os.chdir(oldpath)
322 raise
323
324
289 325
290class NoCache(object): 326class NoCache(object):
291 327
@@ -312,54 +348,23 @@ class NoCache(object):
312 if virtonly: 348 if virtonly:
313 (bbfile, virtual, mc) = virtualfn2realfn(bbfile) 349 (bbfile, virtual, mc) = virtualfn2realfn(bbfile)
314 bb_data = self.databuilder.mcdata[mc].createCopy() 350 bb_data = self.databuilder.mcdata[mc].createCopy()
315 bb_data.setVar("__BBMULTICONFIG", mc)
316 bb_data.setVar("__ONLYFINALISE", virtual or "default") 351 bb_data.setVar("__ONLYFINALISE", virtual or "default")
317 datastores = self._load_bbfile(bb_data, bbfile, appends) 352 datastores = parse_recipe(bb_data, bbfile, appends, mc)
318 return datastores 353 return datastores
319 354
320 bb_data = self.data.createCopy() 355 bb_data = self.data.createCopy()
321 datastores = self._load_bbfile(bb_data, bbfile, appends) 356 datastores = parse_recipe(bb_data, bbfile, appends)
322 357
323 for mc in self.databuilder.mcdata: 358 for mc in self.databuilder.mcdata:
324 if not mc: 359 if not mc:
325 continue 360 continue
326 bb_data = self.databuilder.mcdata[mc].createCopy() 361 bb_data = self.databuilder.mcdata[mc].createCopy()
327 bb_data.setVar("__BBMULTICONFIG", mc) 362 newstores = parse_recipe(bb_data, bbfile, appends, mc)
328 newstores = self._load_bbfile(bb_data, bbfile, appends)
329 for ns in newstores: 363 for ns in newstores:
330 datastores["multiconfig:%s:%s" % (mc, ns)] = newstores[ns] 364 datastores["multiconfig:%s:%s" % (mc, ns)] = newstores[ns]
331 365
332 return datastores 366 return datastores
333 367
334 def _load_bbfile(self, bb_data, bbfile, appends):
335 chdir_back = False
336
337 # expand tmpdir to include this topdir
338 bb_data.setVar('TMPDIR', bb_data.getVar('TMPDIR', True) or "")
339 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
340 oldpath = os.path.abspath(os.getcwd())
341 bb.parse.cached_mtime_noerror(bbfile_loc)
342
343 # The ConfHandler first looks if there is a TOPDIR and if not
344 # then it would call getcwd().
345 # Previously, we chdir()ed to bbfile_loc, called the handler
346 # and finally chdir()ed back, a couple of thousand times. We now
347 # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
348 if not bb_data.getVar('TOPDIR', False):
349 chdir_back = True
350 bb_data.setVar('TOPDIR', bbfile_loc)
351 try:
352 if appends:
353 bb_data.setVar('__BBAPPEND', " ".join(appends))
354 bb_data = bb.parse.handle(bbfile, bb_data)
355 if chdir_back:
356 os.chdir(oldpath)
357 return bb_data
358 except:
359 if chdir_back:
360 os.chdir(oldpath)
361 raise
362
363class Cache(NoCache): 368class Cache(NoCache):
364 """ 369 """
365 BitBake Cache implementation 370 BitBake Cache implementation