bitbake/cooker.py: Misc sync with upstream

Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Richard Purdie
2011-06-08 17:23:42 +01:00
parent 9f33dde6e7
commit 355338c40c
4 changed files with 20 additions and 19 deletions

View File

@@ -170,7 +170,6 @@ Default BBFILES are the .bb files in the current directory.""")
configuration = BBConfiguration(options) configuration = BBConfiguration(options)
configuration.pkgs_to_build.extend(args[1:]) configuration.pkgs_to_build.extend(args[1:])
configuration.initial_path = os.environ['PATH']
ui_main = get_ui(configuration) ui_main = get_ui(configuration)

View File

@@ -28,6 +28,7 @@
import os import os
import sys import sys
import logging import logging
import shlex
import bb import bb
import bb.msg import bb.msg
import bb.process import bb.process

View File

@@ -28,7 +28,6 @@ import atexit
import itertools import itertools
import logging import logging
import multiprocessing import multiprocessing
import signal
import sre_constants import sre_constants
import threading import threading
from cStringIO import StringIO from cStringIO import StringIO
@@ -148,6 +147,8 @@ class BBCooker:
self.command = bb.command.Command(self) self.command = bb.command.Command(self)
self.state = state.initial self.state = state.initial
self.parser = None
def parseConfiguration(self): def parseConfiguration(self):
@@ -799,9 +800,6 @@ class BBCooker:
buildname = bb.data.getVar("BUILDNAME", self.configuration.data) buildname = bb.data.getVar("BUILDNAME", self.configuration.data)
bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.configuration.event_data) bb.event.fire(bb.event.BuildStarted(buildname, [item]), self.configuration.event_data)
# Clear locks
bb.fetch.persistent_database_connection = {}
# Execute the runqueue # Execute the runqueue
runlist = [[item, "do_%s" % task]] runlist = [[item, "do_%s" % task]]
@@ -821,6 +819,10 @@ class BBCooker:
buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
failures += len(exc.args) failures += len(exc.args)
retval = False retval = False
except SystemExit as exc:
self.command.finishAsyncCommand()
return False
if not retval: if not retval:
bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data) bb.event.fire(bb.event.BuildCompleted(buildname, item, failures), self.configuration.event_data)
self.command.finishAsyncCommand() self.command.finishAsyncCommand()
@@ -858,6 +860,10 @@ class BBCooker:
buildlog.error("'%s' failed" % taskdata.fn_index[fnid]) buildlog.error("'%s' failed" % taskdata.fn_index[fnid])
failures += len(exc.args) failures += len(exc.args)
retval = False retval = False
except SystemExit as exc:
self.command.finishAsyncCommand()
return False
if not retval: if not retval:
bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data) bb.event.fire(bb.event.BuildCompleted(buildname, targets, failures), self.configuration.event_data)
self.command.finishAsyncCommand() self.command.finishAsyncCommand()
@@ -883,9 +889,6 @@ class BBCooker:
runlist.append([k, "do_%s" % task]) runlist.append([k, "do_%s" % task])
taskdata.add_unresolved(localdata, self.status) taskdata.add_unresolved(localdata, self.status)
# Clear locks
bb.fetch.persistent_database_connection = {}
rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist) rq = bb.runqueue.RunQueue(self, self.configuration.data, self.status, taskdata, runlist)
self.server_registration_cb(buildTargetsIdle, rq) self.server_registration_cb(buildTargetsIdle, rq)
@@ -894,6 +897,10 @@ class BBCooker:
if self.state == state.running: if self.state == state.running:
return return
if self.state in (state.shutdown, state.stop):
self.parser.shutdown(clean=False)
sys.exit(1)
if self.state != state.parsing: if self.state != state.parsing:
self.parseConfiguration () self.parseConfiguration ()
@@ -1194,9 +1201,8 @@ class CookerParser(object):
def start(self): def start(self):
def init(cfg): def init(cfg):
signal.signal(signal.SIGINT, signal.SIG_IGN)
multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1)
parse_file.cfg = cfg parse_file.cfg = cfg
multiprocessing.util.Finalize(None, bb.codeparser.parser_cache_save, args=(self.cooker.configuration.data, ), exitpriority=1)
self.results = self.load_cached() self.results = self.load_cached()
@@ -1225,7 +1231,7 @@ class CookerParser(object):
sync = threading.Thread(target=self.bb_cache.sync) sync = threading.Thread(target=self.bb_cache.sync)
sync.start() sync.start()
atexit.register(lambda: sync.join()) multiprocessing.util.Finalize(None, sync.join, exitpriority=-100)
bb.codeparser.parser_cache_savemerge(self.cooker.configuration.data) bb.codeparser.parser_cache_savemerge(self.cooker.configuration.data)
def load_cached(self): def load_cached(self):
@@ -1239,9 +1245,6 @@ class CookerParser(object):
except StopIteration: except StopIteration:
self.shutdown() self.shutdown()
return False return False
except KeyboardInterrupt:
self.shutdown(clean=False)
raise
except ParsingFailure as exc: except ParsingFailure as exc:
self.shutdown(clean=False) self.shutdown(clean=False)
bb.fatal('Unable to parse %s: %s' % bb.fatal('Unable to parse %s: %s' %

View File

@@ -753,7 +753,6 @@ class RunQueueData:
self.rqdata.runq_depends[task], self.rqdata.runq_depends[task],
self.rqdata.runq_revdeps[task]) self.rqdata.runq_revdeps[task])
class RunQueue: class RunQueue:
def __init__(self, cooker, cfgData, dataCache, taskData, targets): def __init__(self, cooker, cfgData, dataCache, taskData, targets):
@@ -1106,8 +1105,10 @@ class RunQueueExecute:
newsi = os.open(os.devnull, os.O_RDWR) newsi = os.open(os.devnull, os.O_RDWR)
os.dup2(newsi, sys.stdin.fileno()) os.dup2(newsi, sys.stdin.fileno())
bb.data.setVar("BB_WORKERCONTEXT", "1", self.cooker.configuration.data) bb.data.setVar("BB_WORKERCONTEXT", "1", self.cooker.configuration.data)
bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data)
bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data)
bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps)
the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data) the_data = bb.cache.Cache.loadDataFull(fn, self.cooker.get_file_appends(fn), self.cooker.configuration.data)
@@ -1124,9 +1125,6 @@ class RunQueueExecute:
if quieterrors: if quieterrors:
the_data.setVarFlag(taskname, "quieterrors", "1") the_data.setVarFlag(taskname, "quieterrors", "1")
bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY", self, self.cooker.configuration.data)
bb.data.setVar("__RUNQUEUE_DO_NOT_USE_EXTERNALLY2", fn, self.cooker.configuration.data)
bb.parse.siggen.set_taskdata(self.rqdata.hashes, self.rqdata.hash_deps)
for h in self.rqdata.hashes: for h in self.rqdata.hashes:
bb.data.setVar("BBHASH_%s" % h, self.rqdata.hashes[h], the_data) bb.data.setVar("BBHASH_%s" % h, self.rqdata.hashes[h], the_data)