| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # | 2 # |
| 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. | 3 # Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
| 5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
| 6 | 6 |
| 7 """Runs findbugs, and returns an error code if there are new warnings. | 7 """Runs findbugs, and returns an error code if there are new warnings. |
| 8 | 8 |
| 9 Other options | 9 Other options |
| 10 --only-analyze used to only analyze the class you are interested. | 10 --only-analyze used to only analyze the class you are interested. |
| 11 --relase-build analyze the classes in out/Release directory. | 11 --relase-build analyze the classes in out/Release directory. |
| 12 --findbugs-args used to passin other findbugs's options. | 12 --findbugs-args used to passin other findbugs's options. |
| 13 | 13 |
| 14 Run | 14 Run |
| 15 $CHROMIUM_SRC/third_party/findbugs/bin/findbugs -textui for details. | 15 $CHROMIUM_SRC/third_party/findbugs/bin/findbugs -textui for details. |
| 16 | 16 |
| 17 """ | 17 """ |
| 18 | 18 |
| 19 import argparse | 19 import argparse |
| 20 import os | 20 import os |
| 21 import sys | 21 import sys |
| 22 | 22 |
| 23 import devil_chromium |
| 23 from devil.utils import run_tests_helper | 24 from devil.utils import run_tests_helper |
| 24 from pylib import constants | 25 |
| 26 from pylib.constants import host_paths |
| 25 from pylib.utils import findbugs | 27 from pylib.utils import findbugs |
| 26 | 28 |
| 27 _DEFAULT_BASE_DIR = os.path.join( | 29 _DEFAULT_BASE_DIR = os.path.join( |
| 28 constants.DIR_SOURCE_ROOT, 'build', 'android', 'findbugs_filter') | 30 host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'findbugs_filter') |
| 29 | 31 |
| 30 sys.path.append( | 32 sys.path.append( |
| 31 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', 'gyp')) | 33 os.path.join(host_paths.DIR_SOURCE_ROOT, 'build', 'android', 'gyp')) |
| 32 from util import build_utils # pylint: disable=import-error | 34 from util import build_utils # pylint: disable=import-error |
| 33 | 35 |
| 34 | 36 |
| 35 def main(): | 37 def main(): |
| 36 parser = argparse.ArgumentParser() | 38 parser = argparse.ArgumentParser() |
| 37 | 39 |
| 38 parser.add_argument( | 40 parser.add_argument( |
| 39 '-v', '--verbose', action='count', help='Enable verbose logging.') | 41 '-v', '--verbose', action='count', help='Enable verbose logging.') |
| 40 parser.add_argument( | 42 parser.add_argument( |
| 41 '-a', '--auxclasspath', default=None, dest='auxclasspath', | 43 '-a', '--auxclasspath', default=None, dest='auxclasspath', |
| (...skipping 26 matching lines...) Expand all Loading... |
| 68 "action's first output.") | 70 "action's first output.") |
| 69 | 71 |
| 70 parser.add_argument( | 72 parser.add_argument( |
| 71 'jar_paths', metavar='JAR_PATH', nargs='+', | 73 'jar_paths', metavar='JAR_PATH', nargs='+', |
| 72 help='JAR file to analyze') | 74 help='JAR file to analyze') |
| 73 | 75 |
| 74 args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:])) | 76 args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:])) |
| 75 | 77 |
| 76 run_tests_helper.SetLogLevel(args.verbose) | 78 run_tests_helper.SetLogLevel(args.verbose) |
| 77 | 79 |
| 80 devil_chromium.Initialize() |
| 81 |
| 78 if args.auxclasspath: | 82 if args.auxclasspath: |
| 79 args.auxclasspath = args.auxclasspath.split(':') | 83 args.auxclasspath = args.auxclasspath.split(':') |
| 80 elif args.auxclasspath_gyp: | 84 elif args.auxclasspath_gyp: |
| 81 args.auxclasspath = build_utils.ParseGypList(args.auxclasspath_gyp) | 85 args.auxclasspath = build_utils.ParseGypList(args.auxclasspath_gyp) |
| 82 | 86 |
| 83 if args.base_dir: | 87 if args.base_dir: |
| 84 if not args.exclude: | 88 if not args.exclude: |
| 85 args.exclude = os.path.join(args.base_dir, 'findbugs_exclude.xml') | 89 args.exclude = os.path.join(args.base_dir, 'findbugs_exclude.xml') |
| 86 | 90 |
| 87 findbugs_command, findbugs_warnings = findbugs.Run( | 91 findbugs_command, findbugs_warnings = findbugs.Run( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 107 + args.jar_paths) | 111 + args.jar_paths) |
| 108 if args.stamp: | 112 if args.stamp: |
| 109 build_utils.Touch(args.stamp) | 113 build_utils.Touch(args.stamp) |
| 110 | 114 |
| 111 return len(findbugs_warnings) | 115 return len(findbugs_warnings) |
| 112 | 116 |
| 113 | 117 |
| 114 if __name__ == '__main__': | 118 if __name__ == '__main__': |
| 115 sys.exit(main()) | 119 sys.exit(main()) |
| 116 | 120 |
| OLD | NEW |