summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/data.py4
-rw-r--r--bitbake/lib/bb/methodpool.py1
-rw-r--r--bitbake/lib/bb/parse/parse_py/BBHandler.py77
-rw-r--r--bitbake/lib/bb/runqueue.py72
-rw-r--r--bitbake/lib/bb/shell.py5
5 files changed, 88 insertions, 71 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py
index 19066c9adc..9f7e4be4c8 100644
--- a/bitbake/lib/bb/data.py
+++ b/bitbake/lib/bb/data.py
@@ -542,8 +542,8 @@ def update_data(d):
542 542
543 543
544def inherits_class(klass, d): 544def inherits_class(klass, d):
545 val = getVar('__inherit_cache', d) or "" 545 val = getVar('__inherit_cache', d) or []
546 if os.path.join('classes', '%s.bbclass' % klass) in val.split(): 546 if os.path.join('classes', '%s.bbclass' % klass) in val:
547 return True 547 return True
548 return False 548 return False
549 549
diff --git a/bitbake/lib/bb/methodpool.py b/bitbake/lib/bb/methodpool.py
index e14986bc19..f0565ce790 100644
--- a/bitbake/lib/bb/methodpool.py
+++ b/bitbake/lib/bb/methodpool.py
@@ -83,6 +83,7 @@ def check_insert_method(modulename, code, fn):
83 """ 83 """
84 if not modulename in _parsed_methods: 84 if not modulename in _parsed_methods:
85 return insert_method(modulename, code, fn) 85 return insert_method(modulename, code, fn)
86 _parsed_methods[modulename] = 1
86 87
87def parsed_module(modulename): 88def parsed_module(modulename):
88 """ 89 """
diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py
index 34f4d25996..42b0369428 100644
--- a/bitbake/lib/bb/parse/parse_py/BBHandler.py
+++ b/bitbake/lib/bb/parse/parse_py/BBHandler.py
@@ -40,7 +40,6 @@ __word__ = re.compile(r"\S+")
40__infunc__ = "" 40__infunc__ = ""
41__inpython__ = False 41__inpython__ = False
42__body__ = [] 42__body__ = []
43__bbpath_found__ = 0
44__classname__ = "" 43__classname__ = ""
45classes = [ None, ] 44classes = [ None, ]
46 45
@@ -58,25 +57,24 @@ def supports(fn, d):
58 return localfn[-3:] == ".bb" or localfn[-8:] == ".bbclass" or localfn[-4:] == ".inc" 57 return localfn[-3:] == ".bb" or localfn[-8:] == ".bbclass" or localfn[-4:] == ".inc"
59 58
60def inherit(files, d): 59def inherit(files, d):
61 __inherit_cache = data.getVar('__inherit_cache', d) or "" 60 __inherit_cache = data.getVar('__inherit_cache', d) or []
62 fn = "" 61 fn = ""
63 lineno = 0 62 lineno = 0
64 for f in files: 63 files = data.expand(files, d)
65 file = data.expand(f, d) 64 for file in files:
66 if file[0] != "/" and file[-8:] != ".bbclass": 65 if file[0] != "/" and file[-8:] != ".bbclass":
67 file = os.path.join('classes', '%s.bbclass' % file) 66 file = os.path.join('classes', '%s.bbclass' % file)
68 67
69 if not file in __inherit_cache.split(): 68 if not file in __inherit_cache:
70 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) 69 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file))
71 __inherit_cache += " %s" % file 70 __inherit_cache.append( file )
72 include(fn, file, d, "inherit") 71 include(fn, file, d, "inherit")
73 data.setVar('__inherit_cache', __inherit_cache, d) 72 data.setVar('__inherit_cache', __inherit_cache, d)
74 73
75 74
76def handle(fn, d, include = 0): 75def handle(fn, d, include = 0):
77 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __bbpath_found__, __residue__ 76 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__
78 __body__ = [] 77 __body__ = []
79 __bbpath_found__ = 0
80 __infunc__ = "" 78 __infunc__ = ""
81 __classname__ = "" 79 __classname__ = ""
82 __residue__ = [] 80 __residue__ = []
@@ -104,7 +102,6 @@ def handle(fn, d, include = 0):
104 if not os.path.isabs(fn): 102 if not os.path.isabs(fn):
105 f = None 103 f = None
106 for p in bbpath: 104 for p in bbpath:
107 p = data.expand(p, d)
108 j = os.path.join(p, fn) 105 j = os.path.join(p, fn)
109 if os.access(j, os.R_OK): 106 if os.access(j, os.R_OK):
110 abs_fn = j 107 abs_fn = j
@@ -147,39 +144,35 @@ def handle(fn, d, include = 0):
147 data.expandKeys(d) 144 data.expandKeys(d)
148 data.update_data(d) 145 data.update_data(d)
149 anonqueue = data.getVar("__anonqueue", d, 1) or [] 146 anonqueue = data.getVar("__anonqueue", d, 1) or []
150 for anon in anonqueue: 147 body = [x['content'] for x in anonqueue]
151 data.setVar("__anonfunc", anon["content"], d) 148 flag = { 'python' : 1, 'func' : 1 }
152 data.setVarFlags("__anonfunc", anon["flags"], d) 149 data.setVar("__anonfunc", "\n".join(body), d)
153 from bb import build 150 data.setVarFlags("__anonfunc", flag, d)
154 try: 151 from bb import build
155 t = data.getVar('T', d) 152 try:
156 data.setVar('T', '${TMPDIR}/', d) 153 t = data.getVar('T', d)
157 build.exec_func("__anonfunc", d) 154 data.setVar('T', '${TMPDIR}/', d)
158 data.delVar('T', d) 155 build.exec_func("__anonfunc", d)
159 if t: 156 data.delVar('T', d)
160 data.setVar('T', t, d) 157 if t:
161 except Exception, e: 158 data.setVar('T', t, d)
162 bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e) 159 except Exception, e:
163 raise 160 bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e)
161 raise
164 data.delVar("__anonqueue", d) 162 data.delVar("__anonqueue", d)
165 data.delVar("__anonfunc", d) 163 data.delVar("__anonfunc", d)
166 set_additional_vars(fn, d, include) 164 set_additional_vars(fn, d, include)
167 data.update_data(d) 165 data.update_data(d)
168 166
169 all_handlers = {} 167 all_handlers = {}
170 for var in data.keys(d): 168 for var in data.getVar('__BBHANDLERS', d) or []:
171 # try to add the handler 169 # try to add the handler
172 # if we added it remember the choiche 170 # if we added it remember the choiche
173 if data.getVarFlag(var, 'handler', d): 171 handler = data.getVar(var,d)
174 handler = data.getVar(var,d) 172 if bb.event.register(var,handler) == bb.event.Registered:
175 if bb.event.register(var,handler) == bb.event.Registered: 173 all_handlers[var] = handler
176 all_handlers[var] = handler
177
178 continue
179
180 if not data.getVarFlag(var, 'task', d):
181 continue
182 174
175 for var in data.getVar('__BBTASKS', d) or []:
183 deps = data.getVarFlag(var, 'deps', d) or [] 176 deps = data.getVarFlag(var, 'deps', d) or []
184 postdeps = data.getVarFlag(var, 'postdeps', d) or [] 177 postdeps = data.getVarFlag(var, 'postdeps', d) or []
185 bb.build.add_task(var, deps, d) 178 bb.build.add_task(var, deps, d)
@@ -204,7 +197,7 @@ def handle(fn, d, include = 0):
204 return d 197 return d
205 198
206def feeder(lineno, s, fn, root, d): 199def feeder(lineno, s, fn, root, d):
207 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, __bbpath_found__, classes, bb, __residue__ 200 global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__
208 if __infunc__: 201 if __infunc__:
209 if s == '}': 202 if s == '}':
210 __body__.append('') 203 __body__.append('')
@@ -336,6 +329,10 @@ def feeder(lineno, s, fn, root, d):
336 329
337 data.setVarFlag(var, "task", 1, d) 330 data.setVarFlag(var, "task", 1, d)
338 331
332 bbtasks = data.getVar('__BBTASKS', d) or []
333 bbtasks.append(var)
334 data.setVar('__BBTASKS', bbtasks, d)
335
339 if after is not None: 336 if after is not None:
340# set up deps for function 337# set up deps for function
341 data.setVarFlag(var, "deps", after.split(), d) 338 data.setVarFlag(var, "deps", after.split(), d)
@@ -348,8 +345,11 @@ def feeder(lineno, s, fn, root, d):
348 if m: 345 if m:
349 fns = m.group(1) 346 fns = m.group(1)
350 hs = __word__.findall(fns) 347 hs = __word__.findall(fns)
348 bbhands = data.getVar('__BBHANDLERS', d) or []
351 for h in hs: 349 for h in hs:
350 bbhands.append(h)
352 data.setVarFlag(h, "handler", 1, d) 351 data.setVarFlag(h, "handler", 1, d)
352 data.setVar('__BBHANDLERS', bbhands, d)
353 return 353 return
354 354
355 m = __inherit_regexp__.match(s) 355 m = __inherit_regexp__.match(s)
@@ -386,16 +386,11 @@ def set_additional_vars(file, d, include):
386 386
387 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file) 387 bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file)
388 388
389 src_uri = data.getVar('SRC_URI', d) 389 src_uri = data.getVar('SRC_URI', d, 1)
390 if not src_uri: 390 if not src_uri:
391 return 391 return
392 src_uri = data.expand(src_uri, d)
393 392
394 a = data.getVar('A', d) 393 a = (data.getVar('A', d, 1) or '').split()
395 if a:
396 a = data.expand(a, d).split()
397 else:
398 a = []
399 394
400 from bb import fetch 395 from bb import fetch
401 try: 396 try:
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py
index 3dde9a9ffb..07821e23de 100644
--- a/bitbake/lib/bb/runqueue.py
+++ b/bitbake/lib/bb/runqueue.py
@@ -1,4 +1,4 @@
1 #!/usr/bin/env python 1#!/usr/bin/env python
2# ex:ts=4:sw=4:sts=4:et 2# ex:ts=4:sw=4:sts=4:et
3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- 3# -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*-
4""" 4"""
@@ -25,9 +25,8 @@ import bb, os, sys
25 25
26class TaskFailure(Exception): 26class TaskFailure(Exception):
27 """Exception raised when a task in a runqueue fails""" 27 """Exception raised when a task in a runqueue fails"""
28 28 def __init__(self, x):
29 def __init__(self, fnid, fn, taskname): 29 self.args = x
30 self.args = fnid, fn, taskname
31 30
32class RunQueue: 31class RunQueue:
33 """ 32 """
@@ -319,21 +318,23 @@ class RunQueue:
319 318
320 failures = 0 319 failures = 0
321 while 1: 320 while 1:
322 try: 321 failed_fnids = self.execute_runqueue_internal(cooker, cfgData, dataCache, taskData)
323 self.execute_runqueue_internal(cooker, cfgData, dataCache, taskData) 322 if len(failed_fnids) == 0:
324 return failures 323 return failures
325 except bb.runqueue.TaskFailure, (fnid, taskData.fn_index[fnid], taskname): 324 if taskData.abort:
326 if taskData.abort: 325 raise bb.runqueue.TaskFailure(failed_fnids)
327 raise 326 for fnid in failed_fnids:
327 #print "Failure: %s %s %s" % (fnid, taskData.fn_index[fnid], self.runq_task[fnid])
328 taskData.fail_fnid(fnid) 328 taskData.fail_fnid(fnid)
329 self.reset_runqueue()
330 self.prepare_runqueue(cfgData, dataCache, taskData, runlist)
331 failures = failures + 1 329 failures = failures + 1
330 self.reset_runqueue()
331 self.prepare_runqueue(cfgData, dataCache, taskData, runlist)
332 332
333 def execute_runqueue_internal(self, cooker, cfgData, dataCache, taskData): 333 def execute_runqueue_internal(self, cooker, cfgData, dataCache, taskData):
334 """ 334 """
335 Run the tasks in a queue prepared by prepare_runqueue 335 Run the tasks in a queue prepared by prepare_runqueue
336 """ 336 """
337 import signal
337 338
338 bb.msg.note(1, bb.msg.domain.RunQueue, "Executing runqueue") 339 bb.msg.note(1, bb.msg.domain.RunQueue, "Executing runqueue")
339 340
@@ -342,11 +343,15 @@ class RunQueue:
342 runq_complete = [] 343 runq_complete = []
343 active_builds = 0 344 active_builds = 0
344 build_pids = {} 345 build_pids = {}
346 failed_fnids = []
345 347
346 if len(self.runq_fnid) == 0: 348 if len(self.runq_fnid) == 0:
347 # nothing to do 349 # nothing to do
348 return 350 return
349 351
352 def sigint_handler(signum, frame):
353 raise KeyboardInterrupt
354
350 def get_next_task(data): 355 def get_next_task(data):
351 """ 356 """
352 Return the id of the highest priority task that is buildable 357 Return the id of the highest priority task that is buildable
@@ -414,6 +419,11 @@ class RunQueue:
414 except OSError, e: 419 except OSError, e:
415 bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror)) 420 bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror))
416 if pid == 0: 421 if pid == 0:
422 # Bypass finally below
423 active_builds = 0
424 # Stop Ctrl+C being sent to children
425 signal.signal(signal.SIGINT, signal.SIG_IGN)
426 sys.stdin = open('/dev/null', 'r')
417 cooker.configuration.cmd = taskname[3:] 427 cooker.configuration.cmd = taskname[3:]
418 try: 428 try:
419 cooker.tryBuild(fn, False) 429 cooker.tryBuild(fn, False)
@@ -434,26 +444,36 @@ class RunQueue:
434 active_builds = active_builds - 1 444 active_builds = active_builds - 1
435 task = build_pids[result[0]] 445 task = build_pids[result[0]]
436 if result[1] != 0: 446 if result[1] != 0:
447 del build_pids[result[0]]
437 bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task, taskData))) 448 bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task, taskData)))
438 raise bb.runqueue.TaskFailure(self.runq_fnid[task], taskData.fn_index[self.runq_fnid[task]], self.runq_task[task]) 449 failed_fnids.append(self.runq_fnid[task])
450 break
439 task_complete(self, task) 451 task_complete(self, task)
440 del build_pids[result[0]] 452 del build_pids[result[0]]
441 continue 453 continue
442 break 454 break
443 except SystemExit: 455 finally:
444 raise 456 try:
445 except: 457 while active_builds > 0:
446 bb.msg.error(bb.msg.domain.RunQueue, "Exception received") 458 bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % active_builds)
447 while active_builds > 0: 459 tasknum = 1
448 bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % active_builds) 460 for k, v in build_pids.iteritems():
449 tasknum = 1 461 bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k))
462 tasknum = tasknum + 1
463 result = os.waitpid(-1, 0)
464 task = build_pids[result[0]]
465 if result[1] != 0:
466 bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task, taskData)))
467 failed_fnids.append(self.runq_fnid[task])
468 del build_pids[result[0]]
469 active_builds = active_builds - 1
470 if len(failed_fnids) > 0:
471 return failed_fnids
472 except:
473 bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGTERM to remaining %s tasks" % active_builds)
450 for k, v in build_pids.iteritems(): 474 for k, v in build_pids.iteritems():
451 bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k)) 475 os.kill(k, signal.SIGTERM)
452 tasknum = tasknum + 1 476 raise
453 result = os.waitpid(-1, 0)
454 del build_pids[result[0]]
455 active_builds = active_builds - 1
456 raise
457 477
458 # Sanity Checks 478 # Sanity Checks
459 for task in range(len(self.runq_fnid)): 479 for task in range(len(self.runq_fnid)):
@@ -464,7 +484,7 @@ class RunQueue:
464 if runq_complete[task] == 0: 484 if runq_complete[task] == 0:
465 bb.msg.error(bb.msg.domain.RunQueue, "Task %s never completed!" % task) 485 bb.msg.error(bb.msg.domain.RunQueue, "Task %s never completed!" % task)
466 486
467 return 0 487 return failed_fnids
468 488
469 def dump_data(self, taskQueue): 489 def dump_data(self, taskQueue):
470 """ 490 """
diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py
index 760c371d90..711cd4335f 100644
--- a/bitbake/lib/bb/shell.py
+++ b/bitbake/lib/bb/shell.py
@@ -179,8 +179,9 @@ class BitBakeShellCommands:
179 global last_exception 179 global last_exception
180 last_exception = Providers.NoProvider 180 last_exception = Providers.NoProvider
181 181
182 except runqueue.TaskFailure, (fnid, fn, taskname): 182 except runqueue.TaskFailure, fnids:
183 print "ERROR: '%s, %s' failed" % (fn, taskname) 183 for fnid in fnids:
184 print "ERROR: '%s' failed" % td.fn_index[fnid])
184 global last_exception 185 global last_exception
185 last_exception = runqueue.TaskFailure 186 last_exception = runqueue.TaskFailure
186 187