| #!/usr/bin/env python |
| # Copyright 2015 The Chromium Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| """Produces a dot file showing dependency relationships between modules. |
| |
| The dot file contains a text-based representation of a directed graph that |
| explains why given module names were included in a trace_viewer config. |
| |
| Example usage: |
| $ ./why_imported core.analysis.analysis_view > ~/analysis_view.dot |
| |
| This can then be converted to a graphical representation with the dot tool: |
| $ dot -Grankdir=LR -Tpng ~/analysis_view.dot -o ~/analysis_view.png |
| """ |
| |
| import sys |
| import optparse |
| |
| from trace_viewer import trace_viewer_project |
| |
| |
| def Main(args): |
| project = trace_viewer_project.TraceViewerProject() |
| |
| parser = optparse.OptionParser( |
| usage='%prog <options> moduleNames', epilog=__doc__) |
| parser.add_option( |
| '--config', type='choice', choices=project.GetConfigNames()) |
| options, args = parser.parse_args(args) |
| |
| if options.config: |
| names = ['trace_viewer', |
| project.GetModuleNameForConfigName(options.config)] |
| load_sequence = project.CalcLoadSequenceForModuleNames(names) |
| else: |
| load_sequence = None |
| print project.GetDominatorGraphForModulesNamed(args, load_sequence) |
| |
| |
| if __name__ == '__main__': |
| sys.exit(Main(sys.argv[1:])) |