summaryrefslogtreecommitdiffstats
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):
389 except: 389 except:
390 pass 390 pass
391 391
392
393 configuration.setConfigParameters(configParams) 392 configuration.setConfigParameters(configParams)
394 393
395 ui_module = import_extension_module(bb.ui, configParams.ui, 'main')
396 servermodule = import_extension_module(bb.server, configParams.servertype, 'BitBakeServer')
397
398 if configParams.server_only: 394 if configParams.server_only:
399 if configParams.servertype != "xmlrpc": 395 if configParams.servertype != "xmlrpc":
400 raise BBMainException("FATAL: If '--server-only' is defined, we must set the " 396 raise BBMainException("FATAL: If '--server-only' is defined, we must set the "
@@ -442,6 +438,31 @@ def bitbake_main(configParams, configuration):
442 bb.msg.init_msgconfig(configParams.verbose, configuration.debug, 438 bb.msg.init_msgconfig(configParams.verbose, configuration.debug,
443 configuration.debug_domains) 439 configuration.debug_domains)
444 440
441 server, server_connection, ui_module = setup_bitbake(configParams, configuration)
442 if server_connection is None and configParams.kill_server:
443 return 0
444
445 if not configParams.server_only:
446 if configParams.status_only:
447 server_connection.terminate()
448 return 0
449
450 try:
451 return ui_module.main(server_connection.connection, server_connection.events,
452 configParams)
453 finally:
454 bb.event.ui_queue = []
455 server_connection.terminate()
456 else:
457 print("Bitbake server address: %s, server port: %s" % (server.serverImpl.host,
458 server.serverImpl.port))
459 if configParams.foreground:
460 server.serverImpl.serve_forever()
461 return 0
462
463 return 1
464
465def setup_bitbake(configParams, configuration, extrafeatures=None):
445 # Ensure logging messages get sent to the UI as events 466 # Ensure logging messages get sent to the UI as events
446 handler = bb.event.LogHandler() 467 handler = bb.event.LogHandler()
447 if not configParams.status_only: 468 if not configParams.status_only:
@@ -451,8 +472,11 @@ def bitbake_main(configParams, configuration):
451 # Clear away any spurious environment variables while we stoke up the cooker 472 # Clear away any spurious environment variables while we stoke up the cooker
452 cleanedvars = bb.utils.clean_environment() 473 cleanedvars = bb.utils.clean_environment()
453 474
454 featureset = [] 475 if configParams.server_only:
455 if not configParams.server_only: 476 featureset = []
477 ui_module = None
478 else:
479 ui_module = import_extension_module(bb.ui, configParams.ui, 'main')
456 # Collect the feature set for the UI 480 # Collect the feature set for the UI
457 featureset = getattr(ui_module, "featureSet", []) 481 featureset = getattr(ui_module, "featureSet", [])
458 482
@@ -463,11 +487,15 @@ def bitbake_main(configParams, configuration):
463 setattr(configuration, "%s_server" % param, value) 487 setattr(configuration, "%s_server" % param, value)
464 param = "%s_server" % param 488 param = "%s_server" % param
465 489
466 if not configParams.remote_server: 490 if extrafeatures:
467 # we start a server with a given configuration 491 for feature in extrafeatures:
468 server = start_server(servermodule, configParams, configuration, featureset) 492 if not feature in featureset:
469 bb.event.ui_queue = [] 493 featureset.append(feature)
470 else: 494
495 servermodule = import_extension_module(bb.server,
496 configParams.servertype,
497 'BitBakeServer')
498 if configParams.remote_server:
471 if os.getenv('BBSERVER') == 'autostart': 499 if os.getenv('BBSERVER') == 'autostart':
472 if configParams.remote_server == 'autostart' or \ 500 if configParams.remote_server == 'autostart' or \
473 not servermodule.check_connection(configParams.remote_server, timeout=2): 501 not servermodule.check_connection(configParams.remote_server, timeout=2):
@@ -475,14 +503,19 @@ def bitbake_main(configParams, configuration):
475 srv = start_server(servermodule, configParams, configuration, featureset) 503 srv = start_server(servermodule, configParams, configuration, featureset)
476 configParams.remote_server = '%s:%d' % tuple(configuration.interface) 504 configParams.remote_server = '%s:%d' % tuple(configuration.interface)
477 bb.event.ui_queue = [] 505 bb.event.ui_queue = []
478
479 # we start a stub server that is actually a XMLRPClient that connects to a real server 506 # we start a stub server that is actually a XMLRPClient that connects to a real server
507 from bb.server.xmlrpc import BitBakeXMLRPCClient
480 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only, 508 server = servermodule.BitBakeXMLRPCClient(configParams.observe_only,
481 configParams.xmlrpctoken) 509 configParams.xmlrpctoken)
482 server.saveConnectionDetails(configParams.remote_server) 510 server.saveConnectionDetails(configParams.remote_server)
511 else:
512 # we start a server with a given configuration
513 server = start_server(servermodule, configParams, configuration, featureset)
514 bb.event.ui_queue = []
483 515
484 516 if configParams.server_only:
485 if not configParams.server_only: 517 server_connection = None
518 else:
486 try: 519 try:
487 server_connection = server.establishConnection(featureset) 520 server_connection = server.establishConnection(featureset)
488 except Exception as e: 521 except Exception as e:
@@ -491,7 +524,7 @@ def bitbake_main(configParams, configuration):
491 if configParams.kill_server: 524 if configParams.kill_server:
492 server_connection.connection.terminateServer() 525 server_connection.connection.terminateServer()
493 bb.event.ui_queue = [] 526 bb.event.ui_queue = []
494 return 0 527 return None, None, None
495 528
496 server_connection.setupEventQueue() 529 server_connection.setupEventQueue()
497 530
@@ -501,22 +534,4 @@ def bitbake_main(configParams, configuration):
501 534
502 logger.removeHandler(handler) 535 logger.removeHandler(handler)
503 536
504 537 return server, server_connection, ui_module
505 if configParams.status_only:
506 server_connection.terminate()
507 return 0
508
509 try:
510 return ui_module.main(server_connection.connection, server_connection.events,
511 configParams)
512 finally:
513 bb.event.ui_queue = []
514 server_connection.terminate()
515 else:
516 print("Bitbake server address: %s, server port: %s" % (server.serverImpl.host,
517 server.serverImpl.port))
518 if configParams.foreground:
519 server.serverImpl.serve_forever()
520 return 0
521
522 return 1