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

Side by Side Diff: build/android/pylib/utils/findbugs.py

Issue 217893002: Revert "Don't hardcode output directory in findbugs.py" (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
« no previous file with comments | « build/android/buildbot/bb_host_steps.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import optparse 5 import optparse
6 import os 6 import os
7 import re 7 import re
8 import shlex 8 import shlex
9 import subprocess 9 import subprocess
10 import sys 10 import sys
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 return count 59 return count
60 60
61 61
62 def _Rebaseline(current_warnings_set, known_bugs_file): 62 def _Rebaseline(current_warnings_set, known_bugs_file):
63 with file(known_bugs_file, 'w') as known_bugs: 63 with file(known_bugs_file, 'w') as known_bugs:
64 for warning in sorted(current_warnings_set): 64 for warning in sorted(current_warnings_set):
65 print >> known_bugs, warning 65 print >> known_bugs, warning
66 return 0 66 return 0
67 67
68 68
69 def _GetChromeClasses(): 69 def _GetChromeClasses(release_version):
70 path = constants.GetOutDirectory() 70 version = 'Debug'
71 if release_version:
72 version = 'Release'
73 path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version)
71 cmd = 'find %s -name "*.class"' % path 74 cmd = 'find %s -name "*.class"' % path
72 out = cmd_helper.GetCmdOutput(shlex.split(cmd)) 75 out = cmd_helper.GetCmdOutput(shlex.split(cmd))
73 if not out: 76 if not out:
74 print 'No classes found in %s' % path 77 print 'No classes found in %s' % path
75 return out 78 return out
76 79
77 80
78 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes, 81 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes,
79 rebaseline, findbug_args): 82 rebaseline, release_version, findbug_args):
80 """Run the FindBugs. 83 """Run the FindBugs.
81 84
82 Args: 85 Args:
83 exclude: the exclude xml file, refer to FindBugs's -exclude command option. 86 exclude: the exclude xml file, refer to FindBugs's -exclude command option.
84 known_bugs: the text file of known bugs. The bugs in it will not be 87 known_bugs: the text file of known bugs. The bugs in it will not be
85 reported. 88 reported.
86 classes_to_analyze: the list of classes need to analyze, refer to FindBug's 89 classes_to_analyze: the list of classes need to analyze, refer to FindBug's
87 -onlyAnalyze command line option. 90 -onlyAnalyze command line option.
88 auxiliary_classes: the classes help to analyze, refer to FindBug's 91 auxiliary_classes: the classes help to analyze, refer to FindBug's
89 -auxclasspath command line option. 92 -auxclasspath command line option.
90 rebaseline: True if the known_bugs file needs rebaseline. 93 rebaseline: True if the known_bugs file needs rebaseline.
94 release_version: True if the release version needs check, otherwise check
95 debug version.
91 findbug_args: addtional command line options needs pass to Findbugs. 96 findbug_args: addtional command line options needs pass to Findbugs.
92 """ 97 """
93 98
94 chrome_src = constants.DIR_SOURCE_ROOT 99 chrome_src = constants.DIR_SOURCE_ROOT
95 sdk_root = constants.ANDROID_SDK_ROOT 100 sdk_root = constants.ANDROID_SDK_ROOT
96 sdk_version = constants.ANDROID_SDK_VERSION 101 sdk_version = constants.ANDROID_SDK_VERSION
97 102
98 system_classes = [] 103 system_classes = []
99 system_classes.append(os.path.join(sdk_root, 'platforms', 104 system_classes.append(os.path.join(sdk_root, 'platforms',
100 'android-%s' % sdk_version, 'android.jar')) 105 'android-%s' % sdk_version, 'android.jar'))
(...skipping 22 matching lines...) Expand all
123 128
124 if classes_to_analyze: 129 if classes_to_analyze:
125 cmd = '%s -onlyAnalyze %s ' % (cmd, classes_to_analyze) 130 cmd = '%s -onlyAnalyze %s ' % (cmd, classes_to_analyze)
126 131
127 if exclude: 132 if exclude:
128 cmd = '%s -exclude %s ' % (cmd, os.path.abspath(exclude)) 133 cmd = '%s -exclude %s ' % (cmd, os.path.abspath(exclude))
129 134
130 if findbug_args: 135 if findbug_args:
131 cmd = '%s %s ' % (cmd, findbug_args) 136 cmd = '%s %s ' % (cmd, findbug_args)
132 137
133 chrome_classes = _GetChromeClasses() 138 chrome_classes = _GetChromeClasses(release_version)
134 if not chrome_classes: 139 if not chrome_classes:
135 return 1 140 return 1
136 cmd = '%s %s ' % (cmd, chrome_classes) 141 cmd = '%s %s ' % (cmd, chrome_classes)
137 142
138 proc = subprocess.Popen(shlex.split(cmd), 143 proc = subprocess.Popen(shlex.split(cmd),
139 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 144 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
140 out, _err = proc.communicate() 145 out, _err = proc.communicate()
141 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines()))) 146 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines())))
142 147
143 if rebaseline: 148 if rebaseline:
(...skipping 12 matching lines...) Expand all
156 161
157 if options.known_bugs: 162 if options.known_bugs:
158 known_bugs_file = options.known_bugs 163 known_bugs_file = options.known_bugs
159 elif options.base_dir: 164 elif options.base_dir:
160 known_bugs_file = os.path.join(options.base_dir, 'findbugs_known_bugs.txt') 165 known_bugs_file = os.path.join(options.base_dir, 'findbugs_known_bugs.txt')
161 166
162 auxclasspath = None 167 auxclasspath = None
163 if options.auxclasspath: 168 if options.auxclasspath:
164 auxclasspath = options.auxclasspath.split(':') 169 auxclasspath = options.auxclasspath.split(':')
165 return _Run(exclude_file, known_bugs_file, options.only_analyze, auxclasspath, 170 return _Run(exclude_file, known_bugs_file, options.only_analyze, auxclasspath,
166 options.rebaseline, options.findbug_args) 171 options.rebaseline, options.release_build, options.findbug_args)
167 172
168 173
169 def GetCommonParser(): 174 def GetCommonParser():
170 parser = optparse.OptionParser() 175 parser = optparse.OptionParser()
171 parser.add_option('-r', 176 parser.add_option('-r',
172 '--rebaseline', 177 '--rebaseline',
173 action='store_true', 178 action='store_true',
174 dest='rebaseline', 179 dest='rebaseline',
175 help='Rebaseline known findbugs issues.') 180 help='Rebaseline known findbugs issues.')
176 181
(...skipping 18 matching lines...) Expand all
195 dest='exclude', 200 dest='exclude',
196 help='Exclude bugs matching given filter.') 201 help='Exclude bugs matching given filter.')
197 202
198 parser.add_option('-k', 203 parser.add_option('-k',
199 '--known-bugs', 204 '--known-bugs',
200 action='store', 205 action='store',
201 default=None, 206 default=None,
202 dest='known_bugs', 207 dest='known_bugs',
203 help='Not report the bugs in the given file.') 208 help='Not report the bugs in the given file.')
204 209
210 parser.add_option('-l',
211 '--release-build',
212 action='store_true',
213 dest='release_build',
214 help='Analyze release build instead of debug.')
215
205 parser.add_option('-f', 216 parser.add_option('-f',
206 '--findbug-args', 217 '--findbug-args',
207 action='store', 218 action='store',
208 default=None, 219 default=None,
209 dest='findbug_args', 220 dest='findbug_args',
210 help='Additional findbug arguments.') 221 help='Additional findbug arguments.')
211 222
212 parser.add_option('-b', 223 parser.add_option('-b',
213 '--base-dir', 224 '--base-dir',
214 action='store', 225 action='store',
215 default=None, 226 default=None,
216 dest='base_dir', 227 dest='base_dir',
217 help='Base directory for configuration file.') 228 help='Base directory for configuration file.')
218 229
219 return parser 230 return parser
220 231
221 232
222 def main(): 233 def main():
223 parser = GetCommonParser() 234 parser = GetCommonParser()
224 options, _ = parser.parse_args() 235 options, _ = parser.parse_args()
225 236
226 return Run(options) 237 return Run(options)
227 238
228 239
229 if __name__ == '__main__': 240 if __name__ == '__main__':
230 sys.exit(main()) 241 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/buildbot/bb_host_steps.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698