Index: build/android/jar.py |
diff --git a/build/android/jar.py b/build/android/jar.py |
new file mode 100755 |
index 0000000000000000000000000000000000000000..ee83d1067e1042b90b82d2e62ad0bb529e0d0e3a |
--- /dev/null |
+++ b/build/android/jar.py |
@@ -0,0 +1,54 @@ |
+#!/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 DoJar(options): |
+ class_files = build_utils.FindInDirectory(options.classes_dir, '*.class') |
+ for exclude in build_utils.ParseGypList(options.jar_excludes): |
+ class_files = filter( |
+ lambda f: not fnmatch.fnmatch(f, exclude), class_files) |
+ |
+ jar_path = os.path.abspath(options.jar_path) |
+ |
+ # The paths of the files in the jar will be the same as they are passed in to |
+ # the command. Because of this, the command should be run in |
+ # options.classes_dir so the .class file paths in the jar are correct. |
+ jar_cwd = options.classes_dir |
+ class_files = map(lambda f: os.path.relpath(f, jar_cwd), class_files) |
newt (away)
2013/03/15 03:25:04
I think a list comprehension is preferred:
class_
cjhopman
2013/03/15 22:44:39
Done. Not preferred by me, though :).
|
+ jar_cmd = ['jar', 'cf0', jar_path] + class_files |
+ subprocess.check_call(jar_cmd, cwd=jar_cwd) |
+ |
+ |
+def main(argv): |
+ parser = optparse.OptionParser() |
+ parser.add_option('--classes-dir') |
+ parser.add_option('--jar-path') |
+ parser.add_option('--jar-excludes') |
+ 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() |
+ |
+ DoJar(options) |
+ |
+ if options.stamp: |
+ build_utils.Touch(options.stamp) |
+ |
+ |
+if __name__ == '__main__': |
+ sys.exit(main(sys.argv)) |
+ |
Yaron
2013/03/14 23:03:51
double trailing ws?
cjhopman
2013/03/15 22:44:39
Done.
|
+ |