OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # | 2 # |
3 # Copyright 2014 The Chromium Authors. All rights reserved. | 3 # Copyright 2014 The Chromium Authors. All rights reserved. |
4 # Use of this source code is governed by a BSD-style license that can be | 4 # Use of this source code is governed by a BSD-style license that can be |
5 # found in the LICENSE file. | 5 # found in the LICENSE file. |
6 | 6 |
7 import optparse | 7 import optparse |
8 import os | 8 import os |
9 import sys | 9 import sys |
10 | 10 |
11 REPOSITORY_ROOT = os.path.abspath(os.path.join( | 11 REPOSITORY_ROOT = os.path.abspath(os.path.join( |
12 os.path.dirname(__file__), '..', '..', '..')) | 12 os.path.dirname(__file__), '..', '..', '..')) |
13 | 13 |
14 sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util')) | 14 sys.path.append(os.path.join(REPOSITORY_ROOT, 'build/android/gyp/util')) |
15 import build_utils | 15 import build_utils |
16 | 16 |
17 | 17 |
18 def ExtractJars(options): | 18 def ExtractJars(options): |
19 # The paths of the files in the jar will be the same as they are passed in to | 19 # The paths of the files in the jar will be the same as they are passed in to |
20 # the command. Because of this, the command should be run in | 20 # the command. Because of this, the command should be run in |
21 # options.classes_dir so the .class file paths in the jar are correct. | 21 # options.classes_dir so the .class file paths in the jar are correct. |
22 jar_cwd = options.classes_dir | 22 jar_cwd = options.classes_dir |
23 build_utils.DeleteDirectory(jar_cwd) | 23 build_utils.DeleteDirectory(jar_cwd) |
24 build_utils.MakeDirectory(jar_cwd) | 24 build_utils.MakeDirectory(jar_cwd) |
25 for jar in build_utils.ParseGypList(options.jars): | 25 for jar in build_utils.ParseGnList(options.jars): |
26 jar_path = os.path.abspath(jar) | 26 jar_path = os.path.abspath(jar) |
27 jar_cmd = ['jar', 'xf', jar_path] | 27 jar_cmd = ['jar', 'xf', jar_path] |
28 build_utils.CheckOutput(jar_cmd, cwd=jar_cwd) | 28 build_utils.CheckOutput(jar_cmd, cwd=jar_cwd) |
29 | 29 |
30 | 30 |
31 def main(): | 31 def main(): |
32 parser = optparse.OptionParser() | 32 parser = optparse.OptionParser() |
33 build_utils.AddDepfileOption(parser) | 33 build_utils.AddDepfileOption(parser) |
34 parser.add_option('--classes-dir', help='Directory to extract .class files.') | 34 parser.add_option('--classes-dir', help='Directory to extract .class files.') |
35 parser.add_option('--jars', help='Paths to jars to extract.') | 35 parser.add_option('--jars', help='Paths to jars to extract.') |
36 parser.add_option('--stamp', help='Path to touch on success.') | 36 parser.add_option('--stamp', help='Path to touch on success.') |
37 | 37 |
38 options, _ = parser.parse_args() | 38 options, _ = parser.parse_args() |
39 | 39 |
40 ExtractJars(options) | 40 ExtractJars(options) |
41 | 41 |
42 if options.depfile: | 42 if options.depfile: |
43 build_utils.WriteDepfile(options.depfile, | 43 build_utils.WriteDepfile(options.depfile, |
44 build_utils.GetPythonDependencies()) | 44 build_utils.GetPythonDependencies()) |
45 | 45 |
46 if options.stamp: | 46 if options.stamp: |
47 build_utils.Touch(options.stamp) | 47 build_utils.Touch(options.stamp) |
48 | 48 |
49 | 49 |
50 if __name__ == '__main__': | 50 if __name__ == '__main__': |
51 sys.exit(main()) | 51 sys.exit(main()) |
52 | 52 |
OLD | NEW |