summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cache.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r--bitbake/lib/bb/cache.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 59ea8cfc7b..f77a3f185e 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -444,6 +444,7 @@ class Cache:
444 Load and parse one .bb build file 444 Load and parse one .bb build file
445 Return the data and whether parsing resulted in the file being skipped 445 Return the data and whether parsing resulted in the file being skipped
446 """ 446 """
447 chdir_back = False
447 448
448 from bb import data, parse 449 from bb import data, parse
449 450
@@ -451,15 +452,22 @@ class Cache:
451 data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config) 452 data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
452 bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) 453 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
453 oldpath = os.path.abspath(os.getcwd()) 454 oldpath = os.path.abspath(os.getcwd())
454 if parse.cached_mtime_noerror(bbfile_loc): 455 parse.cached_mtime_noerror(bbfile_loc)
455 os.chdir(bbfile_loc)
456 bb_data = data.init_db(config) 456 bb_data = data.init_db(config)
457 # The ConfHandler first looks if there is a TOPDIR and if not
458 # then it would call getcwd().
459 # Previously, we chdir()ed to bbfile_loc, called the handler
460 # and finally chdir()ed back, a couple of thousand times. We now
461 # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
462 if not data.getVar('TOPDIR', bb_data):
463 chdir_back = True
464 data.setVar('TOPDIR', bbfile_loc, bb_data)
457 try: 465 try:
458 bb_data = parse.handle(bbfile, bb_data) # read .bb data 466 bb_data = parse.handle(bbfile, bb_data) # read .bb data
459 os.chdir(oldpath) 467 if chdir_back: os.chdir(oldpath)
460 return bb_data 468 return bb_data
461 except: 469 except:
462 os.chdir(oldpath) 470 if chdir_back: os.chdir(oldpath)
463 raise 471 raise
464 472
465def init(cooker): 473def init(cooker):