diff options
author | Chris Larson <chris_larson@mentor.com> | 2010-12-09 20:29:31 -0500 |
---|---|---|
committer | Richard Purdie <rpurdie@linux.intel.com> | 2011-01-04 14:46:48 +0000 |
commit | e2363f3cdddb597c0321b6c396306be966ac58f9 (patch) | |
tree | cef6f4fd59a91c558a528b841c3159f264f68234 /bitbake/lib/bb/build.py | |
parent | b4eff9fcefe2fefab1caaf22e497317e9338063e (diff) | |
download | openembedded-core-e2363f3cdddb597c0321b6c396306be966ac58f9.tar.gz openembedded-core-e2363f3cdddb597c0321b6c396306be966ac58f9.tar.bz2 openembedded-core-e2363f3cdddb597c0321b6c396306be966ac58f9.zip |
build: use a contextmanager for locks
Also don't bother passing logfile to exec_func_python, at least until we start
adding the logfile as a file handler to the bitbake logger.
(Bitbake rev: f99ee4680c9f67b7ed13fc06044ba2382f9a782c)
Signed-off-by: Chris Larson <chris_larson@mentor.com>
Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r-- | bitbake/lib/bb/build.py | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index 79fb1def9b..5d07b06640 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py @@ -25,13 +25,14 @@ # #Based on functions from the base bb module, Copyright 2003 Holger Schurig -from bb import data, event, mkdirhier, utils import os import sys import logging import bb import bb.utils import bb.process +from contextlib import nested +from bb import data, event, mkdirhier, utils logger = logging.getLogger("BitBake.Build") @@ -142,26 +143,21 @@ def exec_func(func, d, dirs = None, logfile = NULL): if flags.get('fakeroot') and not flags.get('task'): bb.fatal("Function %s specifies fakeroot but isn't a task?!" % func) + lockflag = flags.get('lockfiles') + if lockflag: + lockfiles = [data.expand(f, d) for f in lockflag.split()] + else: + lockfiles = None + tempdir = data.getVar('T', d, 1) runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid())) - locks = [] - lockfiles = flags.get('lockfiles') - if lockfiles: - for lock in data.expand(lockfiles, d).split(): - locks.append(bb.utils.lockfile(lock)) - - try: + with bb.utils.fileslocked(lockfiles): if ispython: exec_func_python(func, d, runfile, logfile, cwd=adir) else: exec_func_shell(func, d, runfile, logfile, cwd=adir) - finally: - # Unlock any lockfiles - for lock in locks: - bb.utils.unlockfile(lock) - _functionfmt = """ def {function}(d): {body} |