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 22 matching lines...) Expand all Loading... |
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 lib_dir = {lib_dir} |
41 dex_files = {dex_files} | 41 dex_files = {dex_files} |
42 splits = {splits} | 42 splits = {splits} |
| 43 show_proguard_warning = {show_proguard_warning} |
43 | 44 |
44 return dict(apk_path=_ResolvePath(apk_path), | 45 return dict(apk_path=_ResolvePath(apk_path), |
45 dex_files=[_ResolvePath(p) for p in dex_files], | 46 dex_files=[_ResolvePath(p) for p in dex_files], |
46 lib_dir=_ResolvePath(lib_dir), | 47 lib_dir=_ResolvePath(lib_dir), |
| 48 show_proguard_warning=show_proguard_warning, |
47 splits=[_ResolvePath(p) for p in splits]) | 49 splits=[_ResolvePath(p) for p in splits]) |
48 | 50 |
49 | 51 |
50 def main(): | 52 def main(): |
51 output_directory = {output_directory} | 53 output_directory = {output_directory} |
52 cmd_path = {cmd_path} | 54 cmd_path = {cmd_path} |
53 params = GetInstallParameters() | 55 params = GetInstallParameters() |
54 cmd_args = [ | 56 cmd_args = [ |
55 _ResolvePath(cmd_path), | 57 _ResolvePath(cmd_path), |
56 '--output-directory', _ResolvePath(output_directory), | 58 '--output-directory', _ResolvePath(output_directory), |
57 ] | 59 ] |
58 if params['lib_dir']: | 60 if params['lib_dir']: |
59 cmd_args.extend(('--lib-dir', params['lib_dir'])) | 61 cmd_args.extend(('--lib-dir', params['lib_dir'])) |
60 for dex_path in params['dex_files']: | 62 for dex_path in params['dex_files']: |
61 cmd_args.extend(('--dex-file', dex_path)) | 63 cmd_args.extend(('--dex-file', dex_path)) |
62 for split in params['splits']: | 64 for split in params['splits']: |
63 cmd_args.extend(('--split', split)) | 65 cmd_args.extend(('--split', split)) |
64 cmd_args.append(params['apk_path']) | 66 cmd_args.append(params['apk_path']) |
| 67 if params['show_proguard_warning']: |
| 68 cmd_args.append('--show-proguard-warning') |
65 return subprocess.call(cmd_args + sys.argv[1:]) | 69 return subprocess.call(cmd_args + sys.argv[1:]) |
66 | 70 |
67 if __name__ == '__main__': | 71 if __name__ == '__main__': |
68 sys.exit(main()) | 72 sys.exit(main()) |
69 """ | 73 """ |
70 | 74 |
71 | 75 |
72 def _ParseArgs(args): | 76 def _ParseArgs(args): |
73 args = build_utils.ExpandFileArgs(args) | 77 args = build_utils.ExpandFileArgs(args) |
74 parser = argparse.ArgumentParser() | 78 parser = argparse.ArgumentParser() |
(...skipping 15 matching lines...) Expand all Loading... |
90 'Can be specified multiple times.') | 94 'Can be specified multiple times.') |
91 parser.add_argument('--lib-dir', | 95 parser.add_argument('--lib-dir', |
92 help='Path to native libraries directory.') | 96 help='Path to native libraries directory.') |
93 parser.add_argument('--dex-file', | 97 parser.add_argument('--dex-file', |
94 action='append', | 98 action='append', |
95 default=[], | 99 default=[], |
96 dest='dex_files', | 100 dest='dex_files', |
97 help='List of dex files to include.') | 101 help='List of dex files to include.') |
98 parser.add_argument('--dex-file-list', | 102 parser.add_argument('--dex-file-list', |
99 help='GYP-list of dex files.') | 103 help='GYP-list of dex files.') |
| 104 parser.add_argument('--show-proguard-warning', |
| 105 action='store_true', |
| 106 default=False, |
| 107 help='Print a warning about proguard being disabled') |
100 | 108 |
101 options = parser.parse_args(args) | 109 options = parser.parse_args(args) |
102 options.dex_files += build_utils.ParseGypList(options.dex_file_list) | 110 options.dex_files += build_utils.ParseGypList(options.dex_file_list) |
103 return options | 111 return options |
104 | 112 |
105 | 113 |
106 def main(args): | 114 def main(args): |
107 options = _ParseArgs(args) | 115 options = _ParseArgs(args) |
108 | 116 |
109 def relativize(path): | 117 def relativize(path): |
110 script_dir = os.path.dirname(options.script_output_path) | 118 script_dir = os.path.dirname(options.script_output_path) |
111 return path and os.path.relpath(path, script_dir) | 119 return path and os.path.relpath(path, script_dir) |
112 | 120 |
113 installer_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', | 121 installer_path = os.path.join(constants.DIR_SOURCE_ROOT, 'build', 'android', |
114 'incremental_install', 'installer.py') | 122 'incremental_install', 'installer.py') |
115 pformat = pprint.pformat | 123 pformat = pprint.pformat |
116 template_args = { | 124 template_args = { |
117 'cmd_path': pformat(relativize(installer_path)), | 125 'cmd_path': pformat(relativize(installer_path)), |
118 'apk_path': pformat(relativize(options.apk_path)), | 126 'apk_path': pformat(relativize(options.apk_path)), |
119 'output_directory': pformat(relativize(options.output_directory)), | 127 'output_directory': pformat(relativize(options.output_directory)), |
120 'lib_dir': pformat(relativize(options.lib_dir)), | 128 'lib_dir': pformat(relativize(options.lib_dir)), |
121 'dex_files': pformat([relativize(p) for p in options.dex_files]), | 129 'dex_files': pformat([relativize(p) for p in options.dex_files]), |
| 130 'show_proguard_warning': pformat(options.show_proguard_warning), |
122 'splits': pformat([relativize(p) for p in options.splits]), | 131 'splits': pformat([relativize(p) for p in options.splits]), |
123 } | 132 } |
124 | 133 |
125 with open(options.script_output_path, 'w') as script: | 134 with open(options.script_output_path, 'w') as script: |
126 script.write(SCRIPT_TEMPLATE.format(**template_args)) | 135 script.write(SCRIPT_TEMPLATE.format(**template_args)) |
127 | 136 |
128 os.chmod(options.script_output_path, 0750) | 137 os.chmod(options.script_output_path, 0750) |
129 | 138 |
130 if options.depfile: | 139 if options.depfile: |
131 build_utils.WriteDepfile( | 140 build_utils.WriteDepfile( |
132 options.depfile, | 141 options.depfile, |
133 build_utils.GetPythonDependencies()) | 142 build_utils.GetPythonDependencies()) |
134 | 143 |
135 | 144 |
136 if __name__ == '__main__': | 145 if __name__ == '__main__': |
137 sys.exit(main(sys.argv[1:])) | 146 sys.exit(main(sys.argv[1:])) |
OLD | NEW |