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

Side by Side Diff: build/android/gyp/javac.py

Issue 1136573002: Use the Errorprone Compiler (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Full Sync and Update Created 5 years, 6 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/gyp/find_sun_tools_jar.py ('k') | build/android/setup.gyp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # 2 #
3 # Copyright 2013 The Chromium Authors. All rights reserved. 3 # Copyright 2013 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 fnmatch 7 import fnmatch
8 import optparse 8 import optparse
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 line = Colorize(line, warning_re, warning_color) 47 line = Colorize(line, warning_re, warning_color)
48 elif error_re.match(line): 48 elif error_re.match(line):
49 line = Colorize(line, error_re, error_color) 49 line = Colorize(line, error_re, error_color)
50 elif marker_re.match(line): 50 elif marker_re.match(line):
51 line = Colorize(line, marker_re, marker_color) 51 line = Colorize(line, marker_re, marker_color)
52 return line 52 return line
53 53
54 return '\n'.join(map(ApplyColor, output.split('\n'))) 54 return '\n'.join(map(ApplyColor, output.split('\n')))
55 55
56 56
57 ERRORPRONE_OPTIONS = [
58 '-Xepdisable:'
59 # Something in chrome_private_java makes this check crash.
60 'com.google.errorprone.bugpatterns.ClassCanBeStatic,'
61 # These crash on lots of targets.
62 'com.google.errorprone.bugpatterns.WrongParameterPackage,'
63 'com.google.errorprone.bugpatterns.GuiceOverridesGuiceInjectableMethod,'
64 'com.google.errorprone.bugpatterns.GuiceOverridesJavaxInjectableMethod,'
65 'com.google.errorprone.bugpatterns.ElementsCountedInLoop'
66 ]
67
57 def DoJavac( 68 def DoJavac(
58 classpath, classes_dir, chromium_code, java_files): 69 classpath, classes_dir, chromium_code,
70 use_errorprone_path, java_files):
59 """Runs javac. 71 """Runs javac.
60 72
61 Builds |java_files| with the provided |classpath| and puts the generated 73 Builds |java_files| with the provided |classpath| and puts the generated
62 .class files into |classes_dir|. If |chromium_code| is true, extra lint 74 .class files into |classes_dir|. If |chromium_code| is true, extra lint
63 checking will be enabled. 75 checking will be enabled.
64 """ 76 """
65 77
66 jar_inputs = [] 78 jar_inputs = []
67 for path in classpath: 79 for path in classpath:
68 if os.path.exists(path + '.TOC'): 80 if os.path.exists(path + '.TOC'):
(...skipping 12 matching lines...) Expand all
81 '-d', classes_dir] 93 '-d', classes_dir]
82 if chromium_code: 94 if chromium_code:
83 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed. 95 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed.
84 javac_args.extend(['-Xlint:unchecked']) 96 javac_args.extend(['-Xlint:unchecked'])
85 else: 97 else:
86 # XDignore.symbol.file makes javac compile against rt.jar instead of 98 # XDignore.symbol.file makes javac compile against rt.jar instead of
87 # ct.sym. This means that using a java internal package/class will not 99 # ct.sym. This means that using a java internal package/class will not
88 # trigger a compile warning or error. 100 # trigger a compile warning or error.
89 javac_args.extend(['-XDignore.symbol.file']) 101 javac_args.extend(['-XDignore.symbol.file'])
90 102
91 javac_cmd = ['javac'] + javac_args + java_files 103 if use_errorprone_path:
104 javac_cmd = [use_errorprone_path] + ERRORPRONE_OPTIONS
105 else:
106 javac_cmd = ['javac']
107
108 javac_cmd = javac_cmd + javac_args + java_files
92 109
93 def Compile(): 110 def Compile():
94 build_utils.CheckOutput( 111 build_utils.CheckOutput(
95 javac_cmd, 112 javac_cmd,
96 print_stdout=chromium_code, 113 print_stdout=chromium_code,
97 stderr_filter=ColorJavacOutput) 114 stderr_filter=ColorJavacOutput)
98 115
99 record_path = os.path.join(classes_dir, 'javac.md5.stamp') 116 record_path = os.path.join(classes_dir, 'javac.md5.stamp')
100 md5_check.CallAndRecordIfStale( 117 md5_check.CallAndRecordIfStale(
101 Compile, 118 Compile,
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
177 default='', 194 default='',
178 help='List of .class file patterns to exclude from the jar.') 195 help='List of .class file patterns to exclude from the jar.')
179 196
180 parser.add_option( 197 parser.add_option(
181 '--chromium-code', 198 '--chromium-code',
182 type='int', 199 type='int',
183 help='Whether code being compiled should be built with stricter ' 200 help='Whether code being compiled should be built with stricter '
184 'warnings for chromium code.') 201 'warnings for chromium code.')
185 202
186 parser.add_option( 203 parser.add_option(
204 '--use-errorprone-path',
205 help='Use the Errorprone compiler at this path.')
206
207 parser.add_option(
187 '--classes-dir', 208 '--classes-dir',
188 help='Directory for compiled .class files.') 209 help='Directory for compiled .class files.')
189 parser.add_option('--jar-path', help='Jar output path.') 210 parser.add_option('--jar-path', help='Jar output path.')
190 parser.add_option( 211 parser.add_option(
191 '--main-class', 212 '--main-class',
192 help='The class containing the main method.') 213 help='The class containing the main method.')
193 parser.add_option( 214 parser.add_option(
194 '--manifest-entry', 215 '--manifest-entry',
195 action='append', 216 action='append',
196 help='Key:value pairs to add to the .jar manifest.') 217 help='Key:value pairs to add to the .jar manifest.')
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 if fnmatch.fnmatch(f, include): 255 if fnmatch.fnmatch(f, include):
235 filtered_java_files.append(f) 256 filtered_java_files.append(f)
236 break 257 break
237 java_files = filtered_java_files 258 java_files = filtered_java_files
238 259
239 if len(java_files) != 0: 260 if len(java_files) != 0:
240 DoJavac( 261 DoJavac(
241 classpath, 262 classpath,
242 classes_dir, 263 classes_dir,
243 options.chromium_code, 264 options.chromium_code,
265 options.use_errorprone_path,
244 java_files) 266 java_files)
245 267
246 if options.jar_path: 268 if options.jar_path:
247 if options.main_class or options.manifest_entry: 269 if options.main_class or options.manifest_entry:
248 if options.manifest_entry: 270 if options.manifest_entry:
249 entries = map(lambda e: e.split(":"), options.manifest_entry) 271 entries = map(lambda e: e.split(":"), options.manifest_entry)
250 else: 272 else:
251 entries = [] 273 entries = []
252 manifest_file = os.path.join(temp_dir, 'manifest') 274 manifest_file = os.path.join(temp_dir, 'manifest')
253 CreateManifest(manifest_file, classpath, options.main_class, entries) 275 CreateManifest(manifest_file, classpath, options.main_class, entries)
(...skipping 19 matching lines...) Expand all
273 input_files + build_utils.GetPythonDependencies()) 295 input_files + build_utils.GetPythonDependencies())
274 296
275 if options.stamp: 297 if options.stamp:
276 build_utils.Touch(options.stamp) 298 build_utils.Touch(options.stamp)
277 299
278 300
279 if __name__ == '__main__': 301 if __name__ == '__main__':
280 sys.exit(main(sys.argv[1:])) 302 sys.exit(main(sys.argv[1:]))
281 303
282 304
OLDNEW
« no previous file with comments | « build/android/gyp/find_sun_tools_jar.py ('k') | build/android/setup.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698