Ian Zerny | dcb172e | 2022-02-22 15:36:45 +0100 | [diff] [blame] | 1 | #!/usr/bin/env python3 |
Søren Gjesse | 71a6c52 | 2018-02-21 09:21:00 +0100 | [diff] [blame] | 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 | |
| 6 | import gradle |
Ian Zerny | 3f54e22 | 2019-02-12 10:51:17 +0100 | [diff] [blame] | 7 | import jdk |
Søren Gjesse | 71a6c52 | 2018-02-21 09:21:00 +0100 | [diff] [blame] | 8 | import os |
| 9 | import subprocess |
| 10 | import sys |
| 11 | import utils |
| 12 | |
Søren Gjesse | 2b98d66 | 2024-11-01 13:14:31 +0100 | [diff] [blame] | 13 | ASM_VERSION = '9.7.1' |
Rico Wind | b65d75c | 2023-10-10 11:14:52 +0200 | [diff] [blame] | 14 | ASM_JAR = os.path.join(utils.DEPENDENCIES_DIR, 'org', 'ow2', 'asm', 'asm', |
| 15 | ASM_VERSION, 'asm-' + ASM_VERSION + '.jar') |
Christoffer Quist Adamsen | 2434a4d | 2023-10-16 11:29:03 +0200 | [diff] [blame] | 16 | ASM_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 Gjesse | 1b68579 | 2020-04-02 13:06:11 +0000 | [diff] [blame] | 20 | |
Rico Wind | b65d75c | 2023-10-10 11:14:52 +0200 | [diff] [blame] | 21 | def run(args): |
Christoffer Quist Adamsen | 2434a4d | 2023-10-16 11:29:03 +0200 | [diff] [blame] | 22 | 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 Gjesse | 71a6c52 | 2018-02-21 09:21:00 +0100 | [diff] [blame] | 34 | |
| 35 | def main(): |
Christoffer Quist Adamsen | 2434a4d | 2023-10-16 11:29:03 +0200 | [diff] [blame] | 36 | 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 Gjesse | 71a6c52 | 2018-02-21 09:21:00 +0100 | [diff] [blame] | 61 | |
| 62 | if __name__ == '__main__': |
Christoffer Quist Adamsen | 2434a4d | 2023-10-16 11:29:03 +0200 | [diff] [blame] | 63 | sys.exit(main()) |