blob: 280c6f149bc3182d95ad3298323714fb0cdbf261 [file] [log] [blame]
Søren Gjesse71a6c522018-02-21 09:21:00 +01001#!/usr/bin/env python
2# Copyright (c) 2018, 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
12def run(args, build=True):
13 if build:
14 gradle.RunGradle(['copyMavenDeps'])
15 cmd = []
16 cmd.append('java')
Jinseong Jeona89fa1b2018-09-25 10:00:14 -070017 cp = ":".join([os.path.join(utils.REPO_ROOT, 'build/deps/asm-6.2.1.jar'),
18 os.path.join(utils.REPO_ROOT, 'build/deps/asm-util-6.2.1.jar')])
Søren Gjesse9dde7b22018-08-28 11:28:27 +020019 cmd.extend(['-cp', cp])
Søren Gjesse71a6c522018-02-21 09:21:00 +010020 cmd.append('org.objectweb.asm.util.ASMifier')
21 cmd.extend(args)
22 utils.PrintCmd(cmd)
23 result = subprocess.check_output(cmd)
24 print(result)
25 return result
26
27def main():
28 build = True
Tamas Kenez6b6bb9f2018-11-07 20:08:40 +010029 help = True
Søren Gjesse71a6c522018-02-21 09:21:00 +010030 args = []
31 for arg in sys.argv[1:]:
32 if arg in ("--build", "--no-build"):
33 build = arg == "--build"
Tamas Kenez6b6bb9f2018-11-07 20:08:40 +010034 elif arg == "--no-debug":
35 args.append("-debug")
36 elif arg in ("-help", "--help", "-debug"):
37 help = True
38 break
Søren Gjesse71a6c522018-02-21 09:21:00 +010039 else:
Tamas Kenez6b6bb9f2018-11-07 20:08:40 +010040 help = False
Søren Gjesse71a6c522018-02-21 09:21:00 +010041 args.append(arg)
Tamas Kenez6b6bb9f2018-11-07 20:08:40 +010042 if help:
43 print "asmifier.py [--no-build] [--no-debug] <classfile>*"
44 print " --no-build Don't run R8 dependencies."
45 print " --no-debug Don't include local variable information in output."
46 return
Søren Gjesse71a6c522018-02-21 09:21:00 +010047 try:
48 run(args, build)
49 except subprocess.CalledProcessError as e:
50 # In case anything relevant was printed to stdout, normally this is already
51 # on stderr.
52 print(e.output)
53 return e.returncode
54
55if __name__ == '__main__':
56 sys.exit(main())