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