OLD | NEW |
---|---|
(Empty) | |
1 #!/usr/bin/env python | |
jbudorick
2015/08/27 00:37:37
build/android/gn...?
I'd rather not have one buil
agrieve
2015/08/27 03:19:59
Me neither! Figured it could keep https://code.goo
jbudorick
2015/08/27 03:24:09
... I probably should've looked for that beforehan
| |
2 | |
3 # Copyright 2015 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 """Creates a script to run a "_incremental" .apk.""" | |
8 | |
9 import argparse | |
10 import os | |
11 import sys | |
12 | |
13 sys.path.append(os.path.join(os.path.dirname(__file__), os.pardir)) | |
14 from gyp.util import build_utils | |
15 from pylib import constants | |
16 | |
17 | |
18 SCRIPT_TEMPLATE = """\ | |
19 #!/usr/bin/env python | |
20 # | |
21 # This file was generated by: | |
22 # //build/android/gyp/create_incremental_install_script.py | |
23 | |
24 import os | |
25 import subprocess | |
26 import sys | |
27 | |
28 def main(): | |
29 script_directory = os.path.dirname(__file__) | |
30 | |
31 def resolve_path(path): | |
32 return os.path.abspath(os.path.join(script_directory, path)) | |
33 | |
34 cmd_path = resolve_path({cmd_path}) | |
35 cmd_args = [cmd_path] + {cmd_args} | |
36 cmd_path_args = {cmd_path_args} | |
37 for arg, path in cmd_path_args: | |
38 if arg: | |
39 cmd_args.append(arg) | |
40 cmd_args.append(resolve_path(path)) | |
41 | |
42 return subprocess.call(cmd_args + sys.argv[1:]) | |
43 | |
44 if __name__ == '__main__': | |
45 sys.exit(main()) | |
46 """ | |
47 | |
48 | |
49 def main(args): | |
50 args = build_utils.ExpandFileArgs(args) | |
51 parser = argparse.ArgumentParser() | |
52 build_utils.AddDepfileOption(parser) | |
53 parser.add_argument('--script-output-path', | |
54 help='Output path for executable script.', | |
55 required=True) | |
56 parser.add_argument('--apk-path', | |
57 help='Path to the .apk to install.', | |
58 required=True) | |
59 parser.add_argument('--split', | |
60 action='append', | |
61 dest='splits', | |
62 default=[], | |
63 help='A glob matching the apk splits. ' | |
64 'Can be specified multiple times.') | |
65 parser.add_argument('--lib-dir', | |
66 help='Path to native libraries directory.') | |
67 | |
68 options = parser.parse_args(args) | |
69 | |
70 def relativize(path): | |
71 return os.path.relpath(path, os.path.dirname(options.script_output_path)) | |
72 | |
73 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', | |
74 'android', 'incremental_install.py') | |
75 incremental_install_path = relativize(incremental_install_path) | |
76 | |
77 incremental_install_path_args = [ | |
78 (None, relativize(options.apk_path)), | |
79 ] | |
80 if options.lib_dir: | |
81 incremental_install_path_args.append( | |
82 ('--lib-dir', relativize(options.lib_dir))) | |
83 for split_arg in options.splits: | |
84 incremental_install_path_args.append(('--split', relativize(split_arg))) | |
85 | |
86 with open(options.script_output_path, 'w') as script: | |
87 script.write(SCRIPT_TEMPLATE.format( | |
88 cmd_path=repr(incremental_install_path), | |
89 cmd_args='[]', | |
90 cmd_path_args=repr(incremental_install_path_args))) | |
91 | |
92 os.chmod(options.script_output_path, 0750) | |
93 | |
94 if options.depfile: | |
95 build_utils.WriteDepfile( | |
96 options.depfile, | |
97 build_utils.GetPythonDependencies()) | |
98 | |
99 | |
100 if __name__ == '__main__': | |
101 sys.exit(main(sys.argv[1:])) | |
OLD | NEW |