blob: 3eecf83ce747d124f6550cfd49d896d6994b40fc [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
Rico Wind8777aec2017-09-26 11:57:44 +020012def run(args, build=True, debug=True, profile=False,
Rico Windcb666c02017-08-28 14:36:38 +020013 track_memory_file=None):
Mads Ager418d1ca2017-05-22 09:35:49 +020014 if build:
15 gradle.RunGradle(['D8'])
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 Windb4621c12017-08-28 12:48:53 +020024 cmd.extend(['-jar', utils.D8_JAR])
Mads Ager418d1ca2017-05-22 09:35:49 +020025 cmd.extend(args)
Tamas Kenez5b1c5852017-07-21 13:38:33 +020026 utils.PrintCmd(cmd)
Rico Windcb666c02017-08-28 14:36:38 +020027 result = subprocess.check_output(cmd)
28 print(result)
29 return result
Mads Ager418d1ca2017-05-22 09:35:49 +020030
31def 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
41if __name__ == '__main__':
42 sys.exit(main())