Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Side by Side Diff: build/android/findbugs_diff.py

Issue 1000793002: [Android] Incorporate findbugs into android builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 This runs findbugs with an additional flag to exclude known bugs.
9 To update the list of known bugs, do this:
10
11 findbugs_diff.py --rebaseline
12
13 Note that this is separate from findbugs_exclude.xml. The "exclude" file has
14 false positives that we do not plan to fix. The "known bugs" file has real
15 bugs that we *do* plan to fix (but haven't done so yet).
16 8
17 Other options 9 Other options
18 --only-analyze used to only analyze the class you are interested. 10 --only-analyze used to only analyze the class you are interested.
19 --relase-build analyze the classes in out/Release directory. 11 --relase-build analyze the classes in out/Release directory.
20 --findbugs-args used to passin other findbugs's options. 12 --findbugs-args used to passin other findbugs's options.
21 13
22 Run 14 Run
23 $CHROM_SRC/third_party/findbugs/bin/findbugs -textui for details. 15 $CHROMIUM_SRC/third_party/findbugs/bin/findbugs -textui for details.
24 16
25 """ 17 """
26 18
19 import argparse
27 import os 20 import os
28 import sys 21 import sys
29 22
30 from pylib import constants 23 from pylib import constants
31 from pylib.utils import findbugs 24 from pylib.utils import findbugs
32 25
26 _DEFAULT_BASE_DIR = os.path.join(
27 constants.DIR_SOURCE_ROOT, 'build', 'android', 'findbugs_filter')
28
29 sys.path.append(
30 os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', 'gyp'))
31 from util import build_utils
32
33 33
34 def main(): 34 def main():
35 parser = findbugs.GetCommonParser() 35 parser = argparse.ArgumentParser()
36 36
37 options, _ = parser.parse_args() 37 parser.add_argument(
38 '-a', '--auxclasspath', default=None, dest='auxclasspath',
39 help='Set aux classpath for analysis.')
40 parser.add_argument(
41 '--auxclasspath-gyp', dest='auxclasspath_gyp',
42 help='A gyp list containing the aux classpath for analysis')
43 parser.add_argument(
44 '-o', '--only-analyze', default=None,
45 dest='only_analyze', help='Only analyze the given classes and packages.')
46 parser.add_argument(
47 '-e', '--exclude', default=None, dest='exclude',
48 help='Exclude bugs matching given filter.')
49 parser.add_argument(
50 '-l', '--release-build', action='store_true', dest='release_build',
51 help='Analyze release build instead of debug.')
52 parser.add_argument(
53 '-f', '--findbug-args', default=None, dest='findbug_args',
54 help='Additional findbug arguments.')
55 parser.add_argument(
56 '-b', '--base-dir', default=_DEFAULT_BASE_DIR,
57 dest='base_dir', help='Base directory for configuration file.')
58 parser.add_argument(
59 '--output-file', dest='output_file',
60 help='Path to save the output to.')
61 parser.add_argument(
62 '--stamp', help='Path to touch on success.')
63 parser.add_argument(
64 '--depfile', help='Path to the depfile. This must be specified as the '
65 "action's first output.")
38 66
39 if not options.base_dir: 67 parser.add_argument(
40 options.base_dir = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 68 'jar_paths', metavar='JAR_PATH', nargs='+',
41 'android', 'findbugs_filter') 69 help='JAR file to analyze')
42 if not options.only_analyze:
43 options.only_analyze = 'org.chromium.-'
44 70
45 return findbugs.Run(options) 71 args = parser.parse_args(build_utils.ExpandFileArgs(sys.argv[1:]))
72 if args.auxclasspath:
73 args.auxclasspath = args.auxclasspath.split(':')
74 elif args.auxclasspath_gyp:
75 args.auxclasspath = build_utils.ParseGypList(args.auxclasspath_gyp)
76
77 if args.base_dir:
78 if not args.exclude:
79 args.exclude = os.path.join(args.base_dir, 'findbugs_exclude.xml')
80
81 findbugs_command, findbugs_warnings = findbugs.Run(
82 args.exclude, args.only_analyze, args.auxclasspath,
83 args.output_file, args.findbug_args, args.jar_paths)
84
85 if findbugs_warnings:
86 print
87 print '*' * 80
88 print 'FindBugs run via:'
89 print findbugs_command
90 print
91 print 'FindBugs reported the following issues:'
92 for warning in sorted(findbugs_warnings):
93 print str(warning)
94 print '*' * 80
95 print
96 elif args.stamp:
97 build_utils.Touch(args.stamp)
98
99 return len(findbugs_warnings)
46 100
47 101
48 if __name__ == '__main__': 102 if __name__ == '__main__':
49 sys.exit(main()) 103 sys.exit(main())
104
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698