diff options
Diffstat (limited to 'bitbake/bin')
-rwxr-xr-x | bitbake/bin/bitbake | 87 | ||||
-rwxr-xr-x | bitbake/bin/bitdoc | 2 |
2 files changed, 48 insertions, 41 deletions
diff --git a/bitbake/bin/bitbake b/bitbake/bin/bitbake index 797b5a8d6..6d0528953 100755 --- a/bitbake/bin/bitbake +++ b/bitbake/bin/bitbake @@ -23,14 +23,18 @@ # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. import os -import sys -sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), +import sys, logging +sys.path.insert(0, os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib')) import optparse import warnings from traceback import format_exception -import bb +try: + import bb +except RuntimeError, exc: + sys.exit(str(exc)) +from bb import event import bb.msg from bb import cooker from bb import ui @@ -39,12 +43,9 @@ from bb.server import none #from bb.server import xmlrpc __version__ = "1.11.0" +logger = logging.getLogger("BitBake") - -#============================================================================# -# BBOptions -#============================================================================# class BBConfiguration(object): """ Manages build options and configurations for one run @@ -56,34 +57,44 @@ class BBConfiguration(object): self.pkgs_to_build = [] -def print_exception(exc, value, tb): - """Send exception information through bb.msg""" - bb.fatal("".join(format_exception(exc, value, tb, limit=8))) +def get_ui(config): + if config.ui: + interface = config.ui + else: + interface = 'knotty' -sys.excepthook = print_exception + try: + # Dynamically load the UI based on the ui name. Although we + # suggest a fixed set this allows you to have flexibility in which + # ones are available. + module = __import__("bb.ui", fromlist = [interface]) + return getattr(module, interface).main + except AttributeError: + sys.exit("FATAL: Invalid user interface '%s' specified.\n" + "Valid interfaces: depexp, goggle, ncurses, knotty [default]." % interface) +# Display bitbake/OE warnings via the BitBake.Warnings logger, ignoring others""" +warnlog = logging.getLogger("BitBake.Warnings") _warnings_showwarning = warnings.showwarning def _showwarning(message, category, filename, lineno, file=None, line=None): - """Display python warning messages using bb.msg""" if file is not None: if _warnings_showwarning is not None: _warnings_showwarning(message, category, filename, lineno, file, line) else: s = warnings.formatwarning(message, category, filename, lineno) - s = s.split("\n")[0] - bb.msg.warn(None, s) + warnlog.warn(s) warnings.showwarning = _showwarning -warnings.simplefilter("ignore", DeprecationWarning) +warnings.filterwarnings("ignore") +warnings.filterwarnings("default", module="(<string>$|(oe|bb)\.)") +warnings.filterwarnings("ignore", category=PendingDeprecationWarning) +warnings.filterwarnings("ignore", category=ImportWarning) +warnings.filterwarnings("ignore", category=DeprecationWarning, module="<string>$") +warnings.filterwarnings("ignore", message="With-statements now directly support multiple context managers") -#============================================================================# -# main -#============================================================================# def main(): - return_value = 1 - parser = optparse.OptionParser( version = "BitBake Build Tool Core version %s, %%prog version %s" % (bb.__version__, __version__), usage = """%prog [options] [package ...] @@ -159,6 +170,11 @@ Default BBFILES are the .bb files in the current directory.""") configuration.pkgs_to_build.extend(args[1:]) configuration.initial_path = os.environ['PATH'] + ui_main = get_ui(configuration) + + loghandler = event.LogHandler() + logger.addHandler(loghandler) + #server = bb.server.xmlrpc server = bb.server.none @@ -175,7 +191,6 @@ Default BBFILES are the .bb files in the current directory.""") bb.utils.clean_environment() cooker = bb.cooker.BBCooker(configuration, server) - cooker.parseCommandLine() serverinfo = server.BitbakeServerInfo(cooker.server) @@ -183,8 +198,10 @@ Default BBFILES are the .bb files in the current directory.""") server.BitBakeServerFork(cooker, cooker.server, serverinfo, cooker_logfile) del cooker + logger.removeHandler(loghandler) + # Setup a connection to the server (cooker) - serverConnection = server.BitBakeServerConnection(serverinfo) + server_connection = server.BitBakeServerConnection(serverinfo) # Launch the UI if configuration.ui: @@ -193,25 +210,15 @@ Default BBFILES are the .bb files in the current directory.""") ui = "knotty" try: - # Dynamically load the UI based on the ui name. Although we - # suggest a fixed set this allows you to have flexibility in which - # ones are available. - uimodule = __import__("bb.ui", fromlist = [ui]) - ui_init = getattr(uimodule, ui).init - except AttributeError: - print("FATAL: Invalid user interface '%s' specified. " % ui) - print("Valid interfaces are 'ncurses', 'depexp' or the default, 'knotty'.") - else: - try: - return_value = server.BitbakeUILauch().launch(serverinfo, ui_init, serverConnection.connection, serverConnection.events) - except Exception as e: - print("FATAL: Unable to start to '%s' UI: %s" % (ui, e)) - raise + return server.BitbakeUILauch().launch(serverinfo, ui_main, server_connection.connection, server_connection.events) finally: - serverConnection.terminate() - - return return_value + server_connection.terminate() if __name__ == "__main__": - ret = main() + try: + ret = main() + except Exception: + ret = 1 + import traceback + traceback.print_exc(5) sys.exit(ret) diff --git a/bitbake/bin/bitdoc b/bitbake/bin/bitdoc index 8043b2bd1..c2a7061d1 100755 --- a/bitbake/bin/bitdoc +++ b/bitbake/bin/bitdoc @@ -20,7 +20,7 @@ import optparse, os, sys # bitbake -sys.path.append(os.path.join(os.path.dirname(os.path.dirname(sys.argv[0])), 'lib')) +sys.path.append(os.path.join(os.path.dirname(os.path.dirname(__file__), 'lib')) import bb import bb.parse from string import split, join |