blob: d214cf518343833ba41cbfaefd5b1514d5997220 [file] [log] [blame]
Mads Ager418d1ca2017-05-22 09:35:49 +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
6import gradle
7import os
8import subprocess
9import sys
10import utils
11
12D8_JAR = os.path.join(utils.REPO_ROOT, 'build', 'libs', 'd8.jar')
13
14def 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 Kenez5b1c5852017-07-21 13:38:33 +020027 utils.PrintCmd(cmd)
Mads Ager418d1ca2017-05-22 09:35:49 +020028 subprocess.check_call(cmd)
29
30def 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
40if __name__ == '__main__':
41 sys.exit(main())