diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-08 17:23:42 +0100 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2011-06-08 20:38:27 +0100 |
commit | 355338c40c6fc65d10980cfd75e9ab5ff96ed43a (patch) | |
tree | 1f9564de6685fd2237e14809e353249017531416 /bitbake/lib/bb | |
parent | 9f33dde6e71b7b66db357b1bf289ae63e0db77d2 (diff) | |
download | poky-355338c40c6fc65d10980cfd75e9ab5ff96ed43a.tar.gz |
bitbake/cooker.py: Misc sync with upstream
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb')
-rw-r--r-- | bitbake/lib/bb/build.py | 1 | ||||
-rw-r--r-- | bitbake/lib/bb/cooker.py | 29 | ||||
-rw-r--r-- | bitbake/lib/bb/runqueue.py | 8 |
3 files changed, 20 insertions, 18 deletions
diff --git a/bitbake/lib/bb/build.py b/bitbake/lib/bb/build.py index f1384ef312..0f047364e4 100644 --- a/bitbake/lib/bb/build.py +++ b/bitbake/lib/bb/build.py | |||
@@ -28,6 +28,7 @@ | |||
28 | import os | 28 | import os |
29 | import sys | 29 | import sys |
30 | import logging | 30 | import logging |
31 | import shlex | ||
31 | import bb | 32 | import bb |
32 | import bb.msg | 33 | import bb.msg |
33 | import bb.process | 34 | import bb.process |
diff --git a/bitbake/lib/bb/cooker.py b/bitbake/lib/bb/cooker.py index b66d0038ac..dc196ae801 100644 --- a/bitbake/lib/bb/cooker.py +++ b/bitbake/lib/bb/cooker.py | |||
@@ -28,7 +28,6 @@ import atexit | |||
28 | import itertools | 28 | import itertools |
29 | import logging | 29 | import logging |
30 | import multiprocessing | 30 | import multiprocessing |
31 | import signal | ||
32 | import sre_constants | 31 | import sre_constants |
33 | import threading | 32 | import threading |
34 | from cStringIO import StringIO | 33 | from cStringIO import StringIO |
@@ -148,6 +147,8 @@ class BBCooker: | |||
148 | self.command = bb.command.Command(self) | 147 | self.command = bb.command.Command(self) |
149 | self.state = state.initial | 148 | self.state = state.initial |
150 | 149 | ||
150 | self.parser = None | ||
151 | |||
151 | def parseConfiguration(self): | 152 | def parseConfiguration(self): |
152 | 153 | ||
153 | 154 | ||
@@ -799,9 +800,6 @@ class BBCooker: | |||
799 | buildname = bb.data.getVar("BUILDNAME", self.configuration.data) | 800 | buildname = bb.data.getVar("BUILDNAME", self.configuration.data) |
800 | bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.configuration.event_data) | 801 | bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.configuration.event_data) |
801 | 802 | ||
802 | # Clear locks | ||
803 | bb.fetch.persistent_database_connection = {} | ||
804 | |||
805 | # Execute the runqueue | 803 | # Execute the runqueue |
806 | runlist = [[item, "do_%s" % task]] | 804 | runlist = [[item, "do_%s" % task]] |
807 | 805 | ||
@@ -821,6 +819,10 @@ class BBCooker: | |||
821 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) | 819 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) |
822 | failures += len(exc.args) | 820 | failures += len(exc.args) |
823 | retval = False | 821 | retval = False |
822 | except SystemExit as exc: | ||
823 | self.command.finishAsyncCommand() | ||
824 | return False | ||
825 | |||
824 | if not retval: | 826 | if not retval: |
825 | bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) | 827 | bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) |
826 | self.command.finishAsyncCommand() | 828 | self.command.finishAsyncCommand() |
@@ -858,6 +860,10 @@ class BBCooker: | |||
858 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) | 860 | buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) |
859 | failures += len(exc.args) | 861 | failures += len(exc.args) |
860 | retval = False | 862 | retval = False |
863 | except SystemExit as exc: | ||
864 | self.command.finishAsyncCommand() | ||
865 | return False | ||
866 | |||
861 | if not retval: | 867 | if not retval: |
862 | bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) | 868 | bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) |
863 | self.command.finishAsyncCommand() | 869 | self.command.finishAsyncCommand() |
@@ -883,9 +889,6 @@ class BBCooker: | |||
883 | runlist.append([k, "do_%s" % task]) | 889 | runlist.append([k, "do_%s" % task]) |
884 | taskdata.add_unresolved(localdata, self.status) | 890 | taskdata.add_unresolved(localdata, self.status) |
885 | 891 | ||
886 | # Clear locks | ||
887 | bb.fetch.persistent_database_connection = {} | ||
888 | |||
889 | rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) | 892 | rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) |
890 | 893 | ||
891 | self.server_registration_cb(buildTargetsIdle, rq) | 894 | self.server_registration_cb(buildTargetsIdle, rq) |
@@ -894,6 +897,10 @@ class BBCooker: | |||
894 | if self.state == state.running: | 897 | if self.state == state.running: |
895 | return | 898 | return |
896 | 899 | ||
900 | if self.state in (state.shutdown, state.stop): | ||
901 | self.parser.shutdown(clean=False) | ||
902 | sys.exit(1) | ||
903 | |||
897 | if self.state != state.parsing: | 904 | if self.state != state.parsing: |
898 | self.parseConfiguration () | 905 | self.parseConfiguration () |
899 | 906 | ||
@@ -1194,9 +1201,8 @@ class CookerParser(object): | |||
1194 | 1201 | ||
1195 | def start(self): | 1202 | def start(self): |
1196 | def init(cfg): | 1203 | def init(cfg): |
1197 | signal.signal(signal.SIGINT, signal.SIG_IGN) | ||
1198 | multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1) | ||
1199 | parse_file.cfg = cfg | 1204 | parse_file.cfg = cfg |
1205 | multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1) | ||
1200 | 1206 | ||
1201 | self.results = self.load_cached() | 1207 | self.results = self.load_cached() |
1202 | 1208 | ||
@@ -1225,7 +1231,7 @@ class CookerParser(object): | |||
1225 | 1231 | ||
1226 | sync = threading.Thread(target=self.bb_cache.sync) | 1232 | sync = threading.Thread(target=self.bb_cache.sync) |
1227 | sync.start() | 1233 | sync.start() |
1228 | atexit.register(lambda: sync.join()) | 1234 | multiprocessing.util.Finalize(None, sync.join, exitpriority=-100) |
1229 | bb.codeparser.parser_cache_savemerge(self.cooker.configuration.data) | 1235 | bb.codeparser.parser_cache_savemerge(self.cooker.configuration.data) |
1230 | 1236 | ||
1231 | def load_cached(self): | 1237 | def load_cached(self): |
@@ -1239,9 +1245,6 @@ class CookerParser(object): | |||
1239 | except StopIteration: | 1245 | except StopIteration: |
1240 | self.shutdown() | 1246 | self.shutdown() |
1241 | return False | 1247 | return False |
1242 | except KeyboardInterrupt: | ||
1243 | self.shutdown(clean=False) | ||
1244 | raise | ||
1245 | except ParsingFailure as exc: | 1248 | except ParsingFailure as exc: |
1246 | self.shutdown(clean=False) | 1249 | self.shutdown(clean=False) |
1247 | bb.fatal('Unable to parse %s: %s' % | 1250 | bb.fatal('Unable to parse %s: %s' % |
diff --git a/bitbake/lib/bb/runqueue.py b/bitbake/lib/bb/runqueue.py index afa1f8d736..52360accdb 100644 --- a/bitbake/lib/bb/runqueue.py +++ b/bitbake/lib/bb/runqueue.py | |||
@@ -753,7 +753,6 @@ class RunQueueData: | |||
753 | self.rqdata.runq_depends[task], | 753 | self.rqdata.runq_depends[task], |
754 | self.rqdata.runq_revdeps[task]) | 754 | self.rqdata.runq_revdeps[task]) |
755 | 755 | ||
756 | |||
757 | class RunQueue: | 756 | class RunQueue: |
758 | def __init__(self, cooker, cfgData, dataCache, taskData, targets): | 757 | def __init__(self, cooker, cfgData, dataCache, taskData, targets): |
759 | 758 | ||
@@ -1106,8 +1105,10 @@ class RunQueueExecute: | |||
1106 | newsi = os.open(os.devnull, os.O_RDWR) | 1105 | newsi = os.open(os.devnull, os.O_RDWR) |
1107 | os.dup2(newsi, sys.stdin.fileno()) | 1106 | os.dup2(newsi, sys.stdin.fileno()) |
1108 | 1107 | ||
1109 | |||
1110 | bb.data.setVar("BB_WORKERCONTEXT", "1", self.cooker.configuration.data) | 1108 | bb.data.setVar("BB_WORKERCONTEXT", "1", self.cooker.configuration.data) |
1109 | bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data) | ||
1110 | bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data) | ||
1111 | bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps) | ||
1111 | 1112 | ||
1112 | the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data) | 1113 | the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data) |
1113 | 1114 | ||
@@ -1124,9 +1125,6 @@ class RunQueueExecute: | |||
1124 | if quieterrors: | 1125 | if quieterrors: |
1125 | the_data.setVarFlag(taskname, "quieterrors", "1") | 1126 | the_data.setVarFlag(taskname, "quieterrors", "1") |
1126 | 1127 | ||
1127 | bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data) | ||
1128 | bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data) | ||
1129 | bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps) | ||
1130 | 1128 | ||
1131 | for h in self.rqdata.hashes: | 1129 | for h in self.rqdata.hashes: |
1132 | bb.data.setVar("BBHASH_%s" % h, self.rqdata.hashes[h], the_data) | 1130 | bb.data.setVar("BBHASH_%s" % h, self.rqdata.hashes[h], the_data) |