| 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 fnmatch | 7 import fnmatch |
| 8 import optparse | 8 import optparse |
| 9 import os | 9 import os |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 from util import build_utils | 12 from util import build_utils |
| 13 from util import md5_check | 13 from util import md5_check |
| 14 | 14 |
| 15 | 15 |
| 16 def DoJavac(options): | 16 def DoJavac(options): |
| 17 output_dir = options.output_dir | 17 output_dir = options.output_dir |
| 18 | 18 |
| 19 src_gendirs = build_utils.ParseGypList(options.src_gendirs) | 19 src_dirs = build_utils.ParseGypList(options.src_dirs) |
| 20 java_files = (open(options.src_filelist).read().splitlines() + | 20 java_files = build_utils.FindInDirectories(src_dirs, '*.java') |
| 21 build_utils.FindInDirectories(src_gendirs, '*.java')) | |
| 22 if options.javac_includes: | 21 if options.javac_includes: |
| 23 javac_includes = build_utils.ParseGypList(options.javac_includes) | 22 javac_includes = build_utils.ParseGypList(options.javac_includes) |
| 24 filtered_java_files = [] | 23 filtered_java_files = [] |
| 25 for f in java_files: | 24 for f in java_files: |
| 26 for include in javac_includes: | 25 for include in javac_includes: |
| 27 if fnmatch.fnmatch(f, include): | 26 if fnmatch.fnmatch(f, include): |
| 28 filtered_java_files.append(f) | 27 filtered_java_files.append(f) |
| 29 break | 28 break |
| 30 java_files = filtered_java_files | 29 java_files = filtered_java_files |
| 31 | 30 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 record_path = '%s/javac.md5.stamp' % options.output_dir | 69 record_path = '%s/javac.md5.stamp' % options.output_dir |
| 71 md5_check.CallAndRecordIfStale( | 70 md5_check.CallAndRecordIfStale( |
| 72 Compile, | 71 Compile, |
| 73 record_path=record_path, | 72 record_path=record_path, |
| 74 input_paths=java_files + jar_inputs, | 73 input_paths=java_files + jar_inputs, |
| 75 input_strings=javac_cmd) | 74 input_strings=javac_cmd) |
| 76 | 75 |
| 77 | 76 |
| 78 def main(argv): | 77 def main(argv): |
| 79 parser = optparse.OptionParser() | 78 parser = optparse.OptionParser() |
| 80 parser.add_option('--src-filelist', help='File list containing java files.') | 79 parser.add_option('--src-dirs', help='Directories containing java files.') |
| 81 parser.add_option('--src-gendirs', | |
| 82 help='Directories containing generated java files.') | |
| 83 parser.add_option('--javac-includes', | 80 parser.add_option('--javac-includes', |
| 84 help='A list of file patterns. If provided, only java files that match' + | 81 help='A list of file patterns. If provided, only java files that match' + |
| 85 'one of the patterns will be compiled.') | 82 'one of the patterns will be compiled.') |
| 86 parser.add_option('--classpath', help='Classpath for javac.') | 83 parser.add_option('--classpath', help='Classpath for javac.') |
| 87 parser.add_option('--output-dir', help='Directory for javac output.') | 84 parser.add_option('--output-dir', help='Directory for javac output.') |
| 88 parser.add_option('--stamp', help='Path to touch on success.') | 85 parser.add_option('--stamp', help='Path to touch on success.') |
| 89 parser.add_option('--chromium-code', type='int', help='Whether code being ' | 86 parser.add_option('--chromium-code', type='int', help='Whether code being ' |
| 90 'compiled should be built with stricter warnings for ' | 87 'compiled should be built with stricter warnings for ' |
| 91 'chromium code.') | 88 'chromium code.') |
| 92 | 89 |
| 93 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | 90 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
| 94 parser.add_option('--ignore', help='Ignored.') | 91 parser.add_option('--ignore', help='Ignored.') |
| 95 | 92 |
| 96 options, _ = parser.parse_args() | 93 options, _ = parser.parse_args() |
| 97 | 94 |
| 98 DoJavac(options) | 95 DoJavac(options) |
| 99 | 96 |
| 100 if options.stamp: | 97 if options.stamp: |
| 101 build_utils.Touch(options.stamp) | 98 build_utils.Touch(options.stamp) |
| 102 | 99 |
| 103 | 100 |
| 104 if __name__ == '__main__': | 101 if __name__ == '__main__': |
| 105 sys.exit(main(sys.argv)) | 102 sys.exit(main(sys.argv)) |
| 106 | 103 |
| 107 | 104 |
| OLD | NEW |