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

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

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

Powered by Google App Engine
This is Rietveld 408576698