Index: build/android/javac.py |
diff --git a/build/android/javac.py b/build/android/javac.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..8607d02d2181ce3ae7c68089662503cd6762bb30 |
--- /dev/null |
+++ b/build/android/javac.py |
@@ -0,0 +1,72 @@ |
+#!/usr/bin/env python |
+# |
+# Copyright 2013 The Chromium Authors. All rights reserved. |
+# Use of this source code is governed by a BSD-style license that can be |
+# found in the LICENSE file. |
+ |
+import fnmatch |
+import optparse |
+import os |
+import subprocess |
+import sys |
+ |
+from pylib import build_utils |
+ |
+def DoJavac(options): |
+ intermediate_dir = options.intermediate_dir |
+ |
+ srcdirs = build_utils.ParseGypList(options.src_dirs) |
Yaron
2013/03/14 23:03:51
nit:src_dirs
cjhopman
2013/03/15 22:44:39
Done.
|
+ java_files = build_utils.FindInDirectories(srcdirs, '*.java') |
+ if len(options.javac_includes) > 0: |
Yaron
2013/03/14 23:03:51
nit: omit "> 0"
newt (away)
2013/03/15 03:25:04
nit: omit "len()"
cjhopman
2013/03/15 22:44:39
Done.
cjhopman
2013/03/15 22:44:39
Done.
|
+ javac_includes = build_utils.ParseGypList(options.javac_includes) |
+ filtered_java_files = [] |
+ for f in java_files: |
+ for include in javac_includes: |
+ if fnmatch.fnmatch(f, include): |
+ filtered_java_files.append(f) |
newt (away)
2013/03/15 03:25:04
break (so you don't end up with the same file incl
cjhopman
2013/03/15 22:44:39
Done.
|
+ java_files = filtered_java_files |
+ |
+ # Compiling guava with certain orderings of input files causes a compiler |
+ # crash... Sorted order works, so use that. |
Yaron
2013/03/14 23:03:51
nice
cjhopman
2013/03/15 22:44:39
Yeah, isn't it...
|
+ # See https://code.google.com/p/guava-libraries/issues/detail?id=950 |
+ java_files = sorted(java_files) |
newt (away)
2013/03/15 03:25:04
or java_files.sort()
cjhopman
2013/03/15 22:44:39
Done.
|
+ |
+ classpath = build_utils.ParseGypList(options.input_jars_paths) |
+ |
+ build_utils.DeleteDirectory(intermediate_dir) |
Yaron
2013/03/14 23:03:51
Add comment about deleting .class files (similar t
cjhopman
2013/03/15 22:44:39
Done.
|
+ build_utils.EnsureDirectoryExists(intermediate_dir) |
+ |
+ subprocess.check_call( |
+ ['javac', |
+ '-g', |
Yaron
2013/03/14 23:03:51
Shouldn't this indet match the ' above?
cjhopman
2013/03/15 22:44:39
Actually, I think it should match the 'j' or the '
Yaron
2013/03/15 23:13:46
My vi says it should match the quote, but this is
|
+ '-Xlint:unchecked', |
+ '-source', '1.5', |
newt (away)
2013/03/15 03:25:04
I thought we used 1.6, but I trust you here
cjhopman
2013/03/15 22:44:39
So, currrently, we use 1.6 for libraries and 1.5 f
|
+ '-target', '1.5', |
+ '-classpath', ':'.join(classpath), |
+ '-d', intermediate_dir] |
+ + java_files) |
+ |
+ |
+def main(argv): |
+ parser = optparse.OptionParser() |
+ parser.add_option('--intermediate-dir') |
Yaron
2013/03/14 23:03:51
Can you add the description fields to each of thes
cjhopman
2013/03/15 22:44:39
Done.
|
+ parser.add_option('--input-jars-paths') |
Yaron
2013/03/14 23:03:51
Any reason not to rename this classpath?
cjhopman
2013/03/15 22:44:39
Done.
|
+ parser.add_option('--javac-includes') |
+ parser.add_option('--src-dirs') |
+ parser.add_option('--stamp') |
+ |
+ # TODO(newt): remove this once http://crbug.com/177552 is fixed in ninja. |
+ parser.add_option('--ignore') |
+ |
+ options, _ = parser.parse_args() |
+ |
+ DoJavac(options) |
+ |
+ if options.stamp: |
+ build_utils.Touch(options.stamp) |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv)) |
+ |
+ |