1
0
Fork 0
mirror of https://github.com/zeldaret/oot.git synced 2025-07-17 05:15:16 +00:00

Match retail BSS ordering (#1927)

* Match retail BSS ordering

* Revert moving some global variables to headers

* Adjust block numbers after header changes

* Fix debug build

* Overlay bss ordering

* Fix BSS ordering after header changes

* gc-eu-mq OK

* Implement preprocessor for #pragma increment_block_number

* Transfer usage comment from reencode.sh

* Use temporary directory instead of temporary file

* Move ColChkMassType back
This commit is contained in:
cadmic 2024-04-14 14:51:32 -07:00 committed by GitHub
parent a94661054e
commit f643499462
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
25 changed files with 224 additions and 165 deletions

View file

@ -222,7 +222,7 @@ def find_compiler_command_line(filename, oot_version):
for line in make_output:
parts = line.split()
if "-o" in parts and str(filename) in parts:
makefile_command_line = parts
compiler_command_line = parts
found += 1
if found != 1:
@ -231,49 +231,29 @@ def find_compiler_command_line(filename, oot_version):
)
sys.exit(1)
# Assume command line is of the form:
# tools/reencode.sh [COMPILER] [COMPILER_ARGS]
compiler_command_line = makefile_command_line[1:]
print(f'Command line: {" ".join(compiler_command_line)}', file=sys.stderr)
return compiler_command_line
def generate_symbol_table(command_line):
# Find source file in compiler arguments
source_file = None
args = []
for arg in command_line:
if arg.endswith(".c"):
source_file = Path(arg)
else:
args.append(arg)
# Assume command line is of the form:
# python3 tools/preprocess.py [COMPILER] [COMPILER_ARGS] [INPUT_FILE]
input_file = Path(command_line[-1])
rest = command_line[:-1]
if source_file is None:
raise Exception("No source file found")
source_contents = source_file.read_text()
stem = "reencode_tmp"
input_file = Path(f"{stem}.c")
stem = input_file.stem
symbol_table_file = Path(f"{stem}.T")
ucode_file = Path(f"{stem}.B")
try:
# Write temporary file with #line directive to simulate asm-processor
with open(input_file, "w") as f:
f.write('#line 1 "{}"\n'.format(source_file))
f.write(source_contents)
# Invoke compiler
# -Hf stops compilation after cfe so we can inspect the symbol table
subprocess.run(args + ["-Hf", input_file], check=True)
subprocess.run(rest + ["-Hf", input_file], check=True)
# Read symbol table
return symbol_table_file.read_bytes()
finally:
# Cleanup
input_file.unlink(missing_ok=True)
symbol_table_file.unlink(missing_ok=True)
ucode_file.unlink(missing_ok=True)