aboutsummaryrefslogtreecommitdiffstats
path: root/bitbake/lib/bb/main.py
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib/bb/main.py')
-rwxr-xr-xbitbake/lib/bb/main.py83
1 files changed, 49 insertions, 34 deletions
diff --git a/bitbake/lib/bb/main.py b/bitbake/lib/bb/main.py
index a544c0aecb..443f5ec2fd 100755
--- a/bitbake/lib/bb/main.py
+++ b/bitbake/lib/bb/main.py
@@ -389,12 +389,8 @@ def bitbake_main(configParams, configuration):
except:
pass
-
configuration.setConfigParameters(configParams)
- ui_module = import_extension_module(bb.ui, configParams.ui, 'main')
- servermodule = import_extension_module(bb.server, configParams.servertype, 'BitBakeServer')
-
if configParams.server_only:
if configParams.servertype != "xmlrpc":
raise BBMainException("FATAL: If '--server-only' is defined, we must set the "
@@ -442,6 +438,31 @@ def bitbake_main(configParams, configuration):
bb.msg.init_msgconfig(configParams.verbose, configuration.debug,
configuration.debug_domains)
+ server, server_connection, ui_module = setup_bitbake(configParams, configuration)
+ if server_connection is None and configParams.kill_server:
+ return 0
+
+ if not configParams.server_only:
+ if configParams.status_only:
+ server_connection.terminate()
+ return 0
+
+ try:
+ return ui_module.main(server_connection.connection, server_connection.events,
+ configParams)
+ finally:
+ bb.event.ui_queue = []
+ server_connection.terminate()
+ else:
+ print("Bitbake server address: %s, server port: %s" % (server.serverImpl.host,
+ server.serverImpl.port))
+ if configParams.foreground:
+ server.serverImpl.serve_forever()
+ return 0
+
+ return 1
+
+def setup_bitbake(configParams, configuration, extrafeatures=None):
# Ensure logging messages get sent to the UI as events
handler = bb.event.LogHandler()
if not configParams.status_only:
@@ -451,8 +472,11 @@ def bitbake_main(configParams, configuration):
# Clear away any spurious environment variables while we stoke up the cooker
cleanedvars = bb.utils.clean_environment()
- featureset = []
- if not configParams.server_only:
+ if configParams.server_only:
+ featureset = []
+ ui_module = None
+ else:
+ ui_module = import_extension_module(bb.ui, configParams.ui, 'main')
# Collect the feature set for the UI
featureset = getattr(ui_module, "featureSet", [])
@@ -463,11 +487,15 @@ def bitbake_main(configParams, configuration):
setattr(configuration, "%s_server" % param, value)
param = "%s_server" % param
- if not configParams.remote_server:
- # we start a server with a given configuration
- server = start_server(servermodule, configParams, configuration, featureset)
- bb.event.ui_queue = []
- else:
+ if extrafeatures:
+ for feature in extrafeatures:
+ if not feature in featureset:
+ featureset.append(feature)
+
+ servermodule = import_extension_module(bb.server,
+ configParams.servertype,
+ 'BitBakeServer')
+ if configParams.remote_server:
if os.getenv('BBSERVER') == 'autostart':
if configParams.remote_server == 'autostart' or \
not servermodule.check_connection(configParams.remote_server, timeout=2):
@@ -475,14 +503,19 @@ def bitbake_main(configParams, configuration):
srv = start_server(servermodule, configParams, configuration, featureset)
configParams.remote_server = '%s:%d' % tuple(configuration.interface)
bb.event.ui_queue = []
-
# we start a stub server that is actually a XMLRPClient that connects to a real server
+ from bb.server.xmlrpc import BitBakeXMLRPCClient
server = servermodule.BitBakeXMLRPCClient(configParams.observe_only,
configParams.xmlrpctoken)
server.saveConnectionDetails(configParams.remote_server)
+ else:
+ # we start a server with a given configuration
+ server = start_server(servermodule, configParams, configuration, featureset)
+ bb.event.ui_queue = []
-
- if not configParams.server_only:
+ if configParams.server_only:
+ server_connection = None
+ else:
try:
server_connection = server.establishConnection(featureset)
except Exception as e:
@@ -491,7 +524,7 @@ def bitbake_main(configParams, configuration):
if configParams.kill_server:
server_connection.connection.terminateServer()
bb.event.ui_queue = []
- return 0
+ return None, None, None
server_connection.setupEventQueue()
@@ -501,22 +534,4 @@ def bitbake_main(configParams, configuration):
logger.removeHandler(handler)
-
- if configParams.status_only:
- server_connection.terminate()
- return 0
-
- try:
- return ui_module.main(server_connection.connection, server_connection.events,
- configParams)
- finally:
- bb.event.ui_queue = []
- server_connection.terminate()
- else:
- print("Bitbake server address: %s, server port: %s" % (server.serverImpl.host,
- server.serverImpl.port))
- if configParams.foreground:
- server.serverImpl.serve_forever()
- return 0
-
- return 1
+ return server, server_connection, ui_module