Skip to content

Commit

Permalink
scripts: entry points moved to scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
rizsotto committed Jan 29, 2015
1 parent 2dacbf3 commit 24df4ec
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 57 deletions.
23 changes: 2 additions & 21 deletions analyzer/bear.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand All @@ -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'.
Expand Down
27 changes: 1 addition & 26 deletions analyzer/beye.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand Down
22 changes: 20 additions & 2 deletions bin/bear
Original file line number Diff line number Diff line change
Expand Up @@ -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())
17 changes: 13 additions & 4 deletions bin/beye
Original file line number Diff line number Diff line change
Expand Up @@ -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())
18 changes: 14 additions & 4 deletions bin/scan-build
Original file line number Diff line number Diff line change
Expand Up @@ -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())

0 comments on commit 24df4ec

Please sign in to comment.