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 | |
| 12 | D8_JAR = os.path.join(utils.REPO_ROOT, 'build', 'libs', 'd8.jar') |
| 13 | |
| 14 | def run(args, build = True, debug = True, profile = False, track_memory_file=None): |
| 15 | if build: |
| 16 | gradle.RunGradle(['D8']) |
| 17 | cmd = [] |
| 18 | if track_memory_file: |
| 19 | cmd.extend(['tools/track_memory.sh', track_memory_file]) |
| 20 | cmd.append('java') |
| 21 | if debug: |
| 22 | cmd.append('-ea') |
| 23 | if profile: |
| 24 | cmd.append('-agentlib:hprof=cpu=samples,interval=1,depth=8') |
| 25 | cmd.extend(['-jar', D8_JAR]) |
| 26 | cmd.extend(args) |
Tamas Kenez | 5b1c585 | 2017-07-21 13:38:33 +0200 | [diff] [blame^] | 27 | utils.PrintCmd(cmd) |
Mads Ager | 418d1ca | 2017-05-22 09:35:49 +0200 | [diff] [blame] | 28 | subprocess.check_call(cmd) |
| 29 | |
| 30 | def main(): |
| 31 | build = True |
| 32 | args = [] |
| 33 | for arg in sys.argv[1:]: |
| 34 | if arg in ("--build", "--no-build"): |
| 35 | build = arg == "--build" |
| 36 | else: |
| 37 | args.append(arg) |
| 38 | run(args, build) |
| 39 | |
| 40 | if __name__ == '__main__': |
| 41 | sys.exit(main()) |