Tamas Kenez | 19a3b8a | 2017-05-29 23:08:48 +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 | import gradle |
| 7 | import os |
| 8 | import subprocess |
| 9 | import sys |
| 10 | import utils |
| 11 | |
Tamas Kenez | 19a3b8a | 2017-05-29 23:08:48 +0200 | [diff] [blame] | 12 | def run(args, build = True, debug = True, profile = False, track_memory_file=None): |
| 13 | if build: |
| 14 | gradle.RunGradle(['CompatDX']) |
| 15 | cmd = [] |
| 16 | if track_memory_file: |
| 17 | cmd.extend(['tools/track_memory.sh', track_memory_file]) |
| 18 | cmd.append('java') |
| 19 | if debug: |
| 20 | cmd.append('-ea') |
| 21 | if profile: |
| 22 | cmd.append('-agentlib:hprof=cpu=samples,interval=1,depth=8') |
Tamas Kenez | 0cad51c | 2017-08-21 14:42:01 +0200 | [diff] [blame] | 23 | cmd.extend(['-jar', utils.COMPATDX_JAR]) |
Tamas Kenez | 19a3b8a | 2017-05-29 23:08:48 +0200 | [diff] [blame] | 24 | cmd.extend(args) |
| 25 | subprocess.check_call(cmd) |
| 26 | |
| 27 | def main(): |
| 28 | build = True |
| 29 | args = [] |
| 30 | for arg in sys.argv[1:]: |
| 31 | if arg in ("--build", "--no-build"): |
| 32 | build = arg == "--build" |
| 33 | else: |
| 34 | args.append(arg) |
| 35 | run(args, build) |
| 36 | |
| 37 | if __name__ == '__main__': |
| 38 | sys.exit(main()) |