summaryrefslogtreecommitdiff
path: root/bitbake/lib
diff options
context:
space:
mode:
authorBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2010-06-04 14:04:42 +0200
committerRichard Purdie <rpurdie@linux.intel.com>2010-07-02 15:41:35 +0100
commit16553b88267bd1b3ad42b2d319d380251b4d6943 (patch)
tree28ff7cae842cbcf493c1044fd9e5a7bb70b9dae0 /bitbake/lib
parent726802b98071f6139c9305be0383a2be20a37f4e (diff)
downloadopenembedded-core-16553b88267bd1b3ad42b2d319d380251b4d6943.tar.gz
openembedded-core-16553b88267bd1b3ad42b2d319d380251b4d6943.tar.bz2
openembedded-core-16553b88267bd1b3ad42b2d319d380251b4d6943.zip
cache: do not chdir unnecessarily
previously we called chdir() twice for every target, this patch reduces the amount of chdir() calls via openembedded master from some 16000 to 4. (Bitbake rev: fa45f5625e13a82bec70d5f10815f52fbe705166) Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib')
-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:
Load and parse one .bb build file
Return the data and whether parsing resulted in the file being skipped
"""
+ chdir_back = False
from bb import data, parse
@@ -451,15 +452,22 @@ class Cache:
data.setVar('TMPDIR', data.getVar('TMPDIR', config, 1) or "", config)
bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
oldpath = os.path.abspath(os.getcwd())
- if parse.cached_mtime_noerror(bbfile_loc):
- os.chdir(bbfile_loc)
+ parse.cached_mtime_noerror(bbfile_loc)
bb_data = data.init_db(config)
+ # The ConfHandler first looks if there is a TOPDIR and if not
+ # then it would call getcwd().
+ # Previously, we chdir()ed to bbfile_loc, called the handler
+ # and finally chdir()ed back, a couple of thousand times. We now
+ # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
+ if not data.getVar('TOPDIR', bb_data):
+ chdir_back = True
+ data.setVar('TOPDIR', bbfile_loc, bb_data)
try:
bb_data = parse.handle(bbfile, bb_data) # read .bb data
- os.chdir(oldpath)
+ if chdir_back: os.chdir(oldpath)
return bb_data
except:
- os.chdir(oldpath)
+ if chdir_back: os.chdir(oldpath)
raise
def init(cooker):