Ejemplo n.º 1
0
def main():
    """Run the graph generation script."""
    import os
    import sys

    from optparse import OptionParser

    from gmxtree import GromacsTree
    from reporter import Reporter

    parser = OptionParser()
    parser.add_option('-S', '--source-root', help='Source tree root directory')
    parser.add_option('-B', '--build-root', help='Build tree root directory')
    parser.add_option(
        '--ignore-cycles',
        help='Set file with module dependencies to ignore in cycles')
    parser.add_option('-o',
                      '--outdir',
                      default='.',
                      help='Specify output directory for graphs')
    parser.add_option('-q',
                      '--quiet',
                      action='store_true',
                      help='Do not write status messages')
    options, args = parser.parse_args()

    reporter = Reporter(quiet=True)

    if not options.quiet:
        sys.stderr.write('Scanning source tree...\n')
    tree = GromacsTree(options.source_root, options.build_root, reporter)
    if not options.quiet:
        sys.stderr.write('Reading source files...\n')
    tree.scan_files()
    if options.ignore_cycles:
        tree.load_cycle_suppression_list(options.ignore_cycles)
    if not options.quiet:
        sys.stderr.write('Reading Doxygen XML files...\n')
    tree.load_xml(only_files=True)

    if not options.quiet:
        sys.stderr.write('Writing graphs...\n')
    graphbuilder = GraphBuilder(tree)
    if not os.path.exists(options.outdir):
        os.mkdir(options.outdir)

    filename = os.path.join(options.outdir, 'module-deps.dot')
    graph = graphbuilder.create_modules_graph()
    with open(filename, 'w') as outfile:
        graph.write(outfile)

    # Skip some modules that are too big to make any sense
    skippedmodules = ('gmxlib', 'mdlib', 'gmxana', 'gmxpreprocess')
    for module in tree.get_modules():
        if not module.get_name()[7:] in skippedmodules:
            filename = '{0}-deps.dot'.format(module.get_name())
            filename = os.path.join(options.outdir, filename)
            graph = graphbuilder.create_module_file_graph(module)
            with open(filename, 'w') as outfile:
                graph.write(outfile)
Ejemplo n.º 2
0
def main():
    """Run the checking script."""
    parser = OptionParser()
    parser.add_option('-S', '--source-root', help='Source tree root directory')
    parser.add_option('-B', '--build-root', help='Build tree root directory')
    parser.add_option(
        '-l',
        '--log',
        help='Write issues into a given log file in addition to stderr')
    parser.add_option('--ignore',
                      help='Set file with patterns for messages to ignore')
    parser.add_option(
        '--ignore-cycles',
        help='Set file with module dependencies to ignore in cycles')
    parser.add_option('--check-ignored',
                      action='store_true',
                      help='Issue notes for comments ignored by Doxygen')
    parser.add_option('-q',
                      '--quiet',
                      action='store_true',
                      help='Do not write status messages')
    parser.add_option('--exitcode',
                      action='store_true',
                      help='Return non-zero exit code if there are warnings')
    options, args = parser.parse_args()

    reporter = Reporter(options.log)
    if options.ignore:
        reporter.load_filters(options.ignore)

    if not options.quiet:
        sys.stderr.write('Scanning source tree...\n')
    tree = GromacsTree(options.source_root, options.build_root, reporter)
    tree.load_git_attributes()
    tree.load_installed_file_list()
    if not options.quiet:
        sys.stderr.write('Reading source files...\n')
    # TODO: The checking should be possible without storing everything in memory
    tree.scan_files(keep_contents=True)
    if options.ignore_cycles:
        tree.load_cycle_suppression_list(options.ignore_cycles)
    if not options.quiet:
        sys.stderr.write('Reading Doxygen XML files...\n')
    tree.load_xml()

    reporter.write_pending()

    if not options.quiet:
        sys.stderr.write('Checking...\n')

    check_all(tree, reporter, options.check_ignored)

    reporter.write_pending()
    reporter.report_unused_filters()
    reporter.close_log()

    if options.exitcode and reporter.had_warnings():
        sys.exit(1)
Ejemplo n.º 3
0
def main():
    """Run the graph generation script."""
    import os
    import sys

    from optparse import OptionParser

    from gmxtree import GromacsTree
    from reporter import Reporter

    parser = OptionParser()
    parser.add_option('-S', '--source-root',
                      help='Source tree root directory')
    parser.add_option('-B', '--build-root',
                      help='Build tree root directory')
    parser.add_option('--ignore-cycles',
                      help='Set file with module dependencies to ignore in cycles')
    parser.add_option('-o', '--outdir', default='.',
                      help='Specify output directory for graphs')
    parser.add_option('-q', '--quiet', action='store_true',
                      help='Do not write status messages')
    options, args = parser.parse_args()

    reporter = Reporter(quiet=True)

    if not options.quiet:
        sys.stderr.write('Scanning source tree...\n')
    tree = GromacsTree(options.source_root, options.build_root, reporter)
    tree.load_installed_file_list()
    if not options.quiet:
        sys.stderr.write('Reading source files...\n')
    tree.scan_files()
    if options.ignore_cycles:
        tree.load_cycle_suppression_list(options.ignore_cycles)
    if not options.quiet:
        sys.stderr.write('Reading Doxygen XML files...\n')
    tree.load_xml(only_files=True)

    if not options.quiet:
        sys.stderr.write('Writing graphs...\n')
    graphbuilder = GraphBuilder(tree)
    if not os.path.exists(options.outdir):
        os.mkdir(options.outdir)

    filename = os.path.join(options.outdir, 'module-deps.dot')
    graph = graphbuilder.create_modules_graph()
    with open(filename, 'w') as outfile:
        graph.write(outfile)

    # Skip some modules that are too big to make any sense
    skippedmodules = ('legacyheaders', 'gmxlib', 'mdlib', 'gmxana', 'gmxpreprocess')
    for module in tree.get_modules():
        if not module.get_name()[7:] in skippedmodules:
            filename = '{0}-deps.dot'.format(module.get_name())
            filename = os.path.join(options.outdir, filename)
            graph = graphbuilder.create_module_file_graph(module)
            with open(filename, 'w') as outfile:
                graph.write(outfile)
Ejemplo n.º 4
0
def main():
    """Run the checking script."""
    parser = OptionParser()
    parser.add_option('-S', '--source-root',
                      help='Source tree root directory')
    parser.add_option('-B', '--build-root',
                      help='Build tree root directory')
    parser.add_option('-l', '--log',
                      help='Write issues into a given log file in addition to stderr')
    parser.add_option('--ignore',
                      help='Set file with patterns for messages to ignore')
    parser.add_option('--ignore-cycles',
                      help='Set file with module dependencies to ignore in cycles')
    parser.add_option('--check-ignored', action='store_true',
                      help='Issue notes for comments ignored by Doxygen')
    parser.add_option('-q', '--quiet', action='store_true',
                      help='Do not write status messages')
    parser.add_option('--exitcode', action='store_true',
                      help='Return non-zero exit code if there are warnings')
    options, args = parser.parse_args()

    reporter = Reporter(options.log)
    if options.ignore:
        reporter.load_filters(options.ignore)

    if not options.quiet:
        sys.stderr.write('Scanning source tree...\n')
    tree = GromacsTree(options.source_root, options.build_root, reporter)
    tree.load_git_attributes()
    tree.load_installed_file_list()
    if not options.quiet:
        sys.stderr.write('Reading source files...\n')
    # TODO: The checking should be possible without storing everything in memory
    tree.scan_files(keep_contents=True)
    if not options.quiet:
        sys.stderr.write('Finding config.h and other preprocessor macro uses...\n')
    tree.find_define_file_uses()
    if options.ignore_cycles:
        tree.load_cycle_suppression_list(options.ignore_cycles)
    if not options.quiet:
        sys.stderr.write('Reading Doxygen XML files...\n')
    tree.load_xml()

    reporter.write_pending()

    if not options.quiet:
        sys.stderr.write('Checking...\n')

    check_all(tree, reporter, options.check_ignored)

    reporter.write_pending()
    reporter.report_unused_filters()
    reporter.close_log()

    if options.exitcode and reporter.had_warnings():
        sys.exit(1)
Ejemplo n.º 5
0
def main():
    """Run the checking script."""
    parser = OptionParser()
    parser.add_option('-S', '--source-root',
                      help='Source tree root directory')
    parser.add_option('-B', '--build-root',
                      help='Build tree root directory')
    parser.add_option('--installed',
                      help='Read list of installed files from given file')
    parser.add_option('-l', '--log',
                      help='Write issues into a given log file in addition to stderr')
    parser.add_option('--ignore',
                      help='Set file with patterns for messages to ignore')
    parser.add_option('--ignore-cycles',
                      help='Set file with module dependencies to ignore in cycles')
    parser.add_option('--check-ignored', action='store_true',
                      help='Issue notes for comments ignored by Doxygen')
    parser.add_option('-q', '--quiet', action='store_true',
                      help='Do not write status messages')
    options, args = parser.parse_args()

    installedlist = []
    if options.installed:
        with open(options.installed, 'r') as outfile:
            for line in outfile:
                installedlist.append(line.strip())

    reporter = Reporter(options.log)
    if options.ignore:
        reporter.load_filters(options.ignore)

    if not options.quiet:
        sys.stderr.write('Scanning source tree...\n')
    tree = GromacsTree(options.source_root, options.build_root, reporter)
    tree.set_installed_file_list(installedlist)
    if not options.quiet:
        sys.stderr.write('Reading source files...\n')
    tree.scan_files()
    if options.ignore_cycles:
        tree.load_cycle_suppression_list(options.ignore_cycles)
    if not options.quiet:
        sys.stderr.write('Reading Doxygen XML files...\n')
    tree.load_xml()

    reporter.write_pending()

    if not options.quiet:
        sys.stderr.write('Checking...\n')

    for fileobj in tree.get_files():
        check_file(fileobj, reporter)
        for includedfile in fileobj.get_includes():
            check_include(fileobj, includedfile, reporter)

    for classobj in tree.get_classes():
        check_class(classobj, reporter)

    for memberobj in tree.get_members():
        check_member(memberobj, reporter, options.check_ignored)

    check_cycles(ModuleDependencyGraph(tree), reporter)

    reporter.write_pending()
    reporter.report_unused_filters()
    reporter.close_log()