summaryrefslogtreecommitdiffstats
path: root/components/cronet/tools/extract_from_jars.py
diff options
context:
space:
mode:
Diffstat (limited to 'components/cronet/tools/extract_from_jars.py')
-rwxr-xr-xcomponents/cronet/tools/extract_from_jars.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/components/cronet/tools/extract_from_jars.py b/components/cronet/tools/extract_from_jars.py
new file mode 100755
index 0000000..d72d46c
--- /dev/null
+++ b/components/cronet/tools/extract_from_jars.py
@@ -0,0 +1,48 @@
+#!/usr/bin/env python
+#
+# Copyright 2014 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 sys
+
+REPOSITORY_ROOT = os.path.abspath(os.path.join(
+ os.path.dirname(__file__), '..', '..', '..'))
+
+sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util'))
+import build_utils
+
+
+def ExtractJars(options):
+ # 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
+ build_utils.DeleteDirectory(jar_cwd)
+ build_utils.MakeDirectory(jar_cwd)
+ for jar in build_utils.ParseGypList(options.jars):
+ jar_path = os.path.abspath(jar)
+ jar_cmd = ['jar', 'xf', jar_path]
+ build_utils.CheckOutput(jar_cmd, cwd=jar_cwd)
+
+
+def main():
+ parser = optparse.OptionParser()
+ parser.add_option('--classes-dir', help='Directory to extract .class files.')
+ parser.add_option('--jars', help='Paths to jars to extract.')
+ parser.add_option('--stamp', help='Path to touch on success.')
+
+ options, _ = parser.parse_args()
+
+ ExtractJars(options)
+
+ if options.stamp:
+ build_utils.Touch(options.stamp)
+
+
+if __name__ == '__main__':
+ sys.exit(main())
+