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)
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('--check-ignored', action='store_true', help='Check documentation 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 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(): if memberobj.is_visible() or options.check_ignored: check_member(memberobj, reporter) reporter.write_pending() reporter.report_unused_filters() reporter.close_log()
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)
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)
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)
def main(): """Run the include sorter 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('-F', '--files', help='Specify files to sort') parser.add_option('-q', '--quiet', action='store_true', help='Do not write status messages') # This is for evaluating different options; can be removed from the final # version. parser.add_option('-s', '--style', type='choice', default='pub-priv', choices=('single-group', 'pub-priv', 'pub-local'), help='Style for Gromacs includes') parser.add_option('--absolute', action='store_true', help='Write all include paths relative to src/') options, args = parser.parse_args() filelist = args if options.files: if options.files == '-': lines = sys.stdin.readlines() else: with open(options.files, 'r') as fp: lines = fp.readlines() filelist.extend([x.strip() for x in lines]) 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() files = [] for filename in filelist: fileobj = tree.get_file(os.path.abspath(filename)) if not fileobj: sys.stderr.write( 'warning: ignoring unknown file {0}\n'.format(filename)) continue files.append(fileobj) if not options.quiet: sys.stderr.write('Reading source files...\n') tree.scan_files(only_files=files, keep_contents=True) extfiles = set(files) for fileobj in files: for included_file in fileobj.get_includes(): other_file = included_file.get_file() if other_file: extfiles.add(other_file) if not options.quiet: sys.stderr.write('Reading Doxygen XML files...\n') tree.load_xml(only_files=extfiles) if not options.quiet: sys.stderr.write('Sorting includes...\n') sorter = IncludeSorter(GroupedSorter(options.style, options.absolute), options.quiet) for fileobj in files: sorter.sort_includes(fileobj)
def main(): """Run the include sorter 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("-F", "--files", help="Specify files to sort") parser.add_option("-q", "--quiet", action="store_true", help="Do not write status messages") # This is for evaluating different options; can be removed from the final # version. parser.add_option( "-s", "--style", type="choice", default="pub-priv", choices=("single-group", "pub-priv", "pub-local"), help="Style for GROMACS includes", ) parser.add_option("--absolute", action="store_true", help="Write all include paths relative to src/") options, args = parser.parse_args() filelist = args if options.files: if options.files == "-": lines = sys.stdin.readlines() else: with open(options.files, "r") as fp: lines = fp.readlines() filelist.extend([x.strip() for x in lines]) 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() files = [] for filename in filelist: fileobj = tree.get_file(os.path.abspath(filename)) if not fileobj: sys.stderr.write("warning: ignoring unknown file {0}\n".format(filename)) continue files.append(fileobj) if not options.quiet: sys.stderr.write("Reading source files...\n") tree.scan_files(only_files=files, keep_contents=True) extfiles = set(files) for fileobj in files: for included_file in fileobj.get_includes(): other_file = included_file.get_file() if other_file: extfiles.add(other_file) if not options.quiet: sys.stderr.write("Reading Doxygen XML files...\n") tree.load_xml(only_files=extfiles) if not options.quiet: sys.stderr.write("Sorting includes...\n") sorter = IncludeSorter(GroupedSorter(options.style, options.absolute), options.quiet) for fileobj in files: sorter.sort_includes(fileobj)
def main(): """Run the include sorter 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('-F', '--files', help='Specify files to sort') parser.add_option('-q', '--quiet', action='store_true', help='Do not write status messages') # This is for evaluating different options; can be removed from the final # version. parser.add_option('-s', '--style', type='choice', default='pub-priv', choices=('single-group', 'pub-priv', 'pub-local'), help='Style for GROMACS includes') parser.add_option('--absolute', action='store_true', help='Write all include paths relative to src/') options, args = parser.parse_args() filelist = args if options.files: if options.files == '-': lines = sys.stdin.readlines() else: with open(options.files, 'r') as fp: lines = fp.readlines() filelist.extend([x.strip() for x in lines]) 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() files = [] for filename in filelist: fileobj = tree.get_file(os.path.abspath(filename)) if not fileobj: sys.stderr.write('warning: ignoring unknown file {0}\n'.format(filename)) continue files.append(fileobj) if not options.quiet: sys.stderr.write('Reading source files...\n') tree.scan_files(only_files=files, keep_contents=True) extfiles = set(files) for fileobj in files: for included_file in fileobj.get_includes(): other_file = included_file.get_file() if other_file: extfiles.add(other_file) if not options.quiet: sys.stderr.write('Reading Doxygen XML files...\n') tree.load_xml(only_files=extfiles) if not options.quiet: sys.stderr.write('Sorting includes...\n') sorter = IncludeSorter(GroupedSorter(options.style, options.absolute), options.quiet) for fileobj in files: sorter.sort_includes(fileobj)
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('--check-ignored', action='store_true', help='Check documentation 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 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(): if memberobj.is_visible() or options.check_ignored: check_member(memberobj, reporter) reporter.write_pending() reporter.report_unused_filters() reporter.close_log()