aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/main.py
diff options
context:
space:
mode:
authorPaul Eggleton <paul.eggleton@linux.intel.com>2016-12-13 20:07:06 +1300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-12-14 09:54:48 +0000
commit3bbf8d611c859f74d563778115677a04f5c4ab43 (patch)
tree11a86283ca5e7026f90fdb685180605f9e19cea4 /lib/bb/main.py
parent74db369c46043116359101cab70486afd82372c0 (diff)
downloadbitbake-contrib-3bbf8d611c859f74d563778115677a04f5c4ab43.tar.gz
tinfoil: rewrite as a wrapper around the UI
Rewrite tinfoil as a wrapper around the UI, instead of the earlier approach of starting up just enough of cooker to do what we want. This has several advantages: * It now works when bitbake is memory-resident instead of failing with "ERROR: Only one copy of bitbake should be run against a build directory". * We can now connect an actual UI, thus you get things like the recipe parsing / cache loading progress bar and parse error handling for free * We can now handle events generated by the server if we wish to do so * We can potentially extend this to do more stuff, e.g. actually running build operations - this needs to be made more practical before we can use it though (since you effectively have to become the UI yourself for this at the moment.) The downside is that tinfoil no longer has direct access to cooker, the global datastore, or the cache. To mitigate this I have extended data_smart to provide remote access capability for the datastore, and created "fake" cooker and cooker.recipecache / cooker.collection adapter objects in order to avoid breaking too many tinfoil-using scripts that might be out there (we've never officially documented tinfoil or BitBake's internal code, but we can still make accommodations where practical). I've at least gone far enough to support all of the utilities that use tinfoil in OE-Core with some changes, but I know there are scripts such as Chris Larson's "bb" out there that do make other calls into BitBake code that I'm not currently providing access to through the adapters. Part of the fix for [YOCTO #5470]. Signed-off-by: Paul Eggleton <paul.eggleton@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/main.py')
-rwxr-xr-xlib/bb/main.py83
1 files changed, 49 insertions, 34 deletions
diff --git a/lib/bb/main.py b/lib/bb/main.py
index a544c0aec..443f5ec2f 100755
--- a/lib/bb/main.py
+++ b/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