• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
6import gradle
7import os
8import subprocess
9import sys
10import utils
11
12R8_JAR = os.path.join(utils.REPO_ROOT, 'build', 'libs', 'r8.jar')
13
14def run(args, build = True, debug = True, profile = False, track_memory_file=None):
15  if build:
16    gradle.RunGradle(['r8'])
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', R8_JAR])
26  cmd.extend(args)
27  utils.PrintCmd(cmd)
28  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())
42