From c7ee2f125881b62c77aca3be8ab50d0e9415759c Mon Sep 17 00:00:00 2001 From: Aetias Date: Thu, 4 Apr 2024 17:11:38 +0200 Subject: [PATCH] Parse long symbols in `gen_externs.py` --- tools/gen_externs.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/gen_externs.py b/tools/gen_externs.py index 27d7bef8..192e7eee 100644 --- a/tools/gen_externs.py +++ b/tools/gen_externs.py @@ -22,6 +22,8 @@ tmp_file = '_gen_externs_tmp' tmp_obj_file = f'{tmp_file}.o' tmp_asm_file = f'{tmp_file}.s' +MSG_UNKNOWN_IDENTIFIER = 'Unknown identifier,' + if platform.system() == 'Windows': as_cmd = [str(as_path)] else: as_cmd = ['wine', str(as_path)] @@ -46,7 +48,19 @@ def get_unknown_symbols(file: Path): output = e.stdout.decode() # Get unknown identifiers - symbols: list[str] = re.findall(r'Unknown identifier, (?:[\r\n]+\S+ )?(\S+)', output) + lines = output.splitlines() + symbol = '' + symbols: list[str] = [] + for line in lines: + if not line.startswith(tmp_asm_file): continue + if ':' not in line: continue + line = line[line.index(':', len(tmp_asm_file) + 1) + 1:].strip() + if line.startswith(MSG_UNKNOWN_IDENTIFIER): + if symbol != '': symbols.append(symbol) + symbol = line[len(MSG_UNKNOWN_IDENTIFIER):].strip() + else: + symbol += line.strip() + if symbol != '': symbols.append(symbol) if len(symbols) == 0: return []