| OLD | NEW |
| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 colorama.init() | 413 colorama.init() |
| 414 | 414 |
| 415 argv = build_utils.ExpandFileArgs(argv) | 415 argv = build_utils.ExpandFileArgs(argv) |
| 416 options, java_files = _ParseOptions(argv) | 416 options, java_files = _ParseOptions(argv) |
| 417 | 417 |
| 418 if options.src_gendirs: | 418 if options.src_gendirs: |
| 419 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java') | 419 java_files += build_utils.FindInDirectories(options.src_gendirs, '*.java') |
| 420 | 420 |
| 421 java_files = _FilterJavaFiles(java_files, options.javac_includes) | 421 java_files = _FilterJavaFiles(java_files, options.javac_includes) |
| 422 | 422 |
| 423 javac_cmd = ['javac'] | |
| 424 if options.use_errorprone_path: | 423 if options.use_errorprone_path: |
| 425 javac_cmd = [options.use_errorprone_path] + ERRORPRONE_OPTIONS | 424 javac_path = options.use_errorprone_path |
| 425 javac_cmd = [javac_path] + ERRORPRONE_OPTIONS |
| 426 else: |
| 427 javac_path = distutils.spawn.find_executable('javac') |
| 428 javac_cmd = [javac_path] |
| 426 | 429 |
| 427 javac_cmd.extend(( | 430 javac_cmd.extend(( |
| 428 '-g', | 431 '-g', |
| 429 # Chromium only allows UTF8 source files. Being explicit avoids | 432 # Chromium only allows UTF8 source files. Being explicit avoids |
| 430 # javac pulling a default encoding from the user's environment. | 433 # javac pulling a default encoding from the user's environment. |
| 431 '-encoding', 'UTF-8', | 434 '-encoding', 'UTF-8', |
| 432 # Make sure we do not pass an empty string to -classpath and -sourcepath. | 435 # Make sure we do not pass an empty string to -classpath and -sourcepath. |
| 433 '-classpath', ':'.join(options.classpath) or ':', | 436 '-classpath', ':'.join(options.classpath) or ':', |
| 434 # Prevent compiler from compiling .java files not listed as inputs. | 437 # Prevent compiler from compiling .java files not listed as inputs. |
| 435 # See: http://blog.ltgt.net/most-build-tools-misuse-javac/ | 438 # See: http://blog.ltgt.net/most-build-tools-misuse-javac/ |
| (...skipping 30 matching lines...) Expand all Loading... |
| 466 if options.classpath[0].endswith('.interface.jar'): | 469 if options.classpath[0].endswith('.interface.jar'): |
| 467 classpath_inputs.extend(options.classpath) | 470 classpath_inputs.extend(options.classpath) |
| 468 else: | 471 else: |
| 469 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more. | 472 # TODO(agrieve): Remove this .TOC heuristic once GYP is no more. |
| 470 for path in options.classpath: | 473 for path in options.classpath: |
| 471 if os.path.exists(path + '.TOC'): | 474 if os.path.exists(path + '.TOC'): |
| 472 classpath_inputs.append(path + '.TOC') | 475 classpath_inputs.append(path + '.TOC') |
| 473 else: | 476 else: |
| 474 classpath_inputs.append(path) | 477 classpath_inputs.append(path) |
| 475 | 478 |
| 476 # Compute the list of paths that when changed, we need to rebuild. | 479 # GN already knows of java_files, so listing them just make things worse when |
| 477 input_paths = classpath_inputs + options.java_srcjars + java_files | 480 # they change. |
| 481 depfile_deps = [javac_path] + classpath_inputs + options.java_srcjars |
| 482 input_paths = depfile_deps + java_files |
| 478 | 483 |
| 479 output_paths = [ | 484 output_paths = [ |
| 480 options.jar_path, | 485 options.jar_path, |
| 481 options.jar_path.replace('.jar', '.excluded.jar'), | 486 options.jar_path.replace('.jar', '.excluded.jar'), |
| 482 ] | 487 ] |
| 483 if options.incremental: | 488 if options.incremental: |
| 484 output_paths.append(options.jar_path + '.pdb') | 489 output_paths.append(options.jar_path + '.pdb') |
| 485 | 490 |
| 486 # An escape hatch to be able to check if incremental compiles are causing | 491 # An escape hatch to be able to check if incremental compiles are causing |
| 487 # problems. | 492 # problems. |
| 488 force = int(os.environ.get('DISABLE_INCREMENTAL_JAVAC', 0)) | 493 force = int(os.environ.get('DISABLE_INCREMENTAL_JAVAC', 0)) |
| 489 | 494 |
| 490 # List python deps in input_strings rather than input_paths since the contents | 495 # 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. | 496 # of them does not change what gets written to the depsfile. |
| 492 build_utils.CallAndWriteDepfileIfStale( | 497 build_utils.CallAndWriteDepfileIfStale( |
| 493 lambda changes: _OnStaleMd5(changes, options, javac_cmd, java_files, | 498 lambda changes: _OnStaleMd5(changes, options, javac_cmd, java_files, |
| 494 classpath_inputs), | 499 classpath_inputs), |
| 495 options, | 500 options, |
| 501 depfile_deps=depfile_deps, |
| 496 input_paths=input_paths, | 502 input_paths=input_paths, |
| 497 input_strings=javac_cmd, | 503 input_strings=javac_cmd, |
| 498 output_paths=output_paths, | 504 output_paths=output_paths, |
| 499 force=force, | 505 force=force, |
| 500 pass_changes=True) | 506 pass_changes=True) |
| 501 | 507 |
| 502 | 508 |
| 503 if __name__ == '__main__': | 509 if __name__ == '__main__': |
| 504 sys.exit(main(sys.argv[1:])) | 510 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |