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

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

Issue 458653002: Update lint and findbugs to use jars instead of class files (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a landmine Created 6 years, 4 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
« no previous file with comments | « build/android/push_libraries.gypi ('k') | build/get_landmines.py » ('j') | 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(release_version): 69 def _GetChromeJars(release_version):
70 version = 'Debug' 70 version = 'Debug'
71 if release_version: 71 if release_version:
72 version = 'Release' 72 version = 'Release'
73 path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version) 73 path = os.path.join(constants.DIR_SOURCE_ROOT, 'out', version, 'lib.java')
74 cmd = 'find %s -name "*.class"' % path 74 cmd = 'find %s -name "*.jar"' % path
75 out = cmd_helper.GetCmdOutput(shlex.split(cmd)) 75 out = cmd_helper.GetCmdOutput(shlex.split(cmd))
76 out = [p for p in out.splitlines() if not p.endswith('.dex.jar')]
76 if not out: 77 if not out:
77 print 'No classes found in %s' % path 78 print 'No classes found in %s' % path
78 return out 79 return ' '.join(out)
79 80
80 81
81 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes, 82 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes,
82 rebaseline, release_version, findbug_args): 83 rebaseline, release_version, findbug_args):
83 """Run the FindBugs. 84 """Run the FindBugs.
84 85
85 Args: 86 Args:
86 exclude: the exclude xml file, refer to FindBugs's -exclude command option. 87 exclude: the exclude xml file, refer to FindBugs's -exclude command option.
87 known_bugs: the text file of known bugs. The bugs in it will not be 88 known_bugs: the text file of known bugs. The bugs in it will not be
88 reported. 89 reported.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 129
129 if classes_to_analyze: 130 if classes_to_analyze:
130 cmd = '%s -onlyAnalyze %s ' % (cmd, classes_to_analyze) 131 cmd = '%s -onlyAnalyze %s ' % (cmd, classes_to_analyze)
131 132
132 if exclude: 133 if exclude:
133 cmd = '%s -exclude %s ' % (cmd, os.path.abspath(exclude)) 134 cmd = '%s -exclude %s ' % (cmd, os.path.abspath(exclude))
134 135
135 if findbug_args: 136 if findbug_args:
136 cmd = '%s %s ' % (cmd, findbug_args) 137 cmd = '%s %s ' % (cmd, findbug_args)
137 138
138 chrome_classes = _GetChromeClasses(release_version) 139 chrome_classes = _GetChromeJars(release_version)
139 if not chrome_classes: 140 if not chrome_classes:
140 return 1 141 return 1
141 cmd = '%s %s ' % (cmd, chrome_classes) 142 cmd = '%s %s ' % (cmd, chrome_classes)
142 143
143 proc = subprocess.Popen(shlex.split(cmd), 144 proc = subprocess.Popen(shlex.split(cmd),
144 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 145 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
145 out, _err = proc.communicate() 146 out, _err = proc.communicate()
146 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines()))) 147 current_warnings_set = set(_StripLineNumbers(filter(None, out.splitlines())))
147 148
148 if rebaseline: 149 if rebaseline:
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 233
233 def main(): 234 def main():
234 parser = GetCommonParser() 235 parser = GetCommonParser()
235 options, _ = parser.parse_args() 236 options, _ = parser.parse_args()
236 237
237 return Run(options) 238 return Run(options)
238 239
239 240
240 if __name__ == '__main__': 241 if __name__ == '__main__':
241 sys.exit(main()) 242 sys.exit(main())
OLDNEW
« no previous file with comments | « build/android/push_libraries.gypi ('k') | build/get_landmines.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698