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

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

Issue 2711413002: Reland of Fix up javac.py's depfile to include all relevant inputs (Closed)
Patch Set: Fix typo in _ConvertToJMakeArgs Created 3 years, 10 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 | « no previous file | no next file » | 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 distutils.spawn 7 import distutils.spawn
8 import optparse 8 import optparse
9 import os 9 import os
10 import shutil 10 import shutil
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 path_without_suffix = re.sub(r'(?:\$|\.)[^/]*class$', '', path) 87 path_without_suffix = re.sub(r'(?:\$|\.)[^/]*class$', '', path)
88 partial_java_path = path_without_suffix + '.java' 88 partial_java_path = path_without_suffix + '.java'
89 return not any(p.endswith(partial_java_path) for p in java_files) 89 return not any(p.endswith(partial_java_path) for p in java_files)
90 90
91 build_utils.ExtractAll(jar_path, path=dest_dir, predicate=extract_predicate) 91 build_utils.ExtractAll(jar_path, path=dest_dir, predicate=extract_predicate)
92 for path in build_utils.FindInDirectory(dest_dir, '*.class'): 92 for path in build_utils.FindInDirectory(dest_dir, '*.class'):
93 shutil.copystat(jar_path, path) 93 shutil.copystat(jar_path, path)
94 94
95 95
96 def _ConvertToJMakeArgs(javac_cmd, pdb_path): 96 def _ConvertToJMakeArgs(javac_cmd, pdb_path):
97 new_args = ['bin/jmake', '-pdb', pdb_path] 97 new_args = ['bin/jmake', '-pdb', pdb_path, '-jcexec', javac_cmd[0]]
98 if javac_cmd[0] != 'javac':
99 new_args.extend(('-jcexec', new_args[0]))
100 if md5_check.PRINT_EXPLANATIONS: 98 if md5_check.PRINT_EXPLANATIONS:
101 new_args.append('-Xtiming') 99 new_args.append('-Xtiming')
102 100
103 do_not_prefix = ('-classpath', '-bootclasspath') 101 do_not_prefix = ('-classpath', '-bootclasspath')
104 skip_next = False 102 skip_next = False
105 for arg in javac_cmd[1:]: 103 for arg in javac_cmd[1:]:
106 if not skip_next and arg not in do_not_prefix: 104 if not skip_next and arg not in do_not_prefix:
107 arg = '-C' + arg 105 arg = '-C' + arg
108 new_args.append(arg) 106 new_args.append(arg)
109 skip_next = arg in do_not_prefix 107 skip_next = arg in do_not_prefix
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after
413 colorama.init() 411 colorama.init()
414 412
415 argv = build_utils.ExpandFileArgs(argv) 413 argv = build_utils.ExpandFileArgs(argv)
416 options, java_files = _ParseOptions(argv) 414 options, java_files = _ParseOptions(argv)
417 415
418 if options.src_gendirs: 416 if options.src_gendirs:
419 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java') 417 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java')
420 418
421 java_files = _FilterJavaFiles(java_files, options.javac_includes) 419 java_files = _FilterJavaFiles(java_files, options.javac_includes)
422 420
423 javac_cmd = ['javac']
424 if options.use_errorprone_path: 421 if options.use_errorprone_path:
425 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS 422 javac_path = options.use_errorprone_path
423 javac_cmd = [javac_path] + ERRORPRONE_OPTIONS
424 else:
425 javac_path = distutils.spawn.find_executable('javac')
426 javac_cmd = [javac_path]
426 427
427 javac_cmd.extend(( 428 javac_cmd.extend((
428 '-g', 429 '-g',
429 # Chromium only allows UTF8 source files. Being explicit avoids 430 # Chromium only allows UTF8 source files. Being explicit avoids
430 # javac pulling a default encoding from the user's environment. 431 # javac pulling a default encoding from the user's environment.
431 '-encoding', 'UTF-8', 432 '-encoding', 'UTF-8',
432 # Make sure we do not pass an empty string to -classpath and -sourcepath. 433 # Make sure we do not pass an empty string to -classpath and -sourcepath.
433 '-classpath', ':'.join(options.classpath) or ':', 434 '-classpath', ':'.join(options.classpath) or ':',
434 # Prevent compiler from compiling .java files not listed as inputs. 435 # Prevent compiler from compiling .java files not listed as inputs.
435 # See: http://blog.ltgt.net/most-build-tools-misuse-javac/ 436 # See: http://blog.ltgt.net/most-build-tools-misuse-javac/
(...skipping 30 matching lines...) Expand all
466 if options.classpath[0].endswith('.interface.jar'): 467 if options.classpath[0].endswith('.interface.jar'):
467 classpath_inputs.extend(options.classpath) 468 classpath_inputs.extend(options.classpath)
468 else: 469 else:
469 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more. 470 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more.
470 for path in options.classpath: 471 for path in options.classpath:
471 if os.path.exists(path + '.TOC'): 472 if os.path.exists(path + '.TOC'):
472 classpath_inputs.append(path + '.TOC') 473 classpath_inputs.append(path + '.TOC')
473 else: 474 else:
474 classpath_inputs.append(path) 475 classpath_inputs.append(path)
475 476
476 # Compute the list of paths that when changed, we need to rebuild. 477 # GN already knows of java_files, so listing them just make things worse when
477 input_paths = classpath_inputs + options.java_srcjars + java_files 478 # they change.
479 depfile_deps = [javac_path] + classpath_inputs + options.java_srcjars
480 input_paths = depfile_deps + java_files
478 481
479 output_paths = [ 482 output_paths = [
480 options.jar_path, 483 options.jar_path,
481 options.jar_path.replace('.jar', '.excluded.jar'), 484 options.jar_path.replace('.jar', '.excluded.jar'),
482 ] 485 ]
483 if options.incremental: 486 if options.incremental:
484 output_paths.append(options.jar_path + '.pdb') 487 output_paths.append(options.jar_path + '.pdb')
485 488
486 # An escape hatch to be able to check if incremental compiles are causing 489 # An escape hatch to be able to check if incremental compiles are causing
487 # problems. 490 # problems.
488 force = int(os.environ.get('DISABLE_INCREMENTAL_JAVAC', 0)) 491 force = int(os.environ.get('DISABLE_INCREMENTAL_JAVAC', 0))
489 492
490 # List python deps in input_strings rather than input_paths since the contents 493 # List python deps in input_strings rather than input_paths since the contents
491 # of them does not change what gets written to the depsfile. 494 # of them does not change what gets written to the depsfile.
492 build_utils.CallAndWriteDepfileIfStale( 495 build_utils.CallAndWriteDepfileIfStale(
493 lambda changes: _OnStaleMd5(changes, options, javac_cmd, java_files, 496 lambda changes: _OnStaleMd5(changes, options, javac_cmd, java_files,
494 classpath_inputs), 497 classpath_inputs),
495 options, 498 options,
499 depfile_deps=depfile_deps,
496 input_paths=input_paths, 500 input_paths=input_paths,
497 input_strings=javac_cmd, 501 input_strings=javac_cmd,
498 output_paths=output_paths, 502 output_paths=output_paths,
499 force=force, 503 force=force,
500 pass_changes=True) 504 pass_changes=True)
501 505
502 506
503 if __name__ == '__main__': 507 if __name__ == '__main__':
504 sys.exit(main(sys.argv[1:])) 508 sys.exit(main(sys.argv[1:]))
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698