diff options
author | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-12 15:37:59 +0000 |
---|---|---|
committer | Richard Purdie <richard.purdie@linuxfoundation.org> | 2017-02-19 06:28:46 -0800 |
commit | 6a531c8b3368f1d2594c60abeddc50a5642cacfa (patch) | |
tree | d2ea0d608acbc907ec6a2ed30c60cb1058a5fe2e /bitbake/lib/bb/ui/depexp.py | |
parent | 0bc0e9801bf85358b343883506095dc0c04ea6f9 (diff) | |
download | poky-6a531c8b3368f1d2594c60abeddc50a5642cacfa.tar.gz |
bitbake: ui: Replace depexp with taskexp
The data displayed by the depexp UI is buggy, bitbake can't convey
accurate runtime dependency information.
Convert the UI to become taskexp ("Task Explorer") which provides
a graphical way of exploring the task-depends.dot file. This data
is accurate and being able to visualise the data is an often requested
feature as standard dot file viewers can't usualy cope.
(Bitbake rev: 416a496edc692982af2feec768ac4df8fb799853)
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'bitbake/lib/bb/ui/depexp.py')
-rw-r--r-- | bitbake/lib/bb/ui/depexp.py | 358 |
1 files changed, 0 insertions, 358 deletions
diff --git a/bitbake/lib/bb/ui/depexp.py b/bitbake/lib/bb/ui/depexp.py deleted file mode 100644 index 9630646ab1..0000000000 --- a/bitbake/lib/bb/ui/depexp.py +++ /dev/null | |||
@@ -1,358 +0,0 @@ | |||
1 | # | ||
2 | # BitBake Graphical GTK based Dependency Explorer | ||
3 | # | ||
4 | # Copyright (C) 2007 Ross Burton | ||
5 | # Copyright (C) 2007 - 2008 Richard Purdie | ||
6 | # | ||
7 | # This program is free software; you can redistribute it and/or modify | ||
8 | # it under the terms of the GNU General Public License version 2 as | ||
9 | # published by the Free Software Foundation. | ||
10 | # | ||
11 | # This program is distributed in the hope that it will be useful, | ||
12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
14 | # GNU General Public License for more details. | ||
15 | # | ||
16 | # You should have received a copy of the GNU General Public License along | ||
17 | # with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
19 | |||
20 | import sys | ||
21 | import gi | ||
22 | gi.require_version('Gtk', '3.0') | ||
23 | from gi.repository import Gtk, Gdk, GObject | ||
24 | from multiprocessing import Queue | ||
25 | import threading | ||
26 | from xmlrpc import client | ||
27 | import time | ||
28 | import bb | ||
29 | import bb.event | ||
30 | |||
31 | # Package Model | ||
32 | (COL_PKG_NAME) = (0) | ||
33 | |||
34 | # Dependency Model | ||
35 | (TYPE_DEP, TYPE_RDEP) = (0, 1) | ||
36 | (COL_DEP_TYPE, COL_DEP_PARENT, COL_DEP_PACKAGE) = (0, 1, 2) | ||
37 | |||
38 | |||
39 | class PackageDepView(Gtk.TreeView): | ||
40 | def __init__(self, model, dep_type, label): | ||
41 | Gtk.TreeView.__init__(self) | ||
42 | self.current = None | ||
43 | self.dep_type = dep_type | ||
44 | self.filter_model = model.filter_new() | ||
45 | self.filter_model.set_visible_func(self._filter, data=None) | ||
46 | self.set_model(self.filter_model) | ||
47 | self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PACKAGE)) | ||
48 | |||
49 | def _filter(self, model, iter, data): | ||
50 | this_type = model[iter][COL_DEP_TYPE] | ||
51 | package = model[iter][COL_DEP_PARENT] | ||
52 | if this_type != self.dep_type: return False | ||
53 | return package == self.current | ||
54 | |||
55 | def set_current_package(self, package): | ||
56 | self.current = package | ||
57 | self.filter_model.refilter() | ||
58 | |||
59 | |||
60 | class PackageReverseDepView(Gtk.TreeView): | ||
61 | def __init__(self, model, label): | ||
62 | Gtk.TreeView.__init__(self) | ||
63 | self.current = None | ||
64 | self.filter_model = model.filter_new() | ||
65 | self.filter_model.set_visible_func(self._filter) | ||
66 | self.set_model(self.filter_model) | ||
67 | self.append_column(Gtk.TreeViewColumn(label, Gtk.CellRendererText(), text=COL_DEP_PARENT)) | ||
68 | |||
69 | def _filter(self, model, iter, data): | ||
70 | package = model[iter][COL_DEP_PACKAGE] | ||
71 | return package == self.current | ||
72 | |||
73 | def set_current_package(self, package): | ||
74 | self.current = package | ||
75 | self.filter_model.refilter() | ||
76 | |||
77 | |||
78 | class DepExplorer(Gtk.Window): | ||
79 | def __init__(self): | ||
80 | Gtk.Window.__init__(self) | ||
81 | self.set_title("Dependency Explorer") | ||
82 | self.set_default_size(500, 500) | ||
83 | self.connect("delete-event", Gtk.main_quit) | ||
84 | |||
85 | # Create the data models | ||
86 | self.pkg_model = Gtk.ListStore(GObject.TYPE_STRING) | ||
87 | self.pkg_model.set_sort_column_id(COL_PKG_NAME, Gtk.SortType.ASCENDING) | ||
88 | self.depends_model = Gtk.ListStore(GObject.TYPE_INT, GObject.TYPE_STRING, GObject.TYPE_STRING) | ||
89 | self.depends_model.set_sort_column_id(COL_DEP_PACKAGE, Gtk.SortType.ASCENDING) | ||
90 | |||
91 | pane = Gtk.HPaned() | ||
92 | pane.set_position(250) | ||
93 | self.add(pane) | ||
94 | |||
95 | # The master list of packages | ||
96 | scrolled = Gtk.ScrolledWindow() | ||
97 | scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) | ||
98 | scrolled.set_shadow_type(Gtk.ShadowType.IN) | ||
99 | |||
100 | self.pkg_treeview = Gtk.TreeView(self.pkg_model) | ||
101 | self.pkg_treeview.get_selection().connect("changed", self.on_cursor_changed) | ||
102 | column = Gtk.TreeViewColumn("Package", Gtk.CellRendererText(), text=COL_PKG_NAME) | ||
103 | self.pkg_treeview.append_column(column) | ||
104 | pane.add1(scrolled) | ||
105 | scrolled.add(self.pkg_treeview) | ||
106 | |||
107 | box = Gtk.VBox(homogeneous=True, spacing=4) | ||
108 | |||
109 | # Runtime Depends | ||
110 | scrolled = Gtk.ScrolledWindow() | ||
111 | scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) | ||
112 | scrolled.set_shadow_type(Gtk.ShadowType.IN) | ||
113 | self.rdep_treeview = PackageDepView(self.depends_model, TYPE_RDEP, "Runtime Depends") | ||
114 | self.rdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) | ||
115 | scrolled.add(self.rdep_treeview) | ||
116 | box.add(scrolled) | ||
117 | |||
118 | # Build Depends | ||
119 | scrolled = Gtk.ScrolledWindow() | ||
120 | scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) | ||
121 | scrolled.set_shadow_type(Gtk.ShadowType.IN) | ||
122 | self.dep_treeview = PackageDepView(self.depends_model, TYPE_DEP, "Build Depends") | ||
123 | self.dep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PACKAGE) | ||
124 | scrolled.add(self.dep_treeview) | ||
125 | box.add(scrolled) | ||
126 | pane.add2(box) | ||
127 | |||
128 | # Reverse Depends | ||
129 | scrolled = Gtk.ScrolledWindow() | ||
130 | scrolled.set_policy(Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.AUTOMATIC) | ||
131 | scrolled.set_shadow_type(Gtk.ShadowType.IN) | ||
132 | self.revdep_treeview = PackageReverseDepView(self.depends_model, "Reverse Depends") | ||
133 | self.revdep_treeview.connect("row-activated", self.on_package_activated, COL_DEP_PARENT) | ||
134 | scrolled.add(self.revdep_treeview) | ||
135 | box.add(scrolled) | ||
136 | pane.add2(box) | ||
137 | |||
138 | self.show_all() | ||
139 | |||
140 | def on_package_activated(self, treeview, path, column, data_col): | ||
141 | model = treeview.get_model() | ||
142 | package = model.get_value(model.get_iter(path), data_col) | ||
143 | |||
144 | pkg_path = [] | ||
145 | def finder(model, path, iter, needle): | ||
146 | package = model.get_value(iter, COL_PKG_NAME) | ||
147 | if package == needle: | ||
148 | pkg_path.append(path) | ||
149 | return True | ||
150 | else: | ||
151 | return False | ||
152 | self.pkg_model.foreach(finder, package) | ||
153 | if pkg_path: | ||
154 | self.pkg_treeview.get_selection().select_path(pkg_path[0]) | ||
155 | self.pkg_treeview.scroll_to_cell(pkg_path[0]) | ||
156 | |||
157 | def on_cursor_changed(self, selection): | ||
158 | (model, it) = selection.get_selected() | ||
159 | if it is None: | ||
160 | current_package = None | ||
161 | else: | ||
162 | current_package = model.get_value(it, COL_PKG_NAME) | ||
163 | self.rdep_treeview.set_current_package(current_package) | ||
164 | self.dep_treeview.set_current_package(current_package) | ||
165 | self.revdep_treeview.set_current_package(current_package) | ||
166 | |||
167 | |||
168 | def parse(self, depgraph): | ||
169 | for package in depgraph["pn"]: | ||
170 | self.pkg_model.insert(0, (package,)) | ||
171 | |||
172 | for package in depgraph["depends"]: | ||
173 | for depend in depgraph["depends"][package]: | ||
174 | self.depends_model.insert (0, (TYPE_DEP, package, depend)) | ||
175 | |||
176 | for package in depgraph["rdepends-pn"]: | ||
177 | for rdepend in depgraph["rdepends-pn"][package]: | ||
178 | self.depends_model.insert (0, (TYPE_RDEP, package, rdepend)) | ||
179 | |||
180 | |||
181 | class gtkthread(threading.Thread): | ||
182 | quit = threading.Event() | ||
183 | def __init__(self, shutdown): | ||
184 | threading.Thread.__init__(self) | ||
185 | self.setDaemon(True) | ||
186 | self.shutdown = shutdown | ||
187 | if not Gtk.init_check()[0]: | ||
188 | sys.stderr.write("Gtk+ init failed. Make sure DISPLAY variable is set.\n") | ||
189 | gtkthread.quit.set() | ||
190 | |||
191 | def run(self): | ||
192 | GObject.threads_init() | ||
193 | Gdk.threads_init() | ||
194 | Gtk.main() | ||
195 | gtkthread.quit.set() | ||
196 | |||
197 | |||
198 | def main(server, eventHandler, params): | ||
199 | shutdown = 0 | ||
200 | |||
201 | gtkgui = gtkthread(shutdown) | ||
202 | gtkgui.start() | ||
203 | |||
204 | try: | ||
205 | params.updateFromServer(server) | ||
206 | cmdline = params.parseActions() | ||
207 | if not cmdline: | ||
208 | print("Nothing to do. Use 'bitbake world' to build everything, or run 'bitbake --help' for usage information.") | ||
209 | return 1 | ||
210 | if 'msg' in cmdline and cmdline['msg']: | ||
211 | print(cmdline['msg']) | ||
212 | return 1 | ||
213 | cmdline = cmdline['action'] | ||
214 | if not cmdline or cmdline[0] != "generateDotGraph": | ||
215 | print("This UI requires the -g option") | ||
216 | return 1 | ||
217 | ret, error = server.runCommand(["generateDepTreeEvent", cmdline[1], cmdline[2]]) | ||
218 | if error: | ||
219 | print("Error running command '%s': %s" % (cmdline, error)) | ||
220 | return 1 | ||
221 | elif ret != True: | ||
222 | print("Error running command '%s': returned %s" % (cmdline, ret)) | ||
223 | return 1 | ||
224 | except client.Fault as x: | ||
225 | print("XMLRPC Fault getting commandline:\n %s" % x) | ||
226 | return | ||
227 | |||
228 | if gtkthread.quit.isSet(): | ||
229 | return | ||
230 | |||
231 | Gdk.threads_enter() | ||
232 | dep = DepExplorer() | ||
233 | bardialog = Gtk.Dialog(parent=dep, | ||
234 | flags=Gtk.DialogFlags.MODAL|Gtk.DialogFlags.DESTROY_WITH_PARENT) | ||
235 | bardialog.set_default_size(400, 50) | ||
236 | box = bardialog.get_content_area() | ||
237 | pbar = Gtk.ProgressBar() | ||
238 | box.pack_start(pbar, True, True, 0) | ||
239 | bardialog.show_all() | ||
240 | bardialog.connect("delete-event", Gtk.main_quit) | ||
241 | Gdk.threads_leave() | ||
242 | |||
243 | progress_total = 0 | ||
244 | while True: | ||
245 | try: | ||
246 | event = eventHandler.waitEvent(0.25) | ||
247 | if gtkthread.quit.isSet(): | ||
248 | _, error = server.runCommand(["stateForceShutdown"]) | ||
249 | if error: | ||
250 | print('Unable to cleanly stop: %s' % error) | ||
251 | break | ||
252 | |||
253 | if event is None: | ||
254 | continue | ||
255 | |||
256 | if isinstance(event, bb.event.CacheLoadStarted): | ||
257 | progress_total = event.total | ||
258 | Gdk.threads_enter() | ||
259 | bardialog.set_title("Loading Cache") | ||
260 | pbar.set_fraction(0.0) | ||
261 | Gdk.threads_leave() | ||
262 | |||
263 | if isinstance(event, bb.event.CacheLoadProgress): | ||
264 | x = event.current | ||
265 | Gdk.threads_enter() | ||
266 | pbar.set_fraction(x * 1.0 / progress_total) | ||
267 | Gdk.threads_leave() | ||
268 | continue | ||
269 | |||
270 | if isinstance(event, bb.event.CacheLoadCompleted): | ||
271 | continue | ||
272 | |||
273 | if isinstance(event, bb.event.ParseStarted): | ||
274 | progress_total = event.total | ||
275 | if progress_total == 0: | ||
276 | continue | ||
277 | Gdk.threads_enter() | ||
278 | pbar.set_fraction(0.0) | ||
279 | bardialog.set_title("Processing recipes") | ||
280 | Gdk.threads_leave() | ||
281 | |||
282 | if isinstance(event, bb.event.ParseProgress): | ||
283 | x = event.current | ||
284 | Gdk.threads_enter() | ||
285 | pbar.set_fraction(x * 1.0 / progress_total) | ||
286 | Gdk.threads_leave() | ||
287 | continue | ||
288 | |||
289 | if isinstance(event, bb.event.ParseCompleted): | ||
290 | Gdk.threads_enter() | ||
291 | bardialog.set_title("Generating dependency tree") | ||
292 | Gdk.threads_leave() | ||
293 | continue | ||
294 | |||
295 | if isinstance(event, bb.event.DepTreeGenerated): | ||
296 | Gdk.threads_enter() | ||
297 | bardialog.hide() | ||
298 | dep.parse(event._depgraph) | ||
299 | Gdk.threads_leave() | ||
300 | |||
301 | if isinstance(event, bb.command.CommandCompleted): | ||
302 | continue | ||
303 | |||
304 | if isinstance(event, bb.event.NoProvider): | ||
305 | if event._runtime: | ||
306 | r = "R" | ||
307 | else: | ||
308 | r = "" | ||
309 | |||
310 | extra = '' | ||
311 | if not event._reasons: | ||
312 | if event._close_matches: | ||
313 | extra = ". Close matches:\n %s" % '\n '.join(event._close_matches) | ||
314 | |||
315 | if event._dependees: | ||
316 | print("Nothing %sPROVIDES '%s' (but %s %sDEPENDS on or otherwise requires it)%s" % (r, event._item, ", ".join(event._dependees), r, extra)) | ||
317 | else: | ||
318 | print("Nothing %sPROVIDES '%s'%s" % (r, event._item, extra)) | ||
319 | if event._reasons: | ||
320 | for reason in event._reasons: | ||
321 | print(reason) | ||
322 | |||
323 | _, error = server.runCommand(["stateShutdown"]) | ||
324 | if error: | ||
325 | print('Unable to cleanly shutdown: %s' % error) | ||
326 | break | ||
327 | |||
328 | if isinstance(event, bb.command.CommandFailed): | ||
329 | print("Command execution failed: %s" % event.error) | ||
330 | return event.exitcode | ||
331 | |||
332 | if isinstance(event, bb.command.CommandExit): | ||
333 | return event.exitcode | ||
334 | |||
335 | if isinstance(event, bb.cooker.CookerExit): | ||
336 | break | ||
337 | |||
338 | continue | ||
339 | except EnvironmentError as ioerror: | ||
340 | # ignore interrupted io | ||
341 | if ioerror.args[0] == 4: | ||
342 | pass | ||
343 | except KeyboardInterrupt: | ||
344 | if shutdown == 2: | ||
345 | print("\nThird Keyboard Interrupt, exit.\n") | ||
346 | break | ||
347 | if shutdown == 1: | ||
348 | print("\nSecond Keyboard Interrupt, stopping...\n") | ||
349 | _, error = server.runCommand(["stateForceShutdown"]) | ||
350 | if error: | ||
351 | print('Unable to cleanly stop: %s' % error) | ||
352 | if shutdown == 0: | ||
353 | print("\nKeyboard Interrupt, closing down...\n") | ||
354 | _, error = server.runCommand(["stateShutdown"]) | ||
355 | if error: | ||
356 | print('Unable to cleanly shutdown: %s' % error) | ||
357 | shutdown = shutdown + 1 | ||
358 | pass | ||