summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Larson <chris_larson@mentor.com>2010-09-09 18:03:40 -0700
committerRichard Purdie <rpurdie@linux.intel.com>2011-01-04 14:46:35 +0000
commit9897d56861a3894e34bf77a62255dc57e680a18e (patch)
treec9ac420fedf434e693d364d70380fe1b9475bd86
parent1e7204a7b5b7b9a73759646fa0e297c7b4bc55ed (diff)
downloadpoky-9897d56861a3894e34bf77a62255dc57e680a18e.tar.gz
Simplify build exception handling
- Drop EventException - Use FuncFailed as the primary function failure exception, using TaskFailed for the event (leaving it up to the process running exec_{func,task} to display the more detailed information available in the exception). - Switch InvalidTask to an exception rather than an event, as that's a critical issue. - Reduce the number of messages shown to the user when a task fails -- they don't need to be told it fails 12 times. Work remains in this area though. (Bitbake rev: 06b742aae2b8013cbb269cc30554cff89e3a5667) Signed-off-by: Chris Larson <chris_larson@mentor.com> Signed-off-by: Richard Purdie <rpurdie@linux.intel.com>
-rw-r--r--bitbake/lib/bb/build.py52
-rw-r--r--bitbake/lib/bb/cooker.py8
-rw-r--r--bitbake/lib/bb/shell.py6
3 files changed, 30 insertions, 36 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py
index 9589313238..e800d5cf08 100644
--- a/bitbake/lib/bb/build.py
+++ b/bitbake/lib/bb/build.py
@@ -41,13 +41,17 @@ logger = logging.getLogger("BitBake.Build")
41__builtins__['bb'] = bb 41__builtins__['bb'] = bb
42__builtins__['os'] = os 42__builtins__['os'] = os
43 43
44# events
45class FuncFailed(Exception): 44class FuncFailed(Exception):
46 """ 45 def __init__(self, name, metadata, logfile = None):
47 Executed function failed 46 self.name = name
48 First parameter a message 47 self.metadata = metadata
49 Second paramter is a logfile (optional) 48 self.logfile = logfile
50 """ 49
50 def __str__(self):
51 msg = "Function '%s' failed" % self.name
52 if self.logfile:
53 msg += " (see %s for further information)" % self.logfile
54 return msg
51 55
52class TaskBase(event.Event): 56class TaskBase(event.Event):
53 """Base class for task events""" 57 """Base class for task events"""
@@ -74,13 +78,16 @@ class TaskSucceeded(TaskBase):
74 78
75class TaskFailed(TaskBase): 79class TaskFailed(TaskBase):
76 """Task execution failed""" 80 """Task execution failed"""
77 def __init__(self, msg, logfile, t, d ): 81
82 def __init__(self, task, logfile, metadata):
78 self.logfile = logfile 83 self.logfile = logfile
79 self.msg = msg 84 super(TaskFailed, self).__init__(task, metadata)
80 TaskBase.__init__(self, t, d)
81 85
82class TaskInvalid(TaskBase): 86class TaskInvalid(TaskBase):
83 """Invalid Task""" 87
88 def __init__(self, task, metadata):
89 super(TaskInvalid, self).__init__(task, metadata)
90 self._message = "No such task '%s'" % task
84 91
85# functions 92# functions
86 93
@@ -171,12 +178,11 @@ def exec_func_python(func, d, runfile, logfile):
171 comp = utils.better_compile(tmp, func, bbfile) 178 comp = utils.better_compile(tmp, func, bbfile)
172 try: 179 try:
173 utils.better_exec(comp, {"d": d}, tmp, bbfile) 180 utils.better_exec(comp, {"d": d}, tmp, bbfile)
174 except: 181 except Exception as exc:
175 (t, value, tb) = sys.exc_info() 182 if isinstance(exc, (bb.parse.SkipPackage, bb.build.FuncFailed)):
176
177 if t in [bb.parse.SkipPackage, bb.build.FuncFailed]:
178 raise 183 raise
179 raise FuncFailed("Function %s failed" % func, logfile) 184
185 raise FuncFailed(func, d, logfile)
180 186
181 187
182def exec_func_shell(func, d, runfile, logfile, flags): 188def exec_func_shell(func, d, runfile, logfile, flags):
@@ -207,7 +213,7 @@ def exec_func_shell(func, d, runfile, logfile, flags):
207 f.close() 213 f.close()
208 os.chmod(runfile, 0775) 214 os.chmod(runfile, 0775)
209 if not func: 215 if not func:
210 raise FuncFailed("Function not specified for exec_func_shell") 216 raise TypeError("Function argument must be a string")
211 217
212 # execute function 218 # execute function
213 if flags['fakeroot'] and not flags['task']: 219 if flags['fakeroot'] and not flags['task']:
@@ -219,7 +225,7 @@ def exec_func_shell(func, d, runfile, logfile, flags):
219 if ret == 0: 225 if ret == 0:
220 return 226 return
221 227
222 raise FuncFailed("function %s failed" % func, logfile) 228 raise FuncFailed(func, d, logfile)
223 229
224 230
225def exec_task(fn, task, d): 231def exec_task(fn, task, d):
@@ -310,16 +316,10 @@ def exec_task(fn, task, d):
310 if not data.getVarFlag(task, 'nostamp', d) and not data.getVarFlag(task, 'selfstamp', d): 316 if not data.getVarFlag(task, 'nostamp', d) and not data.getVarFlag(task, 'selfstamp', d):
311 make_stamp(task, d) 317 make_stamp(task, d)
312 318
313 except FuncFailed as message: 319 except FuncFailed as exc:
314 # Try to extract the optional logfile
315 try:
316 (msg, logfile) = message
317 except:
318 logfile = None
319 msg = message
320 if not quieterr: 320 if not quieterr:
321 logger.error("Task failed: %s" % message ) 321 logger.error(str(exc))
322 failedevent = TaskFailed(msg, logfile, task, d) 322 failedevent = TaskFailed(exc.name, exc.logfile, task, d)
323 event.fire(failedevent, d) 323 event.fire(failedevent, d)
324 return 1 324 return 1
325 325
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py
index de213f03f4..c1e2105c5e 100644
--- a/bitbake/lib/bb/cooker.py
+++ b/bitbake/lib/bb/cooker.py
@@ -690,9 +690,7 @@ class BBCooker:
690 try: 690 try:
691 retval = rq.execute_runqueue() 691 retval = rq.execute_runqueue()
692 except runqueue.TaskFailure as exc: 692 except runqueue.TaskFailure as exc:
693 for fnid in exc.args: 693 failures += len(exc.args)
694 buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
695 failures = failures + 1
696 retval = False 694 retval = False
697 if not retval: 695 if not retval:
698 bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) 696 bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data)
@@ -727,9 +725,7 @@ class BBCooker:
727 try: 725 try:
728 retval = rq.execute_runqueue() 726 retval = rq.execute_runqueue()
729 except runqueue.TaskFailure as exc: 727 except runqueue.TaskFailure as exc:
730 for fnid in exc.args: 728 failures += len(exc.args)
731 buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
732 failures = failures + 1
733 retval = False 729 retval = False
734 if not retval: 730 if not retval:
735 bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) 731 bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data)
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py
index f9ca9d5bd3..c61e93a1cb 100644
--- a/bitbake/lib/bb/shell.py
+++ b/bitbake/lib/bb/shell.py
@@ -180,11 +180,9 @@ class BitBakeShellCommands:
180 last_exception = Providers.NoProvider 180 last_exception = Providers.NoProvider
181 181
182 except runqueue.TaskFailure as fnids: 182 except runqueue.TaskFailure as fnids:
183 for fnid in fnids:
184 print("ERROR: '%s' failed" % td.fn_index[fnid])
185 last_exception = runqueue.TaskFailure 183 last_exception = runqueue.TaskFailure
186 184
187 except build.EventException as e: 185 except build.FuncFailed as e:
188 print("ERROR: Couldn't build '%s'" % names) 186 print("ERROR: Couldn't build '%s'" % names)
189 last_exception = e 187 last_exception = e
190 188
@@ -247,7 +245,7 @@ class BitBakeShellCommands:
247 cooker.buildFile(bf, cmd) 245 cooker.buildFile(bf, cmd)
248 except parse.ParseError: 246 except parse.ParseError:
249 print("ERROR: Unable to open or parse '%s'" % bf) 247 print("ERROR: Unable to open or parse '%s'" % bf)
250 except build.EventException as e: 248 except build.FuncFailed as e:
251 print("ERROR: Couldn't build '%s'" % name) 249 print("ERROR: Couldn't build '%s'" % name)
252 last_exception = e 250 last_exception = e
253 251