blob: f3aa392173c70c6a4b1d648120878cbc68535ccd [file] [log] [blame]
Tamas Kenez0cad51c2017-08-21 14:42:01 +02001#!/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
8from __future__ import print_function
9from glob import glob
10from itertools import chain
11from os.path import join
12import argparse
13import os
14import subprocess
15import sys
16
17import gradle
18
19import utils
20
21REPLAY_SCRIPT_DIR = join(utils.REPO_ROOT, 'third_party',
22 'android_cts_baseline', 'dx_replay')
23REPLAY_SCRIPT = join(REPLAY_SCRIPT_DIR, 'replay_script.py')
24OUT_DIR = join(REPLAY_SCRIPT_DIR, 'out')
25
26def 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
32def Main():
Tamas Kenez0cad51c2017-08-21 14:42:01 +020033 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
50if __name__ == '__main__':
51 sys.exit(Main())