OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 | 2 |
3 # Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 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 """Creates a script to run a "_incremental" .apk.""" | 7 """Creates a script to run a "_incremental" .apk.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import os | 10 import os |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 """ | 47 """ |
48 | 48 |
49 | 49 |
50 def main(args): | 50 def main(args): |
51 args = build_utils.ExpandFileArgs(args) | 51 args = build_utils.ExpandFileArgs(args) |
52 parser = argparse.ArgumentParser() | 52 parser = argparse.ArgumentParser() |
53 build_utils.AddDepfileOption(parser) | 53 build_utils.AddDepfileOption(parser) |
54 parser.add_argument('--script-output-path', | 54 parser.add_argument('--script-output-path', |
55 help='Output path for executable script.', | 55 help='Output path for executable script.', |
56 required=True) | 56 required=True) |
| 57 parser.add_argument('--output-directory', |
| 58 help='Path to the root build directory.', |
| 59 default='.') |
57 parser.add_argument('--apk-path', | 60 parser.add_argument('--apk-path', |
58 help='Path to the .apk to install.', | 61 help='Path to the .apk to install.', |
59 required=True) | 62 required=True) |
60 parser.add_argument('--split', | 63 parser.add_argument('--split', |
61 action='append', | 64 action='append', |
62 dest='splits', | 65 dest='splits', |
63 default=[], | 66 default=[], |
64 help='A glob matching the apk splits. ' | 67 help='A glob matching the apk splits. ' |
65 'Can be specified multiple times.') | 68 'Can be specified multiple times.') |
66 parser.add_argument('--lib-dir', | 69 parser.add_argument('--lib-dir', |
67 help='Path to native libraries directory.') | 70 help='Path to native libraries directory.') |
68 | 71 |
69 options = parser.parse_args(args) | 72 options = parser.parse_args(args) |
70 | 73 |
71 def relativize(path): | 74 def relativize(path): |
72 return os.path.relpath(path, os.path.dirname(options.script_output_path)) | 75 return os.path.relpath(path, os.path.dirname(options.script_output_path)) |
73 | 76 |
74 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', | 77 incremental_install_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', |
75 'android', 'incremental_install.py') | 78 'android', 'incremental_install.py') |
76 incremental_install_path = relativize(incremental_install_path) | 79 incremental_install_path = relativize(incremental_install_path) |
77 | 80 |
78 incremental_install_path_args = [ | 81 incremental_install_path_args = [ |
| 82 ('--output-directory', relativize(options.output_directory)), |
79 (None, relativize(options.apk_path)), | 83 (None, relativize(options.apk_path)), |
80 ] | 84 ] |
81 if options.lib_dir: | 85 if options.lib_dir: |
82 incremental_install_path_args.append( | 86 incremental_install_path_args.append( |
83 ('--lib-dir', relativize(options.lib_dir))) | 87 ('--lib-dir', relativize(options.lib_dir))) |
84 for split_arg in options.splits: | 88 for split_arg in options.splits: |
85 incremental_install_path_args.append(('--split', relativize(split_arg))) | 89 incremental_install_path_args.append(('--split', relativize(split_arg))) |
86 | 90 |
87 with open(options.script_output_path, 'w') as script: | 91 with open(options.script_output_path, 'w') as script: |
88 script.write(SCRIPT_TEMPLATE.format( | 92 script.write(SCRIPT_TEMPLATE.format( |
89 cmd_path=repr(incremental_install_path), | 93 cmd_path=repr(incremental_install_path), |
90 cmd_args='[]', | 94 cmd_args='[]', |
91 cmd_path_args=repr(incremental_install_path_args))) | 95 cmd_path_args=repr(incremental_install_path_args))) |
92 | 96 |
93 os.chmod(options.script_output_path, 0750) | 97 os.chmod(options.script_output_path, 0750) |
94 | 98 |
95 if options.depfile: | 99 if options.depfile: |
96 build_utils.WriteDepfile( | 100 build_utils.WriteDepfile( |
97 options.depfile, | 101 options.depfile, |
98 build_utils.GetPythonDependencies()) | 102 build_utils.GetPythonDependencies()) |
99 | 103 |
100 | 104 |
101 if __name__ == '__main__': | 105 if __name__ == '__main__': |
102 sys.exit(main(sys.argv[1:])) | 106 sys.exit(main(sys.argv[1:])) |
OLD | NEW |