Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(45)

Side by Side Diff: build/android/javac.py

Issue 13432002: Add input content checking to some build scripts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(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 sys
11
12 from pylib import build_utils
13
14 def DoJavac(options):
15 output_dir = options.output_dir
16
17 src_dirs = build_utils.ParseGypList(options.src_dirs)
18 java_files = build_utils.FindInDirectories(src_dirs, '*.java')
19 if options.javac_includes:
20 javac_includes = build_utils.ParseGypList(options.javac_includes)
21 filtered_java_files = []
22 for f in java_files:
23 for include in javac_includes:
24 if fnmatch.fnmatch(f, include):
25 filtered_java_files.append(f)
26 break
27 java_files = filtered_java_files
28
29 # Compiling guava with certain orderings of input files causes a compiler
30 # crash... Sorted order works, so use that.
31 # See https://code.google.com/p/guava-libraries/issues/detail?id=950
32 java_files.sort()
33
34 classpath = build_utils.ParseGypList(options.classpath)
35
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
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.
40 build_utils.DeleteDirectory(output_dir)
41 build_utils.MakeDirectory(output_dir)
42
43 cmd = [
44 'javac',
45 '-g',
46 '-source', '1.5',
47 '-target', '1.5',
48 '-classpath', ':'.join(classpath),
49 '-d', output_dir]
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)
59
60 def main(argv):
61 parser = optparse.OptionParser()
62 parser.add_option('--src-dirs', help='Directories containing java files.')
63 parser.add_option('--javac-includes',
64 help='A list of file patterns. If provided, only java files that match' +
65 'one of the patterns will be compiled.')
66 parser.add_option('--classpath', help='Classpath for javac.')
67 parser.add_option('--output-dir', help='Directory for javac output.')
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.')
72
73 # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja.
74 parser.add_option('--ignore', help='Ignored.')
75
76 options, _ = parser.parse_args()
77
78 DoJavac(options)
79
80 if options.stamp:
81 build_utils.Touch(options.stamp)
82
83
84 if __name__ == '__main__':
85 sys.exit(main(sys.argv))
86
87
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698