feat: now we generate header file for stub functions

This commit is contained in:
Ran-j
2025-11-29 12:26:39 -03:00
parent cd2e7f4ea8
commit 4ea08199b0
5 changed files with 44 additions and 19 deletions
+37
View File
@@ -119,6 +119,7 @@ namespace ps2recomp
combinedOutput << "#include \"ps2_recompiled_functions.h\"\n\n";
combinedOutput << "#include \"ps2_runtime_macros.h\"\n";
combinedOutput << "#include \"ps2_runtime.h\"\n";
combinedOutput << "#include \"ps2_recompiled_stubs.h\"\n";
for (const auto &function : m_functions)
{
@@ -199,6 +200,8 @@ namespace ps2recomp
fs::path registerPath = fs::path(m_config.outputPath) / "register_functions.cpp";
writeToFile(registerPath.string(), registerFunctions);
std::cout << "Generated function registration file: " << registerPath << std::endl;
generateStubHeader();
}
catch (const std::exception &e)
{
@@ -206,6 +209,40 @@ namespace ps2recomp
}
}
bool PS2Recompiler::generateStubHeader()
{
try
{
std::stringstream ss;
ss << "#pragma once\n\n";
ss << "#include <cstdint>\n";
ss << "#include \"ps2_runtime.h\"\n";
ss << "#include \"ps2_syscalls.h\"\n\n";
ss << "namespace ps2recomp {\n";
ss << "namespace stubs {\n\n";
for (const auto &funcName : m_config.stubImplementations)
{
ss << "void " << funcName << "(uint8_t* rdram, R5900Context* ctx, PS2Runtime* runtime) { ps2_syscalls::TODO(rdram, ctx, runtime); }\n";
}
ss << "\n} // namespace stubs\n";
ss << "} // namespace ps2recomp\n";
fs::path headerPath = fs::path(m_config.outputPath) / "ps2_recompiled_stubs.h";
writeToFile(headerPath.string(), ss.str());
std::cout << "Generated generating header file: " << headerPath << std::endl;
return true;
}
catch (const std::exception &e)
{
std::cerr << "Error generating stub header: " << e.what() << std::endl;
return false;
}
}
bool PS2Recompiler::generateFunctionHeader()
{
try