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.
12 from util
import build_utils
16 output_dir
= options
.output_dir
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
= []
24 for include
in javac_includes
:
25 if fnmatch
.fnmatch(f
, include
):
26 filtered_java_files
.append(f
)
28 java_files
= filtered_java_files
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
35 classpath
= build_utils
.ParseGypList(options
.classpath
)
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
)
49 '-classpath', ':'.join(classpath
),
55 suppress_output
= not options
.chromium_code
56 build_utils
.CheckCallDie(cmd
+ java_files
, suppress_output
=suppress_output
)
59 parser
= optparse
.OptionParser()
60 parser
.add_option('--src-dirs', help='Directories containing java files.')
61 parser
.add_option('--javac-includes',
62 help='A list of file patterns. If provided, only java files that match' +
63 'one of the patterns will be compiled.')
64 parser
.add_option('--classpath', help='Classpath for javac.')
65 parser
.add_option('--output-dir', help='Directory for javac output.')
66 parser
.add_option('--stamp', help='Path to touch on success.')
67 parser
.add_option('--chromium-code', type='int', help='Whether code being '
68 'compiled should be built with stricter warnings for '
71 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
72 parser
.add_option('--ignore', help='Ignored.')
74 options
, _
= parser
.parse_args()
79 build_utils
.Touch(options
.stamp
)
82 if __name__
== '__main__':
83 sys
.exit(main(sys
.argv
))