mirror of
https://github.com/SpeedBreakerProject/speedbreaker.git
synced 2026-10-18 07:01:21 +02:00
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
36 lines
1.6 KiB
Python
36 lines
1.6 KiB
Python
"""Write runtime/kernel/import_stubs.cpp: a logging stub for every kernel/XAM
|
|
import the recompiled code references that the runtime doesn't implement yet.
|
|
|
|
python3 scripts/gen_import_stubs.py
|
|
|
|
Import names come from ppc/ppc_recomp_shared.h (XenonRecomp output). An import
|
|
counts as implemented if any other runtime source defines it with PPC_FUNC,
|
|
GUEST_FUNCTION_HOOK or GUEST_FUNCTION_STUB.
|
|
"""
|
|
import pathlib
|
|
import re
|
|
|
|
ROOT = pathlib.Path(__file__).resolve().parent.parent
|
|
OUT = ROOT / 'runtime/kernel/import_stubs.cpp'
|
|
|
|
imports = sorted(set(re.findall(r'PPC_EXTERN_FUNC\(__imp__(\w+)\)', (ROOT / 'ppc/ppc_recomp_shared.h').read_text())))
|
|
implemented = set()
|
|
for src in (ROOT / 'runtime').rglob('*.cpp'):
|
|
if src == OUT:
|
|
continue
|
|
implemented |= set(re.findall(r'(?:PPC_FUNC|GUEST_FUNCTION_HOOK|GUEST_FUNCTION_STUB)\(\s*__imp__(\w+)', src.read_text()))
|
|
|
|
missing = [n for n in imports if n not in implemented]
|
|
lines = [
|
|
'// Generated by scripts/gen_import_stubs.py. Do not edit; implement the import',
|
|
'// elsewhere in runtime/ and rerun the script.',
|
|
'// SpeedBreaker runtime. GPL-3.0-or-later (see COPYING).',
|
|
f'// {len(imports)} imports: {len(implemented & set(imports))} implemented, {len(missing)} stubbed.',
|
|
'#include "../stdafx.h"',
|
|
'#include "unimplemented.h"',
|
|
'',
|
|
]
|
|
lines += [f'PPC_FUNC(__imp__{n}) {{ UnimplementedImport("{n}", ctx, base); }}' for n in missing]
|
|
OUT.write_text('\n'.join(lines) + '\n')
|
|
print(f'{OUT.relative_to(ROOT)}: {len(imports)} imports, {len(implemented & set(imports))} implemented, {len(missing)} stubbed')
|