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 an "_incremental" .apk.""" | 7 """Creates a script to run an "_incremental" .apk.""" |
8 | 8 |
9 import argparse | 9 import argparse |
10 import os | 10 import os |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 | 31 |
32 def _ResolvePath(path): | 32 def _ResolvePath(path): |
33 script_directory = os.path.dirname(__file__) | 33 script_directory = os.path.dirname(__file__) |
34 return os.path.abspath(os.path.join(script_directory, path)) | 34 return os.path.abspath(os.path.join(script_directory, path)) |
35 | 35 |
36 | 36 |
37 # Exported to allow test runner to be able to install incremental apks. | 37 # Exported to allow test runner to be able to install incremental apks. |
38 def GetInstallParameters(): | 38 def GetInstallParameters(): |
39 apk_path = {apk_path} | 39 apk_path = {apk_path} |
40 lib_dir = {lib_dir} | 40 native_libs = {native_libs} |
41 dex_files = {dex_files} | 41 dex_files = {dex_files} |
42 splits = {splits} | 42 splits = {splits} |
43 show_proguard_warning = {show_proguard_warning} | 43 show_proguard_warning = {show_proguard_warning} |
44 | 44 |
45 return dict(apk_path=_ResolvePath(apk_path), | 45 return dict(apk_path=_ResolvePath(apk_path), |
46 dex_files=[_ResolvePath(p) for p in dex_files], | 46 dex_files=[_ResolvePath(p) for p in dex_files], |
47 lib_dir=_ResolvePath(lib_dir), | 47 native_libs=[_ResolvePath(p) for p in native_libs], |
48 show_proguard_warning=show_proguard_warning, | 48 show_proguard_warning=show_proguard_warning, |
49 splits=[_ResolvePath(p) for p in splits]) | 49 splits=[_ResolvePath(p) for p in splits]) |
50 | 50 |
51 | 51 |
52 def main(): | 52 def main(): |
53 output_directory = {output_directory} | 53 output_directory = {output_directory} |
54 cmd_path = {cmd_path} | 54 cmd_path = {cmd_path} |
55 params = GetInstallParameters() | 55 params = GetInstallParameters() |
56 cmd_args = [ | 56 cmd_args = [ |
57 _ResolvePath(cmd_path), | 57 _ResolvePath(cmd_path), |
58 '--output-directory', _ResolvePath(output_directory), | 58 '--output-directory', _ResolvePath(output_directory), |
59 ] | 59 ] |
60 if params['lib_dir']: | 60 for native_lib in params['native_libs']: |
61 cmd_args.extend(('--lib-dir', params['lib_dir'])) | 61 cmd_args.extend(('--native_lib', native_lib)) |
62 for dex_path in params['dex_files']: | 62 for dex_path in params['dex_files']: |
63 cmd_args.extend(('--dex-file', dex_path)) | 63 cmd_args.extend(('--dex-file', dex_path)) |
64 for split in params['splits']: | 64 for split in params['splits']: |
65 cmd_args.extend(('--split', split)) | 65 cmd_args.extend(('--split', split)) |
66 cmd_args.append(params['apk_path']) | 66 cmd_args.append(params['apk_path']) |
67 if params['show_proguard_warning']: | 67 if params['show_proguard_warning']: |
68 cmd_args.append('--show-proguard-warning') | 68 cmd_args.append('--show-proguard-warning') |
69 return subprocess.call(cmd_args + sys.argv[1:]) | 69 return subprocess.call(cmd_args + sys.argv[1:]) |
70 | 70 |
71 if __name__ == '__main__': | 71 if __name__ == '__main__': |
(...skipping 13 matching lines...) Expand all Loading... |
85 default='.') | 85 default='.') |
86 parser.add_argument('--apk-path', | 86 parser.add_argument('--apk-path', |
87 help='Path to the .apk to install.', | 87 help='Path to the .apk to install.', |
88 required=True) | 88 required=True) |
89 parser.add_argument('--split', | 89 parser.add_argument('--split', |
90 action='append', | 90 action='append', |
91 dest='splits', | 91 dest='splits', |
92 default=[], | 92 default=[], |
93 help='A glob matching the apk splits. ' | 93 help='A glob matching the apk splits. ' |
94 'Can be specified multiple times.') | 94 'Can be specified multiple times.') |
95 parser.add_argument('--lib-dir', | 95 parser.add_argument('--native-libs', |
96 help='Path to native libraries directory.') | 96 action='append', |
| 97 default=[], |
| 98 help='GYP-list of paths to native libraries. Can be ' |
| 99 'repeated.') |
97 parser.add_argument('--dex-file', | 100 parser.add_argument('--dex-file', |
98 action='append', | 101 action='append', |
99 default=[], | 102 default=[], |
100 dest='dex_files', | 103 dest='dex_files', |
101 help='List of dex files to include.') | 104 help='List of dex files to include.') |
102 parser.add_argument('--dex-file-list', | 105 parser.add_argument('--dex-file-list', |
103 help='GYP-list of dex files.') | 106 help='GYP-list of dex files.') |
104 parser.add_argument('--show-proguard-warning', | 107 parser.add_argument('--show-proguard-warning', |
105 action='store_true', | 108 action='store_true', |
106 default=False, | 109 default=False, |
107 help='Print a warning about proguard being disabled') | 110 help='Print a warning about proguard being disabled') |
108 | 111 |
109 options = parser.parse_args(args) | 112 options = parser.parse_args(args) |
110 options.dex_files += build_utils.ParseGypList(options.dex_file_list) | 113 options.dex_files += build_utils.ParseGypList(options.dex_file_list) |
| 114 all_libs = [] |
| 115 for gyp_list in options.native_libs: |
| 116 all_libs.extend(build_utils.ParseGypList(gyp_list)) |
| 117 options.native_libs = all_libs |
111 return options | 118 return options |
112 | 119 |
113 | 120 |
114 def main(args): | 121 def main(args): |
115 options = _ParseArgs(args) | 122 options = _ParseArgs(args) |
116 | 123 |
117 def relativize(path): | 124 def relativize(path): |
118 script_dir = os.path.dirname(options.script_output_path) | 125 script_dir = os.path.dirname(options.script_output_path) |
119 return path and os.path.relpath(path, script_dir) | 126 return path and os.path.relpath(path, script_dir) |
120 | 127 |
121 installer_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', | 128 installer_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', |
122 'incremental_install', 'installer.py') | 129 'incremental_install', 'installer.py') |
123 pformat = pprint.pformat | 130 pformat = pprint.pformat |
124 template_args = { | 131 template_args = { |
125 'cmd_path': pformat(relativize(installer_path)), | 132 'cmd_path': pformat(relativize(installer_path)), |
126 'apk_path': pformat(relativize(options.apk_path)), | 133 'apk_path': pformat(relativize(options.apk_path)), |
127 'output_directory': pformat(relativize(options.output_directory)), | 134 'output_directory': pformat(relativize(options.output_directory)), |
128 'lib_dir': pformat(relativize(options.lib_dir)), | 135 'native_libs': pformat([relativize(p) for p in options.native_libs]), |
129 'dex_files': pformat([relativize(p) for p in options.dex_files]), | 136 'dex_files': pformat([relativize(p) for p in options.dex_files]), |
130 'show_proguard_warning': pformat(options.show_proguard_warning), | 137 'show_proguard_warning': pformat(options.show_proguard_warning), |
131 'splits': pformat([relativize(p) for p in options.splits]), | 138 'splits': pformat([relativize(p) for p in options.splits]), |
132 } | 139 } |
133 | 140 |
134 with open(options.script_output_path, 'w') as script: | 141 with open(options.script_output_path, 'w') as script: |
135 script.write(SCRIPT_TEMPLATE.format(**template_args)) | 142 script.write(SCRIPT_TEMPLATE.format(**template_args)) |
136 | 143 |
137 os.chmod(options.script_output_path, 0750) | 144 os.chmod(options.script_output_path, 0750) |
138 | 145 |
139 if options.depfile: | 146 if options.depfile: |
140 build_utils.WriteDepfile( | 147 build_utils.WriteDepfile( |
141 options.depfile, | 148 options.depfile, |
142 build_utils.GetPythonDependencies()) | 149 build_utils.GetPythonDependencies()) |
143 | 150 |
144 | 151 |
145 if __name__ == '__main__': | 152 if __name__ == '__main__': |
146 sys.exit(main(sys.argv[1:])) | 153 sys.exit(main(sys.argv[1:])) |
OLD | NEW |