blob: 79a584a9ee63b4df3dbacc32ea13fea005d992a2 [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():
33
34 utils.check_java_version()
35 args = parse_arguments()
36
37 if not args.no_build:
38 gradle.RunGradle(['CompatDx'])
39
40 cmd = [REPLAY_SCRIPT, 'java', '-jar', utils.COMPATDX_JAR]
41 utils.PrintCmd(cmd)
42 subprocess.check_call(cmd)
43
44 # collect dex files below OUT_DIR
45 dex_files = (chain.from_iterable(glob(join(x[0], '*.dex'))
46 for x in os.walk(OUT_DIR)))
47
48 for dex_file in dex_files:
49 utils.verify_with_dex2oat(dex_file)
50
51
52if __name__ == '__main__':
53 sys.exit(Main())
54