summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/cache.py
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-13 16:19:49 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2021-11-15 11:03:25 +0000
commitf07a097213477c4e4291e6dbcddd04300631f294 (patch)
tree5b424696cded82a6f469ed79a6080139c98535a4 /bitbake/lib/bb/cache.py
parent119c592530e82ab2a9bdddb532640c345b58cf8b (diff)
downloadpoky-f07a097213477c4e4291e6dbcddd04300631f294.tar.gz
bitbake: cache/ConfHandler: Drop TOPDIR/chdir manipulations
This code has been unchanged since 2006 apart from attempts to optimise performance by minimising chdir() calls. There is no reason the modern bitbake parser should be changing directory all the time. We did have some path assumptions in the mists of time but those were resovled and the code is deterministic and doesn't depend on cwd now for parsing. We can therefore drop the changes in directory. Also, TOPDIR is now being set by cookerdata in all cases so we don't need the fallbacks in this code (which was used to effectively initialise a value). We don't need to change TOPDIR when parsing a recipe, that makes no sense. If we stop all the other messing around, we don't need to expand TMPDIR either. These changes have the potential to break some obscure use cases such as an anonymous function assuming the current working directory, or some case which depends on TOPDIR changing but I believe any such uses should be fixed at this point. (Bitbake rev: add5d488e1d6607a98441836075d01cb1dc9c0fa) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/cache.py')
-rw-r--r--bitbake/lib/bb/cache.py29
1 files changed, 4 insertions, 25 deletions
diff --git a/bitbake/lib/bb/cache.py b/bitbake/lib/bb/cache.py
index 4e08c100ab..fcb15796cc 100644
--- a/bitbake/lib/bb/cache.py
+++ b/bitbake/lib/bb/cache.py
@@ -284,36 +284,15 @@ def parse_recipe(bb_data, bbfile, appends, mc=''):
284 Parse a recipe 284 Parse a recipe
285 """ 285 """
286 286
287 chdir_back = False
288
289 bb_data.setVar("__BBMULTICONFIG", mc) 287 bb_data.setVar("__BBMULTICONFIG", mc)
290 288
291 # expand tmpdir to include this topdir
292 bb_data.setVar('TMPDIR', bb_data.getVar('TMPDIR') or "")
293 bbfile_loc = os.path.abspath(os.path.dirname(bbfile)) 289 bbfile_loc = os.path.abspath(os.path.dirname(bbfile))
294 oldpath = os.path.abspath(os.getcwd())
295 bb.parse.cached_mtime_noerror(bbfile_loc) 290 bb.parse.cached_mtime_noerror(bbfile_loc)
296 291
297 # The ConfHandler first looks if there is a TOPDIR and if not 292 if appends:
298 # then it would call getcwd(). 293 bb_data.setVar('__BBAPPEND', " ".join(appends))
299 # Previously, we chdir()ed to bbfile_loc, called the handler 294 bb_data = bb.parse.handle(bbfile, bb_data)
300 # and finally chdir()ed back, a couple of thousand times. We now 295 return bb_data
301 # just fill in TOPDIR to point to bbfile_loc if there is no TOPDIR yet.
302 if not bb_data.getVar('TOPDIR', False):
303 chdir_back = True
304 bb_data.setVar('TOPDIR', bbfile_loc)
305 try:
306 if appends:
307 bb_data.setVar('__BBAPPEND', " ".join(appends))
308 bb_data = bb.parse.handle(bbfile, bb_data)
309 if chdir_back:
310 os.chdir(oldpath)
311 return bb_data
312 except:
313 if chdir_back:
314 os.chdir(oldpath)
315 raise
316
317 296
318 297
319class NoCache(object): 298class NoCache(object):