mirror of
https://github.com/pret/pmd-sky.git
synced 2026-03-21 17:25:15 -05:00
Use argparse for extract_function
This commit is contained in:
parent
d802fe866c
commit
36dbdd8862
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from write_inc_file import write_inc_file
|
||||
|
||||
|
|
@ -8,18 +8,21 @@ from write_inc_file import write_inc_file
|
|||
# This is intended for use after decompiling a function, so that you can place the decompiled C code in the placeholder after running the script.
|
||||
# Since this script updates files, it's recommended to have no uncommitted changes when running this script, in case something goes wrong and needs a revert.
|
||||
# Example usage (auto-generated file name): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)"
|
||||
# Example usage (custom file name): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" my_new_file
|
||||
# Example usage (custom file name): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" -f my_new_file
|
||||
# Example usage (nonmatching): python extract_function.py overlay_29_0234EC38 "u8 ov29_0234FCA8(u8 arg0)" -n
|
||||
|
||||
if len(sys.argv) < 3 or len(sys.argv) > 5:
|
||||
print('Usage: python extract_function.py <asm_file> <function_header> <extract_file_name> <nonmatching>')
|
||||
exit(1)
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
_, function_location, function_header = sys.argv[0:3]
|
||||
extract_file_name = None
|
||||
if len(sys.argv) >= 4 and len(sys.argv[3]) > 0:
|
||||
extract_file_name = sys.argv[3]
|
||||
parser.add_argument('asm_file')
|
||||
parser.add_argument('function_header')
|
||||
parser.add_argument('-f', '--extract_file_name')
|
||||
parser.add_argument('-n', '--nonmatching', action='store_true')
|
||||
|
||||
nonmatching = len(sys.argv) >= 5 and sys.argv[4] == 'nonmatching'
|
||||
args = parser.parse_args()
|
||||
function_location = args.asm_file
|
||||
function_header = args.function_header
|
||||
extract_file_name = args.extract_file_name
|
||||
nonmatching = args.nonmatching
|
||||
|
||||
if function_location.endswith('.s'):
|
||||
function_location = function_location[:-2]
|
||||
|
|
|
|||
|
|
@ -1,18 +1,21 @@
|
|||
import os
|
||||
import re
|
||||
import sys
|
||||
import argparse
|
||||
|
||||
from write_inc_file import write_inc_file
|
||||
|
||||
# Use this script to split a data file at a certain symbol.
|
||||
# Example usage: python split_data.py overlay_29_0234EC38 TWO_TURN_STATUSES
|
||||
|
||||
if len(sys.argv) != 3:
|
||||
print('Usage: python extract_function.py <asm_file> <split_symbol_name>')
|
||||
exit(1)
|
||||
parser = argparse.ArgumentParser()
|
||||
|
||||
_, symbol_location, symbol_name = sys.argv[0:3]
|
||||
parser.add_argument('asm_file')
|
||||
parser.add_argument('split_symbol_name')
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
symbol_location = args.asm_file
|
||||
symbol_name = args.split_symbol_name
|
||||
|
||||
if symbol_location.endswith('.s'):
|
||||
symbol_location = symbol_location[:-2]
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user