Mads Ager | 418d1ca | 2017-05-22 09:35:49 +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 | |
Rico Wind | 8777aec | 2017-09-26 11:57:44 +0200 | [diff] [blame] | 12 | def run(args, build=True, debug=True, profile=False, |
Rico Wind | cb666c0 | 2017-08-28 14:36:38 +0200 | [diff] [blame] | 13 | track_memory_file=None): |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 14 | if build: |
| 15 | gradle.RunGradle(['r8']) |
| 16 | cmd = [] |
| 17 | if track_memory_file: |
| 18 | cmd.extend(['tools/track_memory.sh', track_memory_file]) |
| 19 | cmd.append('java') |
| 20 | if debug: |
| 21 | cmd.append('-ea') |
| 22 | if profile: |
| 23 | cmd.append('-agentlib:hprof=cpu=samples,interval=1,depth=8') |
Rico Wind | b4621c1 | 2017-08-28 12:48:53 +0200 | [diff] [blame] | 24 | cmd.extend(['-jar', utils.R8_JAR]) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 25 | cmd.extend(args) |
| 26 | utils.PrintCmd(cmd) |
Rico Wind | cb666c0 | 2017-08-28 14:36:38 +0200 | [diff] [blame] | 27 | result = subprocess.check_output(cmd) |
| 28 | print(result) |
| 29 | return result |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 30 | |
| 31 | def main(): |
| 32 | build = True |
| 33 | args = [] |
| 34 | for arg in sys.argv[1:]: |
| 35 | if arg in ("--build", "--no-build"): |
| 36 | build = arg == "--build" |
| 37 | else: |
| 38 | args.append(arg) |
| 39 | run(args, build) |
| 40 | |
| 41 | if __name__ == '__main__': |
| 42 | sys.exit(main()) |