Ian Zerny | dcb172e | 2022-02-22 15:36:45 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 2 | # Copyright (c) 2018, the R8 project authors. Please see the AUTHORS file |
| 3 | # for details. All rights reserved. Use of this source code is governed by a |
| 4 | # BSD-style license that can be found in the LICENSE file. |
| 5 | |
| 6 | # Script for building sample apks using the sdk tools directly. |
| 7 | |
| 8 | import apk_utils |
| 9 | import fnmatch |
| 10 | import glob |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 11 | import jdk |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 12 | import optparse |
| 13 | import os |
| 14 | import shutil |
| 15 | import subprocess |
| 16 | import sys |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 17 | import time |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 18 | import utils |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 19 | import uuid |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 20 | |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 21 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 22 | DEFAULT_AAPT = 'aapt' # Assume in path. |
Rico Wind | 33a57cc | 2020-05-05 09:06:09 +0200 | [diff] [blame] | 23 | DEFAULT_AAPT2 = 'aapt2' # Assume in path. |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 24 | DEFAULT_D8 = os.path.join(utils.REPO_ROOT, 'tools', 'd8.py') |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 25 | DEFAULT_DEXSPLITTER = os.path.join(utils.REPO_ROOT, 'tools', 'dexsplitter.py') |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 26 | DEFAULT_JAVAC = jdk.GetJavacExecutable() |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 27 | SRC_LOCATION = 'src/com/android/tools/r8/sample/{app}/*.java' |
| 28 | DEFAULT_KEYSTORE = os.path.join(os.getenv('HOME'), '.android', 'debug.keystore') |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 29 | PACKAGE_PREFIX = 'com.android.tools.r8.sample' |
| 30 | STANDARD_ACTIVITY = "R8Activity" |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 31 | BENCHMARK_ITERATIONS = 30 |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 32 | |
| 33 | SAMPLE_APKS = [ |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 34 | 'simple', |
| 35 | 'split' |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 36 | ] |
| 37 | |
| 38 | def parse_options(): |
| 39 | result = optparse.OptionParser() |
| 40 | result.add_option('--aapt', |
| 41 | help='aapt executable to use', |
| 42 | default=DEFAULT_AAPT) |
Rico Wind | 33a57cc | 2020-05-05 09:06:09 +0200 | [diff] [blame] | 43 | result.add_option('--aapt2', |
| 44 | help='aapt2 executable to use', |
| 45 | default=DEFAULT_AAPT2) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 46 | result.add_option('--api', |
| 47 | help='Android api level', |
| 48 | default=21, |
Rico Wind | fecaf02 | 2020-01-28 12:28:31 +0100 | [diff] [blame] | 49 | choices=['14', '15', '19', '21', '22', '23', '24', '25', |
| 50 | '26']) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 51 | result.add_option('--keystore', |
| 52 | help='Keystore used for signing', |
| 53 | default=DEFAULT_KEYSTORE) |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 54 | result.add_option('--split', |
| 55 | help='Split the app using the split.spec file', |
| 56 | default=False, action='store_true') |
Rico Wind | 33a57cc | 2020-05-05 09:06:09 +0200 | [diff] [blame] | 57 | result.add_option('--generate-proto-apk', |
| 58 | help='Use aapt2 to generate the proto version of the apk.', |
| 59 | default=False, action='store_true') |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 60 | result.add_option('--install', |
| 61 | help='Install the app (including featuresplit)', |
| 62 | default=False, action='store_true') |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 63 | result.add_option('--benchmark', |
| 64 | help='Benchmark the app on the phone with specialized markers', |
| 65 | default=False, action='store_true') |
| 66 | result.add_option('--benchmark-output-dir', |
| 67 | help='Store benchmark results here.', |
| 68 | default=None) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 69 | result.add_option('--app', |
| 70 | help='Which app to build', |
| 71 | default='simple', |
| 72 | choices=SAMPLE_APKS) |
| 73 | return result.parse_args() |
| 74 | |
| 75 | def run_aapt(aapt, args): |
| 76 | command = [aapt] |
| 77 | command.extend(args) |
| 78 | utils.PrintCmd(command) |
| 79 | subprocess.check_call(command) |
| 80 | |
| 81 | def get_build_dir(app): |
| 82 | return os.path.join(utils.BUILD, 'sampleApks', app) |
| 83 | |
| 84 | def get_gen_path(app): |
| 85 | gen_path = os.path.join(get_build_dir(app), 'gen') |
| 86 | utils.makedirs_if_needed(gen_path) |
| 87 | return gen_path |
| 88 | |
| 89 | def get_bin_path(app): |
| 90 | bin_path = os.path.join(get_build_dir(app), 'bin') |
| 91 | utils.makedirs_if_needed(bin_path) |
| 92 | return bin_path |
| 93 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 94 | |
Rico Wind | f395863 | 2018-08-07 09:39:19 +0200 | [diff] [blame] | 95 | def get_guava_jar(): |
| 96 | return os.path.join(utils.REPO_ROOT, |
| 97 | 'third_party/gradle-plugin/com/google/guava/guava/22.0/guava-22.0.jar') |
| 98 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 99 | def get_sample_dir(app): |
| 100 | return os.path.join(utils.REPO_ROOT, 'src', 'test', 'sampleApks', app) |
| 101 | |
| 102 | def get_src_path(app): |
| 103 | return os.path.join(get_sample_dir(app), 'src') |
| 104 | |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 105 | def get_dex_path(app): |
| 106 | return os.path.join(get_bin_path(app), 'classes.dex') |
| 107 | |
| 108 | def get_split_path(app, split): |
| 109 | return os.path.join(get_bin_path(app), split, 'classes.dex') |
| 110 | |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 111 | def get_package_name(app): |
| 112 | return '%s.%s' % (PACKAGE_PREFIX, app) |
| 113 | |
| 114 | def get_qualified_activity(app): |
| 115 | # The activity specified to adb start is PACKAGE_NAME/.ACTIVITY |
| 116 | return '%s/.%s' % (get_package_name(app), STANDARD_ACTIVITY) |
| 117 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 118 | def run_aapt_pack(aapt, api, app): |
| 119 | with utils.ChangedWorkingDirectory(get_sample_dir(app)): |
| 120 | args = ['package', |
| 121 | '-v', '-f', |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 122 | '-I', utils.get_android_jar(api), |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 123 | '-M', 'AndroidManifest.xml', |
| 124 | '-A', 'assets', |
| 125 | '-S', 'res', |
| 126 | '-m', |
| 127 | '-J', get_gen_path(app), |
Søren Gjesse | 12c5209 | 2018-04-05 14:22:29 +0200 | [diff] [blame] | 128 | '-F', os.path.join(get_bin_path(app), 'resources.ap_'), |
| 129 | '-G', os.path.join(get_build_dir(app), 'proguard_options')] |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 130 | run_aapt(aapt, args) |
| 131 | |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 132 | def run_aapt_split_pack(aapt, api, app): |
| 133 | with utils.ChangedWorkingDirectory(get_sample_dir(app)): |
| 134 | args = ['package', |
| 135 | '-v', '-f', |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 136 | '-I', utils.get_android_jar(api), |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 137 | '-M', 'split_manifest/AndroidManifest.xml', |
| 138 | '-S', 'res', |
| 139 | '-F', os.path.join(get_bin_path(app), 'split_resources.ap_')] |
| 140 | run_aapt(aapt, args) |
| 141 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 142 | def compile_with_javac(api, app): |
| 143 | with utils.ChangedWorkingDirectory(get_sample_dir(app)): |
| 144 | files = glob.glob(SRC_LOCATION.format(app=app)) |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 145 | classpath = '%s:%s' % (utils.get_android_jar(api), get_guava_jar()) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 146 | command = [DEFAULT_JAVAC, |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 147 | '-classpath', classpath, |
Rico Wind | f395863 | 2018-08-07 09:39:19 +0200 | [diff] [blame] | 148 | '-sourcepath', '%s:%s:%s' % ( |
| 149 | get_src_path(app), |
| 150 | get_gen_path(app), |
| 151 | get_guava_jar()), |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 152 | '-d', get_bin_path(app)] |
| 153 | command.extend(files) |
| 154 | utils.PrintCmd(command) |
| 155 | subprocess.check_call(command) |
| 156 | |
| 157 | def dex(app, api): |
| 158 | files = [] |
| 159 | for root, dirnames, filenames in os.walk(get_bin_path(app)): |
| 160 | for filename in fnmatch.filter(filenames, '*.class'): |
| 161 | files.append(os.path.join(root, filename)) |
Rico Wind | c270474 | 2021-12-16 13:29:55 +0100 | [diff] [blame] | 162 | command = [DEFAULT_D8, '--', |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 163 | '--output', get_bin_path(app), |
Rico Wind | 9d70f61 | 2018-08-31 09:17:43 +0200 | [diff] [blame] | 164 | '--classpath', utils.get_android_jar(api), |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 165 | '--min-api', str(api)] |
| 166 | command.extend(files) |
Rico Wind | fecaf02 | 2020-01-28 12:28:31 +0100 | [diff] [blame] | 167 | if app != 'simple': |
| 168 | command.append(get_guava_jar()) |
Rico Wind | f395863 | 2018-08-07 09:39:19 +0200 | [diff] [blame] | 169 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 170 | utils.PrintCmd(command) |
| 171 | subprocess.check_call(command) |
| 172 | |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 173 | def split(app): |
| 174 | split_spec = os.path.join(get_sample_dir(app), 'split.spec') |
| 175 | command = [DEFAULT_DEXSPLITTER, |
| 176 | '--input', get_dex_path(app), |
| 177 | '--output', get_bin_path(app), |
| 178 | '--feature-splits', split_spec] |
| 179 | utils.PrintCmd(command) |
| 180 | subprocess.check_call(command) |
| 181 | |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 182 | def run_adb(args, ignore_exit=False): |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 183 | command = ['adb'] |
| 184 | command.extend(args) |
| 185 | utils.PrintCmd(command) |
Rico Wind | e01a505 | 2018-07-06 07:28:32 +0200 | [diff] [blame] | 186 | # On M adb install-multiple exits 1 but succeed in installing. |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 187 | if ignore_exit: |
| 188 | subprocess.call(command) |
| 189 | else: |
| 190 | subprocess.check_call(command) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 191 | |
| 192 | def adb_install(apks): |
| 193 | args = [ |
| 194 | 'install-multiple' if len(apks) > 1 else 'install', |
| 195 | '-r', |
| 196 | '-d'] |
| 197 | args.extend(apks) |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 198 | run_adb(args, ignore_exit=True) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 199 | |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 200 | def create_temp_apk(app, prefix): |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 201 | temp_apk_path = os.path.join(get_bin_path(app), '%s.ap_' % app) |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 202 | shutil.copyfile(os.path.join(get_bin_path(app), '%sresources.ap_' % prefix), |
| 203 | temp_apk_path) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 204 | return temp_apk_path |
| 205 | |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 206 | def aapt_add_dex(aapt, dex, temp_apk_path): |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 207 | args = ['add', |
| 208 | '-k', temp_apk_path, |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 209 | dex] |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 210 | run_aapt(aapt, args) |
| 211 | |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 212 | def kill(app): |
| 213 | args = ['shell', 'am', 'force-stop', get_package_name(app)] |
| 214 | run_adb(args) |
| 215 | |
| 216 | def start_logcat(): |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 217 | return subprocess.Popen(['adb', 'logcat'], bufsize=1024*1024, stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 218 | |
| 219 | def start(app): |
| 220 | args = ['shell', 'am', 'start', '-n', get_qualified_activity(app)] |
| 221 | run_adb(args) |
| 222 | |
| 223 | def clear_logcat(): |
| 224 | args = ['logcat', '-c'] |
| 225 | run_adb(args) |
| 226 | |
| 227 | def stop_logcat(popen): |
| 228 | popen.terminate() |
| 229 | lines = [] |
| 230 | for l in popen.stdout: |
| 231 | if 'System.out' in l: |
| 232 | lines.append(l) |
| 233 | return lines |
| 234 | |
| 235 | def store_or_print_benchmarks(lines, output): |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 236 | results = {} |
| 237 | overall_total = 0 |
| 238 | # We assume that the total times are |
| 239 | # prefixed with 'NAME Total: '. The logcat lines looks like: |
| 240 | # 06-28 12:22:00.991 13698 13698 I System.out: Call Total: 61614 |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 241 | for l in lines: |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 242 | if 'Total: ' in l: |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 243 | split = l.split('Total: ') |
| 244 | time = split[1] |
| 245 | name = split[0].split()[-1] |
| 246 | overall_total += int(time) |
| 247 | print '%s: %s' % (name, time) |
| 248 | results[name] = time |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 249 | |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 250 | print 'Total: %s' % overall_total |
| 251 | if not output: |
| 252 | return overall_total |
| 253 | results['total'] = str(overall_total) |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 254 | output_dir = os.path.join(output, str(uuid.uuid4())) |
| 255 | os.makedirs(output_dir) |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 256 | written_files = [] |
| 257 | for name, time in results.iteritems(): |
| 258 | total_file = os.path.join(output_dir, name) |
| 259 | written_files.append(total_file) |
| 260 | with open(total_file, 'w') as f: |
| 261 | f.write(time) |
| 262 | |
| 263 | print 'Result stored in: \n%s' % ('\n'.join(written_files)) |
| 264 | return overall_total |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 265 | |
| 266 | def benchmark(app, output_dir): |
| 267 | # Ensure app is not running |
| 268 | kill(app) |
| 269 | clear_logcat() |
| 270 | logcat = start_logcat() |
| 271 | start(app) |
| 272 | # We could do better here by continiously parsing the logcat for a marker, but |
| 273 | # this works nicely with the current setup. |
Rico Wind | f395863 | 2018-08-07 09:39:19 +0200 | [diff] [blame] | 274 | time.sleep(12) |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 275 | kill(app) |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 276 | return float(store_or_print_benchmarks(stop_logcat(logcat), output_dir)) |
| 277 | |
| 278 | def ensure_no_logcat(): |
| 279 | output = subprocess.check_output(['ps', 'aux']) |
| 280 | if 'adb logcat' in output: |
| 281 | raise Exception('You have adb logcat running, please close it and rerun') |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 282 | |
Rico Wind | 33a57cc | 2020-05-05 09:06:09 +0200 | [diff] [blame] | 283 | def generate_proto_apks(apks, options): |
| 284 | proto_apks = [] |
| 285 | for apk in apks: |
| 286 | proto_apk = apk + '.proto' |
| 287 | cmd = [options.aapt2, 'convert', |
| 288 | '-o', proto_apk, |
| 289 | '--output-format', 'proto', |
| 290 | apk] |
| 291 | utils.PrintCmd(cmd) |
| 292 | subprocess.check_call(cmd) |
| 293 | proto_apks.append(proto_apk) |
| 294 | return proto_apks |
| 295 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 296 | def Main(): |
| 297 | (options, args) = parse_options() |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 298 | apks = [] |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 299 | is_split = options.split |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 300 | run_aapt_pack(options.aapt, options.api, options.app) |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 301 | if is_split: |
| 302 | run_aapt_split_pack(options.aapt, options.api, options.app) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 303 | compile_with_javac(options.api, options.app) |
| 304 | dex(options.app, options.api) |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 305 | dex_files = { options.app: get_dex_path(options.app)} |
| 306 | dex_path = get_dex_path(options.app) |
| 307 | if is_split: |
| 308 | split(options.app) |
| 309 | dex_path = get_split_path(options.app, 'base') |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 310 | temp_apk_path = create_temp_apk(options.app, '') |
| 311 | aapt_add_dex(options.aapt, dex_path, temp_apk_path) |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 312 | apk_path = os.path.join(get_bin_path(options.app), '%s.apk' % options.app) |
| 313 | apk_utils.sign(temp_apk_path, apk_path, options.keystore) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 314 | apks.append(apk_path) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 315 | if is_split: |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 316 | split_temp_apk_path = create_temp_apk(options.app, 'split_') |
| 317 | aapt_add_dex(options.aapt, |
| 318 | get_split_path(options.app, 'split'), |
| 319 | temp_apk_path) |
| 320 | split_apk_path = os.path.join(get_bin_path(options.app), 'featuresplit.apk') |
| 321 | apk_utils.sign(temp_apk_path, split_apk_path, options.keystore) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 322 | apks.append(split_apk_path) |
Rico Wind | 33a57cc | 2020-05-05 09:06:09 +0200 | [diff] [blame] | 323 | if options.generate_proto_apk: |
| 324 | proto_apks = generate_proto_apks(apks, options) |
| 325 | print('Generated proto apks available at: %s' % ' '.join(proto_apks)) |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 326 | print('Generated apks available at: %s' % ' '.join(apks)) |
Rico Wind | e01a505 | 2018-07-06 07:28:32 +0200 | [diff] [blame] | 327 | if options.install or options.benchmark: |
Rico Wind | d0cd1a5 | 2018-06-27 15:26:22 +0200 | [diff] [blame] | 328 | adb_install(apks) |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 329 | grand_total = 0 |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 330 | if options.benchmark: |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 331 | ensure_no_logcat() |
Rico Wind | b1e257e | 2018-06-28 14:17:09 +0200 | [diff] [blame] | 332 | for _ in range(BENCHMARK_ITERATIONS): |
Rico Wind | 097e3eb | 2018-07-05 15:14:10 +0200 | [diff] [blame] | 333 | grand_total += benchmark(options.app, options.benchmark_output_dir) |
| 334 | print 'Combined average: %s' % (grand_total/BENCHMARK_ITERATIONS) |
Rico Wind | a5db71d8 | 2018-06-27 13:45:05 +0200 | [diff] [blame] | 335 | |
Rico Wind | 0ed24cc | 2018-03-23 07:16:35 +0100 | [diff] [blame] | 336 | if __name__ == '__main__': |
| 337 | sys.exit(Main()) |