summaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/build.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/build.py')
-rw-r--r--bitbake/lib/bb/build.py52
1 files changed, 26 insertions, 26 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