mirror of
https://github.com/N64Recomp/N64Recomp.git
synced 2026-04-30 14:02:14 +00:00
Move file header writing outside of function recompilation
This commit is contained in:
parent
ad0e38dde7
commit
008b1177fa
4 changed files with 12 additions and 14 deletions
|
|
@ -156,7 +156,7 @@ int main(int argc, const char** argv) {
|
||||||
output_file << "RECOMP_EXPORT int32_t* section_addresses = NULL;\n";
|
output_file << "RECOMP_EXPORT int32_t* section_addresses = NULL;\n";
|
||||||
|
|
||||||
for (const auto& func : mod_context.functions) {
|
for (const auto& func : mod_context.functions) {
|
||||||
N64Recomp::recompile_function(mod_context, func, "", output_file, static_funcs_by_section, false);
|
N64Recomp::recompile_function(mod_context, func, output_file, static_funcs_by_section);
|
||||||
}
|
}
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
|
|
|
||||||
|
|
@ -469,7 +469,7 @@ namespace N64Recomp {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool recompile_function(const Context& context, const Function& func, const std::string& recomp_include, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs, bool write_header);
|
bool recompile_function(const Context& context, const Function& func, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs);
|
||||||
|
|
||||||
enum class ModSymbolsError {
|
enum class ModSymbolsError {
|
||||||
Good,
|
Good,
|
||||||
|
|
|
||||||
12
src/main.cpp
12
src/main.cpp
|
|
@ -121,7 +121,13 @@ bool recompile_single_function(const N64Recomp::Context& context, const N64Recom
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!N64Recomp::recompile_function(context, func, recomp_include, output_file, static_funcs_out, true)) {
|
// Write the file header
|
||||||
|
fmt::print(output_file,
|
||||||
|
"{}\n"
|
||||||
|
"\n",
|
||||||
|
recomp_include);
|
||||||
|
|
||||||
|
if (!N64Recomp::recompile_function(context, func, output_file, static_funcs_out)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -611,7 +617,7 @@ int main(int argc, char** argv) {
|
||||||
|
|
||||||
// Recompile the function.
|
// Recompile the function.
|
||||||
if (config.single_file_output || config.functions_per_output_file > 1) {
|
if (config.single_file_output || config.functions_per_output_file > 1) {
|
||||||
result = N64Recomp::recompile_function(context, func, config.recomp_include, current_output_file, static_funcs_by_section, false);
|
result = N64Recomp::recompile_function(context, func, current_output_file, static_funcs_by_section);
|
||||||
if (!config.single_file_output) {
|
if (!config.single_file_output) {
|
||||||
cur_file_function_count++;
|
cur_file_function_count++;
|
||||||
if (cur_file_function_count >= config.functions_per_output_file) {
|
if (cur_file_function_count >= config.functions_per_output_file) {
|
||||||
|
|
@ -698,7 +704,7 @@ int main(int argc, char** argv) {
|
||||||
bool result;
|
bool result;
|
||||||
size_t prev_num_statics = static_funcs_by_section[func.section_index].size();
|
size_t prev_num_statics = static_funcs_by_section[func.section_index].size();
|
||||||
if (config.single_file_output || config.functions_per_output_file > 1) {
|
if (config.single_file_output || config.functions_per_output_file > 1) {
|
||||||
result = N64Recomp::recompile_function(context, func, config.recomp_include, current_output_file, static_funcs_by_section, false);
|
result = N64Recomp::recompile_function(context, func, current_output_file, static_funcs_by_section);
|
||||||
if (!config.single_file_output) {
|
if (!config.single_file_output) {
|
||||||
cur_file_function_count++;
|
cur_file_function_count++;
|
||||||
if (cur_file_function_count >= config.functions_per_output_file) {
|
if (cur_file_function_count >= config.functions_per_output_file) {
|
||||||
|
|
|
||||||
|
|
@ -730,18 +730,10 @@ bool process_instruction(const N64Recomp::Context& context, const N64Recomp::Fun
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool N64Recomp::recompile_function(const N64Recomp::Context& context, const N64Recomp::Function& func, const std::string& recomp_include, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs_out, bool write_header) {
|
bool N64Recomp::recompile_function(const N64Recomp::Context& context, const N64Recomp::Function& func, std::ofstream& output_file, std::span<std::vector<uint32_t>> static_funcs_out) {
|
||||||
//fmt::print("Recompiling {}\n", func.name);
|
//fmt::print("Recompiling {}\n", func.name);
|
||||||
std::vector<rabbitizer::InstructionCpu> instructions;
|
std::vector<rabbitizer::InstructionCpu> instructions;
|
||||||
|
|
||||||
if (write_header) {
|
|
||||||
// Write the file header
|
|
||||||
fmt::print(output_file,
|
|
||||||
"{}\n"
|
|
||||||
"\n",
|
|
||||||
recomp_include);
|
|
||||||
}
|
|
||||||
|
|
||||||
fmt::print(output_file,
|
fmt::print(output_file,
|
||||||
"RECOMP_FUNC void {}(uint8_t* rdram, recomp_context* ctx) {{\n"
|
"RECOMP_FUNC void {}(uint8_t* rdram, recomp_context* ctx) {{\n"
|
||||||
// these variables shouldn't need to be preserved across function boundaries, so make them local for more efficient output
|
// these variables shouldn't need to be preserved across function boundaries, so make them local for more efficient output
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue