Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 #!/usr/bin/env python | |
| 2 # | |
| 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 | |
| 5 # found in the LICENSE file. | |
| 6 | |
| 7 import fnmatch | |
| 8 import optparse | |
| 9 import os | |
| 10 import subprocess | |
| 11 import sys | |
| 12 | |
| 13 from pylib import build_utils | |
| 14 | |
| 15 def DoJavac(options): | |
| 16 output_dir = options.output_dir | |
| 17 | |
| 18 src_dirs = build_utils.ParseGypList(options.src_dirs) | |
| 19 java_files = build_utils.FindInDirectories(src_dirs, '*.java') | |
| 20 if options.javac_includes: | |
| 21 javac_includes = build_utils.ParseGypList(options.javac_includes) | |
| 22 filtered_java_files = [] | |
| 23 for f in java_files: | |
| 24 for include in javac_includes: | |
| 25 if fnmatch.fnmatch(f, include): | |
| 26 filtered_java_files.append(f) | |
| 27 break | |
| 28 java_files = filtered_java_files | |
| 29 | |
| 30 # Compiling guava with certain orderings of input files causes a compiler | |
| 31 # crash... Sorted order works, so use that. | |
| 32 # See https://code.google.com/p/guava-libraries/issues/detail?id=950 | |
| 33 java_files.sort() | |
| 34 | |
| 35 classpath = build_utils.ParseGypList(options.classpath) | |
| 36 | |
| 37 # Delete the classes directory. This ensures that all .class files in the | |
| 38 # output are actually from the input .java files. For example, if a .java | |
| 39 # file is deleted or an inner class is removed, the classes directory should | |
| 40 # not contain the corresponding old .class file after running this action. | |
| 41 build_utils.DeleteDirectory(output_dir) | |
| 42 build_utils.MakeDirectory(output_dir) | |
| 43 | |
| 44 subprocess.check_call([ | |
| 45 'javac', | |
|
newt (away)
2013/03/15 23:01:19
indent by 4
| |
| 46 '-g', | |
| 47 '-Xlint:unchecked', | |
| 48 '-source', '1.5', | |
| 49 '-target', '1.5', | |
| 50 '-classpath', ':'.join(classpath), | |
| 51 '-d', output_dir] + | |
| 52 java_files) | |
| 53 | |
| 54 | |
| 55 def main(argv): | |
| 56 parser = optparse.OptionParser() | |
| 57 parser.add_option('--src-dirs', help='Directories containing java files.') | |
| 58 parser.add_option('--javac-includes', | |
| 59 help='A list of file patterns. If provided, only java files that match' + | |
| 60 'one of the patterns will be compiled.') | |
| 61 parser.add_option('--classpath', help='Classpath for javac.') | |
| 62 parser.add_option('--output-dir', help='Directory for javac output.') | |
| 63 parser.add_option('--stamp', help='Path to touch on success.') | |
| 64 | |
| 65 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | |
| 66 parser.add_option('--ignore', help='Ignored.') | |
| 67 | |
| 68 options, _ = parser.parse_args() | |
| 69 | |
| 70 DoJavac(options) | |
| 71 | |
| 72 if options.stamp: | |
| 73 build_utils.Touch(options.stamp) | |
| 74 | |
| 75 | |
| 76 if __name__ == '__main__': | |
| 77 sys.exit(main(sys.argv)) | |
| 78 | |
| 79 | |
| OLD | NEW |