| 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 dex_files = {dex_files} |
| 41 dont_even_try = {dont_even_try} |
| 40 native_libs = {native_libs} | 42 native_libs = {native_libs} |
| 41 dex_files = {dex_files} | 43 show_proguard_warning = {show_proguard_warning} |
| 42 splits = {splits} | 44 splits = {splits} |
| 43 show_proguard_warning = {show_proguard_warning} | |
| 44 | 45 |
| 45 return dict(apk_path=_ResolvePath(apk_path), | 46 return dict(apk_path=_ResolvePath(apk_path), |
| 46 dex_files=[_ResolvePath(p) for p in dex_files], | 47 dex_files=[_ResolvePath(p) for p in dex_files], |
| 48 dont_even_try=dont_even_try, |
| 47 native_libs=[_ResolvePath(p) for p in native_libs], | 49 native_libs=[_ResolvePath(p) for p in native_libs], |
| 48 show_proguard_warning=show_proguard_warning, | 50 show_proguard_warning=show_proguard_warning, |
| 49 splits=[_ResolvePath(p) for p in splits]) | 51 splits=[_ResolvePath(p) for p in splits]) |
| 50 | 52 |
| 51 | 53 |
| 52 def main(): | 54 def main(): |
| 53 output_directory = {output_directory} | 55 output_directory = {output_directory} |
| 54 cmd_path = {cmd_path} | 56 cmd_path = {cmd_path} |
| 55 params = GetInstallParameters() | 57 params = GetInstallParameters() |
| 56 cmd_args = [ | 58 cmd_args = [ |
| 57 _ResolvePath(cmd_path), | 59 _ResolvePath(cmd_path), |
| 58 '--output-directory', _ResolvePath(output_directory), | 60 '--output-directory', _ResolvePath(output_directory), |
| 59 ] | 61 ] |
| 60 for native_lib in params['native_libs']: | 62 for native_lib in params['native_libs']: |
| 61 cmd_args.extend(('--native_lib', native_lib)) | 63 cmd_args.extend(('--native_lib', native_lib)) |
| 62 for dex_path in params['dex_files']: | 64 for dex_path in params['dex_files']: |
| 63 cmd_args.extend(('--dex-file', dex_path)) | 65 cmd_args.extend(('--dex-file', dex_path)) |
| 64 for split in params['splits']: | 66 for split in params['splits']: |
| 65 cmd_args.extend(('--split', split)) | 67 cmd_args.extend(('--split', split)) |
| 66 cmd_args.append(params['apk_path']) | 68 cmd_args.append(params['apk_path']) |
| 69 if params['dont_even_try']: |
| 70 cmd_args.extend(('--dont-even-try', params['dont_even_try'])) |
| 67 if params['show_proguard_warning']: | 71 if params['show_proguard_warning']: |
| 68 cmd_args.append('--show-proguard-warning') | 72 cmd_args.append('--show-proguard-warning') |
| 69 return subprocess.call(cmd_args + sys.argv[1:]) | 73 return subprocess.call(cmd_args + sys.argv[1:]) |
| 70 | 74 |
| 71 if __name__ == '__main__': | 75 if __name__ == '__main__': |
| 72 sys.exit(main()) | 76 sys.exit(main()) |
| 73 """ | 77 """ |
| 74 | 78 |
| 75 | 79 |
| 76 def _ParseArgs(args): | 80 def _ParseArgs(args): |
| (...skipping 24 matching lines...) Expand all Loading... |
| 101 action='append', | 105 action='append', |
| 102 default=[], | 106 default=[], |
| 103 dest='dex_files', | 107 dest='dex_files', |
| 104 help='List of dex files to include.') | 108 help='List of dex files to include.') |
| 105 parser.add_argument('--dex-file-list', | 109 parser.add_argument('--dex-file-list', |
| 106 help='GYP-list of dex files.') | 110 help='GYP-list of dex files.') |
| 107 parser.add_argument('--show-proguard-warning', | 111 parser.add_argument('--show-proguard-warning', |
| 108 action='store_true', | 112 action='store_true', |
| 109 default=False, | 113 default=False, |
| 110 help='Print a warning about proguard being disabled') | 114 help='Print a warning about proguard being disabled') |
| 115 parser.add_argument('--dont-even-try', |
| 116 help='Prints this message and exits.') |
| 111 | 117 |
| 112 options = parser.parse_args(args) | 118 options = parser.parse_args(args) |
| 113 options.dex_files += build_utils.ParseGypList(options.dex_file_list) | 119 options.dex_files += build_utils.ParseGypList(options.dex_file_list) |
| 114 all_libs = [] | 120 all_libs = [] |
| 115 for gyp_list in options.native_libs: | 121 for gyp_list in options.native_libs: |
| 116 all_libs.extend(build_utils.ParseGypList(gyp_list)) | 122 all_libs.extend(build_utils.ParseGypList(gyp_list)) |
| 117 options.native_libs = all_libs | 123 options.native_libs = all_libs |
| 118 return options | 124 return options |
| 119 | 125 |
| 120 | 126 |
| 121 def main(args): | 127 def main(args): |
| 122 options = _ParseArgs(args) | 128 options = _ParseArgs(args) |
| 123 | 129 |
| 124 def relativize(path): | 130 def relativize(path): |
| 125 script_dir = os.path.dirname(options.script_output_path) | 131 script_dir = os.path.dirname(options.script_output_path) |
| 126 return path and os.path.relpath(path, script_dir) | 132 return path and os.path.relpath(path, script_dir) |
| 127 | 133 |
| 128 installer_path = os.path.join(host_paths.DIR_SOURCE_ROOT, 'build', 'android', | 134 installer_path = os.path.join(host_paths.DIR_SOURCE_ROOT, 'build', 'android', |
| 129 'incremental_install', 'installer.py') | 135 'incremental_install', 'installer.py') |
| 130 pformat = pprint.pformat | 136 pformat = pprint.pformat |
| 131 template_args = { | 137 template_args = { |
| 132 'cmd_path': pformat(relativize(installer_path)), | 138 'cmd_path': pformat(relativize(installer_path)), |
| 133 'apk_path': pformat(relativize(options.apk_path)), | 139 'apk_path': pformat(relativize(options.apk_path)), |
| 134 'output_directory': pformat(relativize(options.output_directory)), | 140 'output_directory': pformat(relativize(options.output_directory)), |
| 135 'native_libs': pformat([relativize(p) for p in options.native_libs]), | 141 'native_libs': pformat([relativize(p) for p in options.native_libs]), |
| 136 'dex_files': pformat([relativize(p) for p in options.dex_files]), | 142 'dex_files': pformat([relativize(p) for p in options.dex_files]), |
| 143 'dont_even_try': pformat(options.dont_even_try), |
| 137 'show_proguard_warning': pformat(options.show_proguard_warning), | 144 'show_proguard_warning': pformat(options.show_proguard_warning), |
| 138 'splits': pformat([relativize(p) for p in options.splits]), | 145 'splits': pformat([relativize(p) for p in options.splits]), |
| 139 } | 146 } |
| 140 | 147 |
| 141 with open(options.script_output_path, 'w') as script: | 148 with open(options.script_output_path, 'w') as script: |
| 142 script.write(SCRIPT_TEMPLATE.format(**template_args)) | 149 script.write(SCRIPT_TEMPLATE.format(**template_args)) |
| 143 | 150 |
| 144 os.chmod(options.script_output_path, 0750) | 151 os.chmod(options.script_output_path, 0750) |
| 145 | 152 |
| 146 if options.depfile: | 153 if options.depfile: |
| 147 build_utils.WriteDepfile( | 154 build_utils.WriteDepfile( |
| 148 options.depfile, | 155 options.depfile, |
| 149 build_utils.GetPythonDependencies()) | 156 build_utils.GetPythonDependencies()) |
| 150 | 157 |
| 151 | 158 |
| 152 if __name__ == '__main__': | 159 if __name__ == '__main__': |
| 153 sys.exit(main(sys.argv[1:])) | 160 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |