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

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

Issue 1369583002: Revert of CallAndRecordIfStale(): Add knownledge of output_files, depfiles, stamp (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@incremental-script-dep
Patch Set: 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/gyp/dex.py ('k') | build/android/gyp/proguard.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 #!/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
11 import sys 11 import sys
12 import textwrap 12 import textwrap
13 13
14 from util import build_utils 14 from util import build_utils
15 from util import md5_check
15 16
16 import jar 17 import jar
17 18
18 sys.path.append(build_utils.COLORAMA_ROOT) 19 sys.path.append(build_utils.COLORAMA_ROOT)
19 import colorama 20 import colorama
20 21
21 22
22 def ColorJavacOutput(output): 23 def ColorJavacOutput(output):
23 fileline_prefix = r'(?P<fileline>(?P<file>[-.\w/\\]+.java):(?P<line>[0-9]+):)' 24 fileline_prefix = r'(?P<fileline>(?P<file>[-.\w/\\]+.java):(?P<line>[0-9]+):)'
24 warning_re = re.compile( 25 warning_re = re.compile(
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 205
205 java_files = _FilterJavaFiles(java_files, options.javac_includes) 206 java_files = _FilterJavaFiles(java_files, options.javac_includes)
206 207
207 runtime_classpath = options.classpath 208 runtime_classpath = options.classpath
208 compile_classpath = runtime_classpath 209 compile_classpath = runtime_classpath
209 if options.use_ijars: 210 if options.use_ijars:
210 ijar_re = re.compile(r'\.jar$') 211 ijar_re = re.compile(r'\.jar$')
211 compile_classpath = ( 212 compile_classpath = (
212 [ijar_re.sub('.interface.jar', p) for p in runtime_classpath]) 213 [ijar_re.sub('.interface.jar', p) for p in runtime_classpath])
213 214
214 javac_cmd = ['javac'] 215 javac_args = [
215 if options.use_errorprone_path:
216 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS
217
218 javac_cmd.extend((
219 '-g', 216 '-g',
220 # Chromium only allows UTF8 source files. Being explicit avoids 217 # Chromium only allows UTF8 source files. Being explicit avoids
221 # javac pulling a default encoding from the user's environment. 218 # javac pulling a default encoding from the user's environment.
222 '-encoding', 'UTF-8', 219 '-encoding', 'UTF-8',
223 '-classpath', ':'.join(compile_classpath), 220 '-classpath', ':'.join(compile_classpath),
224 )) 221 ]
225 222
226 if options.bootclasspath: 223 if options.bootclasspath:
227 javac_cmd.extend([ 224 javac_args.extend([
228 '-bootclasspath', ':'.join(options.bootclasspath), 225 '-bootclasspath', ':'.join(options.bootclasspath),
229 '-source', '1.7', 226 '-source', '1.7',
230 '-target', '1.7', 227 '-target', '1.7',
231 ]) 228 ])
232 229
233 if options.chromium_code: 230 if options.chromium_code:
234 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed. 231 # TODO(aurimas): re-enable '-Xlint:deprecation' checks once they are fixed.
235 javac_cmd.extend(['-Xlint:unchecked']) 232 javac_args.extend(['-Xlint:unchecked'])
236 else: 233 else:
237 # XDignore.symbol.file makes javac compile against rt.jar instead of 234 # XDignore.symbol.file makes javac compile against rt.jar instead of
238 # 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
239 # trigger a compile warning or error. 236 # trigger a compile warning or error.
240 javac_cmd.extend(['-XDignore.symbol.file']) 237 javac_args.extend(['-XDignore.symbol.file'])
238
239 javac_cmd = ['javac']
240 if options.use_errorprone_path:
241 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS
241 242
242 # 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.
243 input_paths = options.bootclasspath + options.java_srcjars + java_files 244 input_paths = options.bootclasspath + options.java_srcjars + java_files
244 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more. 245 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more.
245 if not options.use_ijars: 246 if not options.use_ijars:
246 for path in compile_classpath: 247 for path in compile_classpath:
247 if os.path.exists(path + '.TOC'): 248 if os.path.exists(path + '.TOC'):
248 input_paths.append(path + '.TOC') 249 input_paths.append(path + '.TOC')
249 else: 250 else:
250 input_paths.append(path) 251 input_paths.append(path)
252 python_deps = build_utils.GetPythonDependencies()
251 253
252 def on_stale_md5(): 254 def OnStaleMd5():
253 with build_utils.TempDir() as temp_dir: 255 with build_utils.TempDir() as temp_dir:
254 if options.java_srcjars: 256 if options.java_srcjars:
255 java_dir = os.path.join(temp_dir, 'java') 257 java_dir = os.path.join(temp_dir, 'java')
256 os.makedirs(java_dir) 258 os.makedirs(java_dir)
257 for srcjar in options.java_srcjars: 259 for srcjar in options.java_srcjars:
258 build_utils.ExtractAll(srcjar, path=java_dir, pattern='*.java') 260 build_utils.ExtractAll(srcjar, path=java_dir, pattern='*.java')
259 jar_srcs = build_utils.FindInDirectory(java_dir, '*.java') 261 jar_srcs = build_utils.FindInDirectory(java_dir, '*.java')
260 java_files.extend(_FilterJavaFiles(jar_srcs, options.javac_includes)) 262 java_files.extend(_FilterJavaFiles(jar_srcs, options.javac_includes))
261 263
262 classes_dir = os.path.join(temp_dir, 'classes') 264 classes_dir = os.path.join(temp_dir, 'classes')
263 os.makedirs(classes_dir) 265 os.makedirs(classes_dir)
264 266
265 if java_files: 267 if java_files:
266 # Don't include the output directory in the initial set of args since it 268 # Don't include the output directory in the initial set of args since it
267 # being in a temp dir makes it unstable (breaks md5 stamping). 269 # being in a temp dir makes it unstable (breaks md5 stamping).
268 cmd = javac_cmd + ['-d', classes_dir] + java_files 270 cmd = javac_cmd + javac_args + ['-d', classes_dir] + java_files
269 271
270 build_utils.CheckOutput( 272 build_utils.CheckOutput(
271 cmd, 273 cmd,
272 print_stdout=options.chromium_code, 274 print_stdout=options.chromium_code,
273 stderr_filter=ColorJavacOutput) 275 stderr_filter=ColorJavacOutput)
274 276
275 if options.main_class or options.manifest_entry: 277 if options.main_class or options.manifest_entry:
276 entries = [] 278 entries = []
277 if options.manifest_entry: 279 if options.manifest_entry:
278 entries = [e.split(':') for e in options.manifest_entry] 280 entries = [e.split(':') for e in options.manifest_entry]
279 manifest_file = os.path.join(temp_dir, 'manifest') 281 manifest_file = os.path.join(temp_dir, 'manifest')
280 _CreateManifest(manifest_file, runtime_classpath, options.main_class, 282 _CreateManifest(manifest_file, runtime_classpath, options.main_class,
281 entries) 283 entries)
282 else: 284 else:
283 manifest_file = None 285 manifest_file = None
284 jar.JarDirectory(classes_dir, 286 jar.JarDirectory(classes_dir,
285 options.jar_excluded_classes, 287 options.jar_excluded_classes,
286 options.jar_path, 288 options.jar_path,
287 manifest_file=manifest_file) 289 manifest_file=manifest_file)
288 290
291 if options.stamp:
292 build_utils.Touch(options.stamp)
293
294 if options.depfile:
295 build_utils.WriteDepfile(options.depfile, input_paths + python_deps)
296
289 297
290 # List python deps in input_strings rather than input_paths since the contents 298 # List python deps in input_strings rather than input_paths since the contents
291 # of them does not change what gets written to the depsfile. 299 # of them does not change what gets written to the depsfile.
292 build_utils.CallAndWriteDepfileIfStale( 300 md5_check.CallAndRecordIfStale(
293 on_stale_md5, 301 OnStaleMd5,
294 options, 302 record_path=options.jar_path + '.javac.md5.stamp',
295 input_paths=input_paths, 303 input_paths=input_paths,
296 input_strings=javac_cmd, 304 input_strings=javac_cmd + javac_args + python_deps,
297 output_paths=[options.jar_path]) 305 force=not os.path.exists(options.jar_path))
306
298 307
299 308
300 if __name__ == '__main__': 309 if __name__ == '__main__':
301 sys.exit(main(sys.argv[1:])) 310 sys.exit(main(sys.argv[1:]))
311
312
OLDNEW
« no previous file with comments | « build/android/gyp/dex.py ('k') | build/android/gyp/proguard.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698