diff options
author | Richard Purdie <richard@openedhand.com> | 2006-11-29 22:52:37 +0000 |
---|---|---|
committer | Richard Purdie <richard@openedhand.com> | 2006-11-29 22:52:37 +0000 |
commit | 681d6c18ad59dac9e53f769a568835241d7fa9b7 (patch) | |
tree | 243418a546b89650d28580f7721b8324586146e4 /bitbake/lib | |
parent | adabf6c0931af1282a7c75321cd8b050e8d05c95 (diff) | |
download | openembedded-core-681d6c18ad59dac9e53f769a568835241d7fa9b7.tar.gz openembedded-core-681d6c18ad59dac9e53f769a568835241d7fa9b7.tar.bz2 openembedded-core-681d6c18ad59dac9e53f769a568835241d7fa9b7.tar.xz openembedded-core-681d6c18ad59dac9e53f769a568835241d7fa9b7.zip |
bitbake: Sync with bitbake trunk for bugfixes and improved dot file generation code
git-svn-id: https://svn.o-hand.com/repos/poky/trunk@987 311d38ba-8fff-0310-9ca6-ca027cbcb966
Diffstat (limited to 'bitbake/lib')
-rw-r--r-- | bitbake/lib/bb/data.py | 4 | ||||
-rw-r--r-- | bitbake/lib/bb/methodpool.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/parse/parse_py/BBHandler.py | 77 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 72 | ||||
-rw-r--r-- | bitbake/lib/bb/shell.py | 5 |
5 files changed, 88 insertions, 71 deletions
diff --git a/bitbake/lib/bb/data.py b/bitbake/lib/bb/data.py index 19066c9ad..9f7e4be4c 100644 --- a/bitbake/lib/bb/data.py +++ b/bitbake/lib/bb/data.py @@ -542,8 +542,8 @@ def update_data(d): def inherits_class(klass, d): - val = getVar('__inherit_cache', d) or "" - if os.path.join('classes', '%s.bbclass' % klass) in val.split(): + val = getVar('__inherit_cache', d) or [] + if os.path.join('classes', '%s.bbclass' % klass) in val: return True return False diff --git a/bitbake/lib/bb/methodpool.py b/bitbake/lib/bb/methodpool.py index e14986bc1..f0565ce79 100644 --- a/bitbake/lib/bb/methodpool.py +++ b/bitbake/lib/bb/methodpool.py @@ -83,6 +83,7 @@ def check_insert_method(modulename, code, fn): """ if not modulename in _parsed_methods: return insert_method(modulename, code, fn) + _parsed_methods[modulename] = 1 def parsed_module(modulename): """ diff --git a/bitbake/lib/bb/parse/parse_py/BBHandler.py b/bitbake/lib/bb/parse/parse_py/BBHandler.py index 34f4d2599..42b036942 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+") __infunc__ = "" __inpython__ = False __body__ = [] -__bbpath_found__ = 0 __classname__ = "" classes = [ None, ] @@ -58,25 +57,24 @@ def supports(fn, d): return localfn[-3:] == ".bb" or localfn[-8:] == ".bbclass" or localfn[-4:] == ".inc" def inherit(files, d): - __inherit_cache = data.getVar('__inherit_cache', d) or "" + __inherit_cache = data.getVar('__inherit_cache', d) or [] fn = "" lineno = 0 - for f in files: - file = data.expand(f, d) + files = data.expand(files, d) + for file in files: if file[0] != "/" and file[-8:] != ".bbclass": file = os.path.join('classes', '%s.bbclass' % file) - if not file in __inherit_cache.split(): + if not file in __inherit_cache: bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s:%d: inheriting %s" % (fn, lineno, file)) - __inherit_cache += " %s" % file + __inherit_cache.append( file ) include(fn, file, d, "inherit") data.setVar('__inherit_cache', __inherit_cache, d) def handle(fn, d, include = 0): - global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __bbpath_found__, __residue__ + global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __infunc__, __body__, __residue__ __body__ = [] - __bbpath_found__ = 0 __infunc__ = "" __classname__ = "" __residue__ = [] @@ -104,7 +102,6 @@ def handle(fn, d, include = 0): if not os.path.isabs(fn): f = None for p in bbpath: - p = data.expand(p, d) j = os.path.join(p, fn) if os.access(j, os.R_OK): abs_fn = j @@ -147,39 +144,35 @@ def handle(fn, d, include = 0): data.expandKeys(d) data.update_data(d) anonqueue = data.getVar("__anonqueue", d, 1) or [] - for anon in anonqueue: - data.setVar("__anonfunc", anon["content"], d) - data.setVarFlags("__anonfunc", anon["flags"], d) - from bb import build - try: - t = data.getVar('T', d) - data.setVar('T', '${TMPDIR}/', d) - build.exec_func("__anonfunc", d) - data.delVar('T', d) - if t: - data.setVar('T', t, d) - except Exception, e: - bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e) - raise + body = [x['content'] for x in anonqueue] + flag = { 'python' : 1, 'func' : 1 } + data.setVar("__anonfunc", "\n".join(body), d) + data.setVarFlags("__anonfunc", flag, d) + from bb import build + try: + t = data.getVar('T', d) + data.setVar('T', '${TMPDIR}/', d) + build.exec_func("__anonfunc", d) + data.delVar('T', d) + if t: + data.setVar('T', t, d) + except Exception, e: + bb.msg.debug(1, bb.msg.domain.Parsing, "executing anonymous function: %s" % e) + raise data.delVar("__anonqueue", d) data.delVar("__anonfunc", d) set_additional_vars(fn, d, include) data.update_data(d) all_handlers = {} - for var in data.keys(d): + for var in data.getVar('__BBHANDLERS', d) or []: # try to add the handler # if we added it remember the choiche - if data.getVarFlag(var, 'handler', d): - handler = data.getVar(var,d) - if bb.event.register(var,handler) == bb.event.Registered: - all_handlers[var] = handler - - continue - - if not data.getVarFlag(var, 'task', d): - continue + handler = data.getVar(var,d) + if bb.event.register(var,handler) == bb.event.Registered: + all_handlers[var] = handler + for var in data.getVar('__BBTASKS', d) or []: deps = data.getVarFlag(var, 'deps', d) or [] postdeps = data.getVarFlag(var, 'postdeps', d) or [] bb.build.add_task(var, deps, d) @@ -204,7 +197,7 @@ def handle(fn, d, include = 0): return d def feeder(lineno, s, fn, root, d): - 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__ + global __func_start_regexp__, __inherit_regexp__, __export_func_regexp__, __addtask_regexp__, __addhandler_regexp__, __def_regexp__, __python_func_regexp__, __inpython__,__infunc__, __body__, classes, bb, __residue__ if __infunc__: if s == '}': __body__.append('') @@ -336,6 +329,10 @@ def feeder(lineno, s, fn, root, d): data.setVarFlag(var, "task", 1, d) + bbtasks = data.getVar('__BBTASKS', d) or [] + bbtasks.append(var) + data.setVar('__BBTASKS', bbtasks, d) + if after is not None: # set up deps for function data.setVarFlag(var, "deps", after.split(), d) @@ -348,8 +345,11 @@ def feeder(lineno, s, fn, root, d): if m: fns = m.group(1) hs = __word__.findall(fns) + bbhands = data.getVar('__BBHANDLERS', d) or [] for h in hs: + bbhands.append(h) data.setVarFlag(h, "handler", 1, d) + data.setVar('__BBHANDLERS', bbhands, d) return m = __inherit_regexp__.match(s) @@ -386,16 +386,11 @@ def set_additional_vars(file, d, include): bb.msg.debug(2, bb.msg.domain.Parsing, "BB %s: set_additional_vars" % file) - src_uri = data.getVar('SRC_URI', d) + src_uri = data.getVar('SRC_URI', d, 1) if not src_uri: return - src_uri = data.expand(src_uri, d) - a = data.getVar('A', d) - if a: - a = data.expand(a, d).split() - else: - a = [] + a = (data.getVar('A', d, 1) or '').split() from bb import fetch try: diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index 3dde9a9ff..07821e23d 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py @@ -1,4 +1,4 @@ - #!/usr/bin/env python +#!/usr/bin/env python # ex:ts=4:sw=4:sts=4:et # -*- tab-width: 4; c-basic-offset: 4; indent-tabs-mode: nil -*- """ @@ -25,9 +25,8 @@ import bb, os, sys class TaskFailure(Exception): """Exception raised when a task in a runqueue fails""" - - def __init__(self, fnid, fn, taskname): - self.args = fnid, fn, taskname + def __init__(self, x): + self.args = x class RunQueue: """ @@ -319,21 +318,23 @@ class RunQueue: failures = 0 while 1: - try: - self.execute_runqueue_internal(cooker, cfgData, dataCache, taskData) + failed_fnids = self.execute_runqueue_internal(cooker, cfgData, dataCache, taskData) + if len(failed_fnids) == 0: return failures - except bb.runqueue.TaskFailure, (fnid, taskData.fn_index[fnid], taskname): - if taskData.abort: - raise + if taskData.abort: + raise bb.runqueue.TaskFailure(failed_fnids) + for fnid in failed_fnids: + #print "Failure: %s %s %s" % (fnid, taskData.fn_index[fnid], self.runq_task[fnid]) taskData.fail_fnid(fnid) - self.reset_runqueue() - self.prepare_runqueue(cfgData, dataCache, taskData, runlist) failures = failures + 1 + self.reset_runqueue() + self.prepare_runqueue(cfgData, dataCache, taskData, runlist) def execute_runqueue_internal(self, cooker, cfgData, dataCache, taskData): """ Run the tasks in a queue prepared by prepare_runqueue """ + import signal bb.msg.note(1, bb.msg.domain.RunQueue, "Executing runqueue") @@ -342,11 +343,15 @@ class RunQueue: runq_complete = [] active_builds = 0 build_pids = {} + failed_fnids = [] if len(self.runq_fnid) == 0: # nothing to do return + def sigint_handler(signum, frame): + raise KeyboardInterrupt + def get_next_task(data): """ Return the id of the highest priority task that is buildable @@ -414,6 +419,11 @@ class RunQueue: except OSError, e: bb.msg.fatal(bb.msg.domain.RunQueue, "fork failed: %d (%s)" % (e.errno, e.strerror)) if pid == 0: + # Bypass finally below + active_builds = 0 + # Stop Ctrl+C being sent to children + signal.signal(signal.SIGINT, signal.SIG_IGN) + sys.stdin = open('/dev/null', 'r') cooker.configuration.cmd = taskname[3:] try: cooker.tryBuild(fn, False) @@ -434,26 +444,36 @@ class RunQueue: active_builds = active_builds - 1 task = build_pids[result[0]] if result[1] != 0: + del build_pids[result[0]] bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task, taskData))) - raise bb.runqueue.TaskFailure(self.runq_fnid[task], taskData.fn_index[self.runq_fnid[task]], self.runq_task[task]) + failed_fnids.append(self.runq_fnid[task]) + break task_complete(self, task) del build_pids[result[0]] continue break - except SystemExit: - raise - except: - bb.msg.error(bb.msg.domain.RunQueue, "Exception received") - while active_builds > 0: - bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % active_builds) - tasknum = 1 + finally: + try: + while active_builds > 0: + bb.msg.note(1, bb.msg.domain.RunQueue, "Waiting for %s active tasks to finish" % active_builds) + tasknum = 1 + for k, v in build_pids.iteritems(): + bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k)) + tasknum = tasknum + 1 + result = os.waitpid(-1, 0) + task = build_pids[result[0]] + if result[1] != 0: + bb.msg.error(bb.msg.domain.RunQueue, "Task %s (%s) failed" % (task, self.get_user_idstring(task, taskData))) + failed_fnids.append(self.runq_fnid[task]) + del build_pids[result[0]] + active_builds = active_builds - 1 + if len(failed_fnids) > 0: + return failed_fnids + except: + bb.msg.note(1, bb.msg.domain.RunQueue, "Sending SIGTERM to remaining %s tasks" % active_builds) for k, v in build_pids.iteritems(): - bb.msg.note(1, bb.msg.domain.RunQueue, "%s: %s (%s)" % (tasknum, self.get_user_idstring(v, taskData), k)) - tasknum = tasknum + 1 - result = os.waitpid(-1, 0) - del build_pids[result[0]] - active_builds = active_builds - 1 - raise + os.kill(k, signal.SIGTERM) + raise # Sanity Checks for task in range(len(self.runq_fnid)): @@ -464,7 +484,7 @@ class RunQueue: if runq_complete[task] == 0: bb.msg.error(bb.msg.domain.RunQueue, "Task %s never completed!" % task) - return 0 + return failed_fnids def dump_data(self, taskQueue): """ diff --git a/bitbake/lib/bb/shell.py b/bitbake/lib/bb/shell.py index 760c371d9..711cd4335 100644 --- a/bitbake/lib/bb/shell.py +++ b/bitbake/lib/bb/shell.py @@ -179,8 +179,9 @@ class BitBakeShellCommands: global last_exception last_exception = Providers.NoProvider - except runqueue.TaskFailure, (fnid, fn, taskname): - print "ERROR: '%s, %s' failed" % (fn, taskname) + except runqueue.TaskFailure, fnids: + for fnid in fnids: + print "ERROR: '%s' failed" % td.fn_index[fnid]) global last_exception last_exception = runqueue.TaskFailure |