From 24df4ecb630b9e84c9c95773b1ba27a49cad2f62 Mon Sep 17 00:00:00 2001 From: Laszlo Nagy Date: Thu, 29 Jan 2015 17:14:39 +0100 Subject: [PATCH] scripts: entry points moved to scripts --- analyzer/bear.py | 23 ++--------------------- analyzer/beye.py | 27 +-------------------------- bin/bear | 22 ++++++++++++++++++++-- bin/beye | 17 +++++++++++++---- bin/scan-build | 18 ++++++++++++++---- 5 files changed, 50 insertions(+), 57 deletions(-) diff --git a/analyzer/bear.py b/analyzer/bear.py index 3097618..57e6c99 100644 --- a/analyzer/bear.py +++ b/analyzer/bear.py @@ -32,11 +32,11 @@ import pkg_resources import itertools from analyzer import duplicate_check, tempdir -from analyzer.decorators import to_logging_level, trace, entry -from analyzer.options import create_parser +from analyzer.decorators import trace from analyzer.command import classify_parameters from analyzer.command import Action + if 'darwin' == sys.platform: ENVIRONMENTS = [("ENV_OUTPUT", "BEAR_OUTPUT"), ("ENV_PRELOAD", "DYLD_INSERT_LIBRARIES"), @@ -46,25 +46,6 @@ ("ENV_PRELOAD", "LD_PRELOAD")] -@entry -def bear(): - """ Entry point for 'bear'. - - This part initializes some parts and forwards to the main method. """ - - parser = create_parser('bear') - args = parser.parse_args() - - logging.getLogger().setLevel(to_logging_level(args.verbose)) - logging.debug(args) - - if args.help or 0 == len(args.build): - parser.print_help() - return 0 - - return main(args) - - def main(args): """ The reusable entry point of 'bear'. diff --git a/analyzer/beye.py b/analyzer/beye.py index 597916a..ac7f33c 100644 --- a/analyzer/beye.py +++ b/analyzer/beye.py @@ -21,38 +21,13 @@ import tempfile import multiprocessing from analyzer import tempdir -from analyzer.options import create_parser -from analyzer.decorators import to_logging_level, trace, entry +from analyzer.decorators import to_logging_level, trace from analyzer.command import generate_commands from analyzer.runner import run from analyzer.report import document from analyzer.clang import get_checkers -@entry -def scanbuild(): - """ Entry point for 'scan-build' command. - - This method combines the 'bear' and 'beye' commands to imitate the - original Perl implementation of 'scan-build' command. """ - - from analyzer.bear import main as run_bear - parser = create_parser('scan-build') - return main(parser, run_bear) - - -@entry -def beye(): - """ Entry point for 'beye' command. - - It takes a compilation database as input and run analyzer against each - files. The logic to run analyzer against a single file is implemented in - several modules. """ - - parser = create_parser('beye') - return main(parser, lambda x: 0) - - def main(parser, intercept): """ The reusable entry point of 'beye'. diff --git a/bin/bear b/bin/bear index 47ed087..f343547 100755 --- a/bin/bear +++ b/bin/bear @@ -6,7 +6,25 @@ # License. See LICENSE.TXT for details. import sys -from analyzer.bear import bear +import logging +from analyzer.decorators import to_logging_level, entry +from analyzer.options import create_parser +from analyzer.bear import main as run_bear + + +@entry +def main(): + parser = create_parser('bear') + args = parser.parse_args() + + logging.getLogger().setLevel(to_logging_level(args.verbose)) + logging.debug(args) + + if args.help or 0 == len(args.build): + parser.print_help() + return 0 + return run_bear(args) + if __name__ == '__main__': - sys.exit(bear()) + sys.exit(main()) diff --git a/bin/beye b/bin/beye index 29580ce..9bcb063 100755 --- a/bin/beye +++ b/bin/beye @@ -6,9 +6,18 @@ # License. See LICENSE.TXT for details. import sys -from multiprocessing import freeze_support -from analyzer.beye import beye +import multiprocessing +from analyzer.options import create_parser +from analyzer.decorators import entry +from analyzer.beye import main as run_beye + + +@entry +def main(): + parser = create_parser('beye') + return run_beye(parser, lambda x: 0) + if __name__ == '__main__': - freeze_support() - sys.exit(beye()) + multiprocessing.freeze_support() + sys.exit(main()) diff --git a/bin/scan-build b/bin/scan-build index 299b72e..ec4fd36 100755 --- a/bin/scan-build +++ b/bin/scan-build @@ -6,9 +6,19 @@ # License. See LICENSE.TXT for details. import sys -from multiprocessing import freeze_support -from analyzer.beye import scanbuild +import multiprocessing +from analyzer.options import create_parser +from analyzer.decorators import entry +from analyzer.bear import main as run_bear +from analyzer.beye import main as run_beye + + +@entry +def main(): + parser = create_parser('scan-build') + return run_beye(parser, run_bear) + if __name__ == '__main__': - freeze_support() - sys.exit(scanbuild()) + multiprocessing.freeze_support() + sys.exit(main())