summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-12-09 20:29:31 -0500
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:48 +0000
commite2363f3cdddb597c0321b6c396306be966ac58f9 (patch)
treecef6f4fd59a91c558a528b841c3159f264f68234 /bitbake/lib/bb/build.py
parentb4eff9fcefe2fefab1caaf22e497317e9338063e (diff)
downloadpoky-e2363f3cdddb597c0321b6c396306be966ac58f9.tar.gz
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.py22
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 @@
25# 25#
26#Based on functions from the base bb module, Copyright 2003 Holger Schurig 26#Based on functions from the base bb module, Copyright 2003 Holger Schurig
27 27
28from bb import data, event, mkdirhier, utils
29import os 28import os
30import sys 29import sys
31import logging 30import logging
32import bb 31import bb
33import bb.utils 32import bb.utils
34import bb.process 33import bb.process
34from contextlib import nested
35from bb import data, event, mkdirhier, utils
35 36
36logger = logging.getLogger("BitBake.Build") 37logger = logging.getLogger("BitBake.Build")
37 38
@@ -142,26 +143,21 @@ def exec_func(func, d, dirs = None, logfile = NULL):
142 if flags.get('fakeroot') and not flags.get('task'): 143 if flags.get('fakeroot') and not flags.get('task'):
143 bb.fatal("Function %s specifies fakeroot but isn't a task?!" % func) 144 bb.fatal("Function %s specifies fakeroot but isn't a task?!" % func)
144 145
146 lockflag = flags.get('lockfiles')
147 if lockflag:
148 lockfiles = [data.expand(f, d) for f in lockflag.split()]
149 else:
150 lockfiles = None
151
145 tempdir = data.getVar('T', d, 1) 152 tempdir = data.getVar('T', d, 1)
146 runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid())) 153 runfile = os.path.join(tempdir, 'run.{0}.{1}'.format(func, os.getpid()))
147 154
148 locks = [] 155 with bb.utils.fileslocked(lockfiles):
149 lockfiles = flags.get('lockfiles')
150 if lockfiles:
151 for lock in data.expand(lockfiles, d).split():
152 locks.append(bb.utils.lockfile(lock))
153
154 try:
155 if ispython: 156 if ispython:
156 exec_func_python(func, d, runfile, logfile, cwd=adir) 157 exec_func_python(func, d, runfile, logfile, cwd=adir)
157 else: 158 else:
158 exec_func_shell(func, d, runfile, logfile, cwd=adir) 159 exec_func_shell(func, d, runfile, logfile, cwd=adir)
159 160
160 finally:
161 # Unlock any lockfiles
162 for lock in locks:
163 bb.utils.unlockfile(lock)
164
165_functionfmt = """ 161_functionfmt = """
166def {function}(d): 162def {function}(d):
167{body} 163{body}