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

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

Issue 11967019: [Android] Sever findbugs dependencies on environment variables. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fit nits Created 7 years, 11 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
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 import optparse 7 import optparse
8 import os 8 import os
9 import re 9 import re
10 import shlex 10 import shlex
11 import subprocess 11 import subprocess
12 import sys 12 import sys
13 13
14 from pylib import constants
15
14 16
15 def _PrintMessage(warnings, title, action, known_bugs_file): 17 def _PrintMessage(warnings, title, action, known_bugs_file):
16 if warnings: 18 if warnings:
17 print 19 print
18 print '*' * 80 20 print '*' * 80
19 print '%s warnings.' % title 21 print '%s warnings.' % title
20 print '%s %s' % (action, known_bugs_file) 22 print '%s %s' % (action, known_bugs_file)
21 print '-' * 80 23 print '-' * 80
22 for warning in warnings: 24 for warning in warnings:
23 print warning 25 print warning
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 61
60 62
61 def _Rebaseline(current_warnings_set, known_bugs_file): 63 def _Rebaseline(current_warnings_set, known_bugs_file):
62 with file(known_bugs_file, 'w') as known_bugs: 64 with file(known_bugs_file, 'w') as known_bugs:
63 for warning in sorted(current_warnings_set): 65 for warning in sorted(current_warnings_set):
64 print >>known_bugs, warning 66 print >>known_bugs, warning
65 return 0 67 return 0
66 68
67 69
68 def _GetChromeClasses(release_version): 70 def _GetChromeClasses(release_version):
69 chrome_src = os.getenv('CHROME_SRC')
70 version = 'Debug' 71 version = 'Debug'
71 if release_version: 72 if release_version:
72 version = 'Release' 73 version = 'Release'
73 path = os.path.join(chrome_src, 'out', version) 74 path = os.path.join(constants.CHROME_DIR, 'out', version)
74 cmd = 'find %s -name "*.class"' % path 75 cmd = 'find %s -name "*.class"' % path
75 proc = subprocess.Popen(shlex.split(cmd), 76 proc = subprocess.Popen(shlex.split(cmd),
76 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 77 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
77 out, err = proc.communicate() 78 out, err = proc.communicate()
78 79
79 if not out: 80 if not out:
80 print 'No classes found in %s' % path 81 print 'No classes found in %s' % path
81 return out 82 return out
82 83
83 84
84 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes, 85 def _Run(exclude, known_bugs, classes_to_analyze, auxiliary_classes,
85 rebaseline, release_version, findbug_args): 86 rebaseline, release_version, findbug_args):
86 """Run the FindBugs. 87 """Run the FindBugs.
87 88
88 Args: 89 Args:
89 exclude: the exclude xml file, refer to FindBugs's -exclude command option. 90 exclude: the exclude xml file, refer to FindBugs's -exclude command option.
90 known_bugs: the text file of known bugs. The bugs in it will not be 91 known_bugs: the text file of known bugs. The bugs in it will not be
91 reported. 92 reported.
92 classes_to_analyze: the list of classes need to analyze, refer to FindBug's 93 classes_to_analyze: the list of classes need to analyze, refer to FindBug's
93 -onlyAnalyze command line option. 94 -onlyAnalyze command line option.
94 auxiliary_classes: the classes help to analyze, refer to FindBug's 95 auxiliary_classes: the classes help to analyze, refer to FindBug's
95 -auxclasspath command line option. 96 -auxclasspath command line option.
96 rebaseline: True if the known_bugs file needs rebaseline. 97 rebaseline: True if the known_bugs file needs rebaseline.
97 release_version: True if the release version needs check, otherwise check 98 release_version: True if the release version needs check, otherwise check
98 debug version. 99 debug version.
99 findbug_args: addtional command line options needs pass to Findbugs. 100 findbug_args: addtional command line options needs pass to Findbugs.
100 """ 101 """
101 102
102 chrome_src = os.getenv('CHROME_SRC') 103 chrome_src = constants.CHROME_DIR
103 sdk_root = os.getenv('ANDROID_SDK_ROOT') 104 sdk_root = constants.ANDROID_SDK_ROOT
104 sdk_version = os.getenv('ANDROID_SDK_VERSION') 105 sdk_version = constants.ANDROID_SDK_VERSION
105 106
106 system_classes = [] 107 system_classes = []
107 system_classes.append(os.path.join(sdk_root, 'platforms', 108 system_classes.append(os.path.join(sdk_root, 'platforms',
108 'android-%s' % sdk_version, 'android.jar')) 109 'android-%s' % sdk_version, 'android.jar'))
109 if auxiliary_classes: 110 if auxiliary_classes:
110 for classes in auxiliary_classes: 111 for classes in auxiliary_classes:
111 system_classes.append(os.path.abspath(classes)) 112 system_classes.append(os.path.abspath(classes))
112 113
113 cmd = '%s -textui -sortByClass ' % os.path.join(chrome_src, 'third_party', 114 cmd = '%s -textui -sortByClass ' % os.path.join(chrome_src, 'third_party',
114 'findbugs', 'bin', 'findbugs') 115 'findbugs', 'bin', 'findbugs')
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 216
216 parser.add_option('-b', 217 parser.add_option('-b',
217 '--base-dir', 218 '--base-dir',
218 action='store', 219 action='store',
219 default=None, 220 default=None,
220 dest='base_dir', 221 dest='base_dir',
221 help='Base directory for configuration file.') 222 help='Base directory for configuration file.')
222 223
223 return parser 224 return parser
224 225
225 def CheckEnvironment():
226 if not (os.getenv('CHROME_SRC') and os.getenv('ANDROID_SDK_ROOT') and
227 os.getenv('ANDROID_SDK_VERSION')):
228 print 'Your build environment is not set up correctly.'
229 print 'Please source build/android/envsetup.sh.'
230 return False
231 return True
232 226
233 def main(argv): 227 def main(argv):
234 parser = GetCommonParser() 228 parser = GetCommonParser()
235 options, _ = parser.parse_args() 229 options, _ = parser.parse_args()
236 230
237 return Run(options) 231 return Run(options)
238 232
233
239 if __name__ == '__main__': 234 if __name__ == '__main__':
240 sys.exit(main(sys.argv)) 235 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « build/android/pylib/findbugs.py ('k') | tools/android/findbugs_plugin/test/run_findbugs_plugin_tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698