blob: 58397d8551f828facccd1c68dfcacbd050a4f75b [file] [log] [blame]
Ian Zernydcb172e2022-02-22 15:36:45 +01001#!/usr/bin/env python3
Søren Gjesse71a6c522018-02-21 09:21:00 +01002# 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
Ian Zerny3f54e222019-02-12 10:51:17 +01007import jdk
Søren Gjesse71a6c522018-02-21 09:21:00 +01008import os
9import subprocess
10import sys
11import utils
12
Søren Gjesse2b98d662024-11-01 13:14:31 +010013ASM_VERSION = '9.7.1'
Rico Windb65d75c2023-10-10 11:14:52 +020014ASM_JAR = os.path.join(utils.DEPENDENCIES_DIR, 'org', 'ow2', 'asm', 'asm',
15 ASM_VERSION, 'asm-' + ASM_VERSION + '.jar')
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020016ASM_UTIL_JAR = os.path.join(utils.DEPENDENCIES_DIR, 'org', 'ow2', 'asm',
17 'asm-util', ASM_VERSION,
18 'asm-util-' + ASM_VERSION + '.jar')
19
Søren Gjesse1b685792020-04-02 13:06:11 +000020
Rico Windb65d75c2023-10-10 11:14:52 +020021def run(args):
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020022 cmd = []
23 cmd.append(jdk.GetJavaExecutable())
24 cp = ":".join([ASM_JAR, ASM_UTIL_JAR])
25 print(cp)
26 cmd.extend(['-cp', cp])
27 cmd.append('org.objectweb.asm.util.ASMifier')
28 cmd.extend(args)
29 utils.PrintCmd(cmd)
30 result = subprocess.check_output(cmd).decode('utf-8')
31 print(result)
32 return result
33
Søren Gjesse71a6c522018-02-21 09:21:00 +010034
35def main():
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020036 help = True
37 args = []
38 for arg in sys.argv[1:]:
39 if arg == "--no-debug":
40 args.append("-debug")
41 elif arg in ("-help", "--help", "-debug"):
42 help = True
43 break
44 else:
45 help = False
46 args.append(arg)
47 if help:
48 print("asmifier.py [--no-debug] <classfile>*")
49 print(
50 " --no-debug Don't include local variable information in output."
51 )
52 return
53 try:
54 run(args)
55 except subprocess.CalledProcessError as e:
56 # In case anything relevant was printed to stdout, normally this is already
57 # on stderr.
58 print(e.output)
59 return e.returncode
60
Søren Gjesse71a6c522018-02-21 09:21:00 +010061
62if __name__ == '__main__':
Christoffer Quist Adamsen2434a4d2023-10-16 11:29:03 +020063 sys.exit(main())