Patrick Williams | c124f4f | 2015-09-15 14:41:29 -0500 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # |
| 3 | # BitBake Graphical GTK User Interface |
| 4 | # |
| 5 | # Copyright (C) 2011 Intel Corporation |
| 6 | # |
| 7 | # Authored by Joshua Lock <josh@linux.intel.com> |
| 8 | # Authored by Dongxiao Xu <dongxiao.xu@intel.com> |
| 9 | # |
| 10 | # This program is free software; you can redistribute it and/or modify |
| 11 | # it under the terms of the GNU General Public License version 2 as |
| 12 | # published by the Free Software Foundation. |
| 13 | # |
| 14 | # This program is distributed in the hope that it will be useful, |
| 15 | # but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | # GNU General Public License for more details. |
| 18 | # |
| 19 | # You should have received a copy of the GNU General Public License along |
| 20 | # with this program; if not, write to the Free Software Foundation, Inc., |
| 21 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
| 22 | |
| 23 | import sys |
| 24 | import os |
| 25 | requirements = "FATAL: Hob requires Gtk+ 2.20.0 or higher, PyGtk 2.21.0 or higher" |
| 26 | try: |
| 27 | import gobject |
| 28 | import gtk |
| 29 | import pygtk |
| 30 | pygtk.require('2.0') # to be certain we don't have gtk+ 1.x !?! |
| 31 | gtkver = gtk.gtk_version |
| 32 | pygtkver = gtk.pygtk_version |
| 33 | if gtkver < (2, 20, 0) or pygtkver < (2, 21, 0): |
| 34 | sys.exit("%s,\nYou have Gtk+ %s and PyGtk %s." % (requirements, |
| 35 | ".".join(map(str, gtkver)), |
| 36 | ".".join(map(str, pygtkver)))) |
| 37 | except ImportError as exc: |
| 38 | sys.exit("%s (%s)." % (requirements, str(exc))) |
| 39 | sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.dirname(__file__)))) |
| 40 | try: |
| 41 | import bb |
| 42 | except RuntimeError as exc: |
| 43 | sys.exit(str(exc)) |
| 44 | from bb.ui import uihelper |
| 45 | from bb.ui.crumbs.hoblistmodel import RecipeListModel, PackageListModel |
| 46 | from bb.ui.crumbs.hobeventhandler import HobHandler |
| 47 | from bb.ui.crumbs.builder import Builder |
| 48 | |
| 49 | featureSet = [bb.cooker.CookerFeatures.HOB_EXTRA_CACHES, bb.cooker.CookerFeatures.BASEDATASTORE_TRACKING] |
| 50 | |
| 51 | def event_handle_idle_func(eventHandler, hobHandler): |
| 52 | # Consume as many messages as we can in the time available to us |
| 53 | if not eventHandler: |
| 54 | return False |
| 55 | event = eventHandler.getEvent() |
| 56 | while event: |
| 57 | hobHandler.handle_event(event) |
| 58 | event = eventHandler.getEvent() |
| 59 | return True |
| 60 | |
| 61 | _evt_list = [ "bb.runqueue.runQueueExitWait", "bb.event.LogExecTTY", "logging.LogRecord", |
| 62 | "bb.build.TaskFailed", "bb.build.TaskBase", "bb.event.ParseStarted", |
| 63 | "bb.event.ParseProgress", "bb.event.ParseCompleted", "bb.event.CacheLoadStarted", |
| 64 | "bb.event.CacheLoadProgress", "bb.event.CacheLoadCompleted", "bb.command.CommandFailed", |
| 65 | "bb.command.CommandExit", "bb.command.CommandCompleted", "bb.cooker.CookerExit", |
| 66 | "bb.event.MultipleProviders", "bb.event.NoProvider", "bb.runqueue.sceneQueueTaskStarted", |
| 67 | "bb.runqueue.runQueueTaskStarted", "bb.runqueue.runQueueTaskFailed", "bb.runqueue.sceneQueueTaskFailed", |
| 68 | "bb.event.BuildBase", "bb.build.TaskStarted", "bb.build.TaskSucceeded", "bb.build.TaskFailedSilent", |
| 69 | "bb.event.SanityCheckPassed", "bb.event.SanityCheckFailed", "bb.event.PackageInfo", |
| 70 | "bb.event.TargetsTreeGenerated", "bb.event.ConfigFilesFound", "bb.event.ConfigFilePathFound", |
| 71 | "bb.event.FilesMatchingFound", "bb.event.NetworkTestFailed", "bb.event.NetworkTestPassed", |
| 72 | "bb.event.BuildStarted", "bb.event.BuildCompleted", "bb.event.DiskFull"] |
| 73 | |
| 74 | def main (server, eventHandler, params): |
| 75 | params.updateFromServer(server) |
| 76 | gobject.threads_init() |
| 77 | |
| 78 | # That indicates whether the Hob and the bitbake server are |
| 79 | # running on different machines |
| 80 | # recipe model and package model |
| 81 | recipe_model = RecipeListModel() |
| 82 | package_model = PackageListModel() |
| 83 | |
| 84 | llevel, debug_domains = bb.msg.constructLogOptions() |
| 85 | server.runCommand(["setEventMask", server.getEventHandle(), llevel, debug_domains, _evt_list]) |
| 86 | hobHandler = HobHandler(server, recipe_model, package_model) |
| 87 | builder = Builder(hobHandler, recipe_model, package_model) |
| 88 | |
| 89 | # This timeout function regularly probes the event queue to find out if we |
| 90 | # have any messages waiting for us. |
| 91 | gobject.timeout_add(10, event_handle_idle_func, eventHandler, hobHandler) |
| 92 | |
| 93 | try: |
| 94 | gtk.main() |
| 95 | except EnvironmentError as ioerror: |
| 96 | # ignore interrupted io |
| 97 | if ioerror.args[0] == 4: |
| 98 | pass |
| 99 | finally: |
| 100 | hobHandler.cancel_build(force = True) |
| 101 | |
| 102 | if __name__ == "__main__": |
| 103 | try: |
| 104 | ret = main() |
| 105 | except Exception: |
| 106 | ret = 1 |
| 107 | import traceback |
| 108 | traceback.print_exc(15) |
| 109 | sys.exit(ret) |