yocto-sumo源码解析: setup_bitbake
Posted shortnil
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了yocto-sumo源码解析: setup_bitbake相关的知识,希望对你有一定的参考价值。
1. 创造日志handler: 在status_only模式,不需要日志以及UI
# Ensure logging messages get sent to the UI as events handler = bb.event.LogHandler() if not configParams.status_only: # In status only mode there are no logs and no UI logger.addHandler(handler)
2. 取得ui模块并设置特征集:
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", []) if extrafeatures: for feature in extrafeatures: if not feature in featureset: featureset.append(feature)
3. 远程模式下返回远程server连接:
server_connection = None if configParams.remote_server: # Connect to a remote XMLRPC server server_connection = bb.server.xmlrpcclient.connectXMLRPC(configParams.remote_server, featureset, configParams.observe_only, configParams.xmlrpctoken)
4. 本地模式下返回本地server连接:
else: retries = 8 while retries: try: topdir, lock = lockBitbake() sockname = topdir + "/bitbake.sock" if lock: if configParams.status_only or configParams.kill_server: logger.info("bitbake server is not running.") lock.close() return None, None # we start a server with a given configuration logger.info("Starting bitbake server...") # Clear the event queue since we already displayed messages bb.event.ui_queue = [] server = bb.server.process.BitBakeServer(lock, sockname, configuration, featureset) else: logger.info("Reconnecting to bitbake server...") if not os.path.exists(sockname): print("Previous bitbake instance shutting down?, waiting to retry...") i = 0 lock = None # Wait for 5s or until we can get the lock while not lock and i < 50: time.sleep(0.1) _, lock = lockBitbake() i += 1 if lock: bb.utils.unlockfile(lock) raise bb.server.process.ProcessTimeout("Bitbake still shutting down as socket exists but no lock?") if not configParams.server_only: try: server_connection = bb.server.process.connectProcessServer(sockname, featureset) except EOFError: # The server may have been shutting down but not closed the socket yet. If that happened, # ignore it. pass if server_connection or configParams.server_only: break except BBMainFatal: raise except (Exception, bb.server.process.ProcessTimeout) as e: if not retries: raise retries -= 1 if isinstance(e, (bb.server.process.ProcessTimeout, BrokenPipeError)): logger.info("Retrying server connection...") else: logger.info("Retrying server connection... (%s)" % traceback.format_exc()) if not retries: bb.fatal("Unable to connect to bitbake server, or start one") if retries < 5: time.sleep(5)
5. 清理日志handler,返回服务器连接以及ui模块:
if configParams.kill_server: server_connection.connection.terminateServer() server_connection.terminate() bb.event.ui_queue = [] logger.info("Terminated bitbake server.") return None, None # Restore the environment in case the UI needs it for k in cleanedvars: os.environ[k] = cleanedvars[k] logger.removeHandler(handler) return server_connection, ui_module
以上是关于yocto-sumo源码解析: setup_bitbake的主要内容,如果未能解决你的问题,请参考以下文章
yocto-sumo源码解析: ProcessServer.main
yocto-sumo源码解析: oe-buildenv-internal