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

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

Issue 1328823002: GN: Use interface jars in the classpath to speed up compiling (a little) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ijar2
Patch Set: .interface.jar Created 5 years, 3 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/BUILD.gn ('k') | build/config/android/internal_rules.gni » ('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 optparse 7 import optparse
8 import os 8 import os
9 import shutil 9 import shutil
10 import re 10 import re
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 action='append', 126 action='append',
127 default=[], 127 default=[],
128 help='Boot classpath for javac. If this is specified multiple times, ' 128 help='Boot classpath for javac. If this is specified multiple times, '
129 'they will all be appended to construct the classpath.') 129 'they will all be appended to construct the classpath.')
130 parser.add_option( 130 parser.add_option(
131 '--classpath', 131 '--classpath',
132 action='append', 132 action='append',
133 help='Classpath for javac. If this is specified multiple times, they ' 133 help='Classpath for javac. If this is specified multiple times, they '
134 'will all be appended to construct the classpath.') 134 'will all be appended to construct the classpath.')
135 parser.add_option( 135 parser.add_option(
136 '--use-ijars',
137 action='store_true',
138 help='Whether to use interface jars (.interface.jar) when compiling')
139 parser.add_option(
136 '--javac-includes', 140 '--javac-includes',
137 default='', 141 default='',
138 help='A list of file patterns. If provided, only java files that match' 142 help='A list of file patterns. If provided, only java files that match'
139 'one of the patterns will be compiled.') 143 'one of the patterns will be compiled.')
140 parser.add_option( 144 parser.add_option(
141 '--jar-excluded-classes', 145 '--jar-excluded-classes',
142 default='', 146 default='',
143 help='List of .class file patterns to exclude from the jar.') 147 help='List of .class file patterns to exclude from the jar.')
144 148
145 parser.add_option( 149 parser.add_option(
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 colorama.init() 198 colorama.init()
195 199
196 argv = build_utils.ExpandFileArgs(argv) 200 argv = build_utils.ExpandFileArgs(argv)
197 options, java_files = _ParseOptions(argv) 201 options, java_files = _ParseOptions(argv)
198 202
199 if options.src_gendirs: 203 if options.src_gendirs:
200 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java') 204 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java')
201 205
202 java_files = _FilterJavaFiles(java_files, options.javac_includes) 206 java_files = _FilterJavaFiles(java_files, options.javac_includes)
203 207
208 runtime_classpath = options.classpath
209 compile_classpath = runtime_classpath
210 if options.use_ijars:
211 ijar_re = re.compile(r'\.jar$')
212 compile_classpath = (
213 [ijar_re.sub('.interface.jar', p) for p in runtime_classpath])
214
204 javac_args = [ 215 javac_args = [
205 '-g', 216 '-g',
206 # Chromium only allows UTF8 source files. Being explicit avoids 217 # Chromium only allows UTF8 source files. Being explicit avoids
207 # javac pulling a default encoding from the user's environment. 218 # javac pulling a default encoding from the user's environment.
208 '-encoding', 'UTF-8', 219 '-encoding', 'UTF-8',
209 '-classpath', ':'.join(options.classpath), 220 '-classpath', ':'.join(compile_classpath),
210 ] 221 ]
211 222
212 if options.bootclasspath: 223 if options.bootclasspath:
213 javac_args.extend([ 224 javac_args.extend([
214 '-bootclasspath', ':'.join(options.bootclasspath), 225 '-bootclasspath', ':'.join(options.bootclasspath),
215 '-source', '1.7', 226 '-source', '1.7',
216 '-target', '1.7', 227 '-target', '1.7',
217 ]) 228 ])
218 229
219 if options.chromium_code: 230 if options.chromium_code:
220 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed. 231 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed.
221 javac_args.extend(['-Xlint:unchecked']) 232 javac_args.extend(['-Xlint:unchecked'])
222 else: 233 else:
223 # XDignore.symbol.file makes javac compile against rt.jar instead of 234 # XDignore.symbol.file makes javac compile against rt.jar instead of
224 # ct.sym. This means that using a java internal package/class will not 235 # ct.sym. This means that using a java internal package/class will not
225 # trigger a compile warning or error. 236 # trigger a compile warning or error.
226 javac_args.extend(['-XDignore.symbol.file']) 237 javac_args.extend(['-XDignore.symbol.file'])
227 238
228 javac_cmd = ['javac'] 239 javac_cmd = ['javac']
229 if options.use_errorprone_path: 240 if options.use_errorprone_path:
230 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS 241 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS
231 242
232 # Compute the list of paths that when changed, we need to rebuild. 243 # Compute the list of paths that when changed, we need to rebuild.
233 input_paths = options.bootclasspath + options.java_srcjars + java_files 244 input_paths = options.bootclasspath + options.java_srcjars + java_files
234 for path in options.classpath: 245 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more.
235 if os.path.exists(path + '.TOC'): 246 if not options.use_ijars:
236 input_paths.append(path + '.TOC') 247 for path in compile_classpath:
237 else: 248 if os.path.exists(path + '.TOC'):
238 input_paths.append(path) 249 input_paths.append(path + '.TOC')
250 else:
251 input_paths.append(path)
239 python_deps = build_utils.GetPythonDependencies() 252 python_deps = build_utils.GetPythonDependencies()
240 253
241 def OnStaleMd5(): 254 def OnStaleMd5():
242 with build_utils.TempDir() as temp_dir: 255 with build_utils.TempDir() as temp_dir:
243 if options.java_srcjars: 256 if options.java_srcjars:
244 java_dir = os.path.join(temp_dir, 'java') 257 java_dir = os.path.join(temp_dir, 'java')
245 os.makedirs(java_dir) 258 os.makedirs(java_dir)
246 for srcjar in options.java_srcjars: 259 for srcjar in options.java_srcjars:
247 build_utils.ExtractAll(srcjar, path=java_dir, pattern='*.java') 260 build_utils.ExtractAll(srcjar, path=java_dir, pattern='*.java')
248 jar_srcs = build_utils.FindInDirectory(java_dir, '*.java') 261 jar_srcs = build_utils.FindInDirectory(java_dir, '*.java')
(...skipping 10 matching lines...) Expand all
259 build_utils.CheckOutput( 272 build_utils.CheckOutput(
260 cmd, 273 cmd,
261 print_stdout=options.chromium_code, 274 print_stdout=options.chromium_code,
262 stderr_filter=ColorJavacOutput) 275 stderr_filter=ColorJavacOutput)
263 276
264 if options.main_class or options.manifest_entry: 277 if options.main_class or options.manifest_entry:
265 entries = [] 278 entries = []
266 if options.manifest_entry: 279 if options.manifest_entry:
267 entries = [e.split(':') for e in options.manifest_entry] 280 entries = [e.split(':') for e in options.manifest_entry]
268 manifest_file = os.path.join(temp_dir, 'manifest') 281 manifest_file = os.path.join(temp_dir, 'manifest')
269 _CreateManifest(manifest_file, options.classpath, options.main_class, 282 _CreateManifest(manifest_file, runtime_classpath, options.main_class,
270 entries) 283 entries)
271 else: 284 else:
272 manifest_file = None 285 manifest_file = None
273 jar.JarDirectory(classes_dir, 286 jar.JarDirectory(classes_dir,
274 options.jar_excluded_classes, 287 options.jar_excluded_classes,
275 options.jar_path, 288 options.jar_path,
276 manifest_file=manifest_file) 289 manifest_file=manifest_file)
277 290
278 if options.stamp: 291 if options.stamp:
279 build_utils.Touch(options.stamp) 292 build_utils.Touch(options.stamp)
(...skipping 10 matching lines...) Expand all
290 input_paths=input_paths, 303 input_paths=input_paths,
291 input_strings=javac_cmd + javac_args + python_deps, 304 input_strings=javac_cmd + javac_args + python_deps,
292 force=not os.path.exists(options.jar_path)) 305 force=not os.path.exists(options.jar_path))
293 306
294 307
295 308
296 if __name__ == '__main__': 309 if __name__ == '__main__':
297 sys.exit(main(sys.argv[1:])) 310 sys.exit(main(sys.argv[1:]))
298 311
299 312
OLDNEW
« no previous file with comments | « build/android/BUILD.gn ('k') | build/config/android/internal_rules.gni » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698