Tamas Kenez | 0cad51c | 2017-08-21 14:42:01 +0200 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright (c) 2017, 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 | # Test prebuilt AOSP jar files: compile with D8 and run dex2out to validate |
| 7 | |
| 8 | from __future__ import print_function |
| 9 | from glob import glob |
| 10 | from itertools import chain |
| 11 | from os.path import join |
| 12 | import argparse |
| 13 | import os |
| 14 | import subprocess |
| 15 | import sys |
| 16 | |
| 17 | import gradle |
| 18 | |
| 19 | import utils |
| 20 | |
| 21 | REPLAY_SCRIPT_DIR = join(utils.REPO_ROOT, 'third_party', |
| 22 | 'android_cts_baseline', 'dx_replay') |
| 23 | REPLAY_SCRIPT = join(REPLAY_SCRIPT_DIR, 'replay_script.py') |
| 24 | OUT_DIR = join(REPLAY_SCRIPT_DIR, 'out') |
| 25 | |
| 26 | def parse_arguments(): |
| 27 | parser = argparse.ArgumentParser( |
| 28 | description = 'Run D8 (CompatDX) and dex2oat on prebuilt AOSP jars.') |
| 29 | parser.add_argument('--no-build', default = False, action = 'store_true') |
| 30 | return parser.parse_args() |
| 31 | |
| 32 | def Main(): |
Tamas Kenez | 0cad51c | 2017-08-21 14:42:01 +0200 | [diff] [blame] | 33 | args = parse_arguments() |
| 34 | |
| 35 | if not args.no_build: |
| 36 | gradle.RunGradle(['CompatDx']) |
| 37 | |
| 38 | cmd = [REPLAY_SCRIPT, 'java', '-jar', utils.COMPATDX_JAR] |
| 39 | utils.PrintCmd(cmd) |
| 40 | subprocess.check_call(cmd) |
| 41 | |
| 42 | # collect dex files below OUT_DIR |
| 43 | dex_files = (chain.from_iterable(glob(join(x[0], '*.dex')) |
| 44 | for x in os.walk(OUT_DIR))) |
| 45 | |
| 46 | for dex_file in dex_files: |
| 47 | utils.verify_with_dex2oat(dex_file) |
| 48 | |
| 49 | |
| 50 | if __name__ == '__main__': |
| 51 | sys.exit(Main()) |