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 subprocess | 10 import subprocess |
(...skipping 23 matching lines...) Expand all Loading... | |
34 | 34 |
35 classpath = build_utils.ParseGypList(options.classpath) | 35 classpath = build_utils.ParseGypList(options.classpath) |
36 | 36 |
37 # Delete the classes directory. This ensures that all .class files in the | 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 | 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 | 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. | 40 # not contain the corresponding old .class file after running this action. |
41 build_utils.DeleteDirectory(output_dir) | 41 build_utils.DeleteDirectory(output_dir) |
42 build_utils.MakeDirectory(output_dir) | 42 build_utils.MakeDirectory(output_dir) |
43 | 43 |
44 subprocess.check_call([ | 44 cmd = [ |
45 'javac', | 45 'javac', |
46 '-g', | 46 '-g', |
47 '-Xlint:unchecked', | |
48 '-source', '1.5', | 47 '-source', '1.5', |
49 '-target', '1.5', | 48 '-target', '1.5', |
50 '-classpath', ':'.join(classpath), | 49 '-classpath', ':'.join(classpath), |
51 '-d', output_dir] + | 50 '-d', output_dir] |
52 java_files) | |
53 | 51 |
52 # Only output Java warnings for chromium code | |
53 if options.chromium_code: | |
54 cmd += ['-Xlint:unchecked'] | |
55 else: | |
56 cmd += [# Suppress "Sun proprietary API" warnings. See: | |
57 # http://stackoverflow.com/questions/1136659/how-can-i-suppress-java -compiler-warnings-about-sun-proprietary-api | |
58 '-XDignore.symbol.file'] | |
59 | |
60 subprocess.check_call(cmd + java_files) | |
54 | 61 |
55 def main(argv): | 62 def main(argv): |
56 parser = optparse.OptionParser() | 63 parser = optparse.OptionParser() |
57 parser.add_option('--src-dirs', help='Directories containing java files.') | 64 parser.add_option('--src-dirs', help='Directories containing java files.') |
58 parser.add_option('--javac-includes', | 65 parser.add_option('--javac-includes', |
59 help='A list of file patterns. If provided, only java files that match' + | 66 help='A list of file patterns. If provided, only java files that match' + |
60 'one of the patterns will be compiled.') | 67 'one of the patterns will be compiled.') |
61 parser.add_option('--classpath', help='Classpath for javac.') | 68 parser.add_option('--classpath', help='Classpath for javac.') |
62 parser.add_option('--output-dir', help='Directory for javac output.') | 69 parser.add_option('--output-dir', help='Directory for javac output.') |
63 parser.add_option('--stamp', help='Path to touch on success.') | 70 parser.add_option('--stamp', help='Path to touch on success.') |
71 parser.add_option('--chromium-code', type='int', help='Whether code being' | |
cjhopman
2013/04/01 20:33:13
Nit: space at end of string
| |
72 'compiled should be built with stricter warnings for ' | |
73 'chromium code.') | |
64 | 74 |
65 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. | 75 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
66 parser.add_option('--ignore', help='Ignored.') | 76 parser.add_option('--ignore', help='Ignored.') |
67 | 77 |
68 options, _ = parser.parse_args() | 78 options, _ = parser.parse_args() |
69 | 79 |
70 DoJavac(options) | 80 DoJavac(options) |
71 | 81 |
72 if options.stamp: | 82 if options.stamp: |
73 build_utils.Touch(options.stamp) | 83 build_utils.Touch(options.stamp) |
74 | 84 |
75 | 85 |
76 if __name__ == '__main__': | 86 if __name__ == '__main__': |
77 sys.exit(main(sys.argv)) | 87 sys.exit(main(sys.argv)) |
78 | 88 |
79 | 89 |
OLD | NEW |