mirror of
https://github.com/Mr-Wiseguy/N64Recomp.git
synced 2024-12-28 02:16:09 +00:00
Made recompilation header include configurable
This commit is contained in:
parent
dfd90057c9
commit
4161ef68cc
|
@ -85,6 +85,7 @@ namespace RecompPort {
|
||||||
std::vector<FunctionSize> manual_func_sizes;
|
std::vector<FunctionSize> manual_func_sizes;
|
||||||
std::vector<ManualFunction> manual_functions;
|
std::vector<ManualFunction> manual_functions;
|
||||||
std::string bss_section_suffix;
|
std::string bss_section_suffix;
|
||||||
|
std::string recomp_include;
|
||||||
|
|
||||||
Config(const char* path);
|
Config(const char* path);
|
||||||
bool good() { return !bad; }
|
bool good() { return !bad; }
|
||||||
|
|
|
@ -408,6 +408,14 @@ RecompPort::Config::Config(const char* path) {
|
||||||
unpaired_lo16_warnings = true;
|
unpaired_lo16_warnings = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::optional<std::string> recomp_include_opt = input_data["recomp_include"].value<std::string>();
|
||||||
|
if (recomp_include_opt.has_value()) {
|
||||||
|
recomp_include = recomp_include_opt.value();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
recomp_include = "#include \"librecomp/recomp.h\"";
|
||||||
|
}
|
||||||
|
|
||||||
// Patches section (optional)
|
// Patches section (optional)
|
||||||
toml::node_view patches_data = config_data["patches"];
|
toml::node_view patches_data = config_data["patches"];
|
||||||
if (patches_data.is_table()) {
|
if (patches_data.is_table()) {
|
||||||
|
|
20
src/main.cpp
20
src/main.cpp
|
@ -1683,12 +1683,13 @@ int main(int argc, char** argv) {
|
||||||
std::ofstream func_header_file{ config.output_func_path / "funcs.h" };
|
std::ofstream func_header_file{ config.output_func_path / "funcs.h" };
|
||||||
|
|
||||||
fmt::print(func_header_file,
|
fmt::print(func_header_file,
|
||||||
"#include \"librecomp/recomp.h\"\n"
|
"{}\n"
|
||||||
"\n"
|
"\n"
|
||||||
"#ifdef __cplusplus\n"
|
"#ifdef __cplusplus\n"
|
||||||
"extern \"C\" {{\n"
|
"extern \"C\" {{\n"
|
||||||
"#endif\n"
|
"#endif\n"
|
||||||
"\n"
|
"\n",
|
||||||
|
config.recomp_include
|
||||||
);
|
);
|
||||||
|
|
||||||
std::vector<std::vector<uint32_t>> static_funcs_by_section{ context.sections.size() };
|
std::vector<std::vector<uint32_t>> static_funcs_by_section{ context.sections.size() };
|
||||||
|
@ -1785,9 +1786,10 @@ int main(int argc, char** argv) {
|
||||||
single_output_file.open(config.output_func_path / config.elf_path.stem().replace_extension(".c"));
|
single_output_file.open(config.output_func_path / config.elf_path.stem().replace_extension(".c"));
|
||||||
// Write the file header
|
// Write the file header
|
||||||
fmt::print(single_output_file,
|
fmt::print(single_output_file,
|
||||||
"#include \"librecomp/recomp.h\"\n"
|
"{}\n"
|
||||||
"#include \"funcs.h\"\n"
|
"#include \"funcs.h\"\n"
|
||||||
"\n");
|
"\n",
|
||||||
|
config.recomp_include);
|
||||||
}
|
}
|
||||||
|
|
||||||
//#pragma omp parallel for
|
//#pragma omp parallel for
|
||||||
|
@ -1902,8 +1904,9 @@ int main(int argc, char** argv) {
|
||||||
std::ofstream lookup_file{ config.output_func_path / "lookup.cpp" };
|
std::ofstream lookup_file{ config.output_func_path / "lookup.cpp" };
|
||||||
|
|
||||||
fmt::print(lookup_file,
|
fmt::print(lookup_file,
|
||||||
"#include \"librecomp/recomp.h\"\n"
|
"{}\n"
|
||||||
"\n"
|
"\n",
|
||||||
|
config.recomp_include
|
||||||
);
|
);
|
||||||
|
|
||||||
fmt::print(lookup_file,
|
fmt::print(lookup_file,
|
||||||
|
@ -1928,10 +1931,11 @@ int main(int argc, char** argv) {
|
||||||
std::string section_load_table = "static SectionTableEntry section_table[] = {\n";
|
std::string section_load_table = "static SectionTableEntry section_table[] = {\n";
|
||||||
|
|
||||||
fmt::print(overlay_file,
|
fmt::print(overlay_file,
|
||||||
"#include \"librecomp/recomp.h\"\n"
|
"{}\n"
|
||||||
"#include \"funcs.h\"\n"
|
"#include \"funcs.h\"\n"
|
||||||
"#include \"librecomp/sections.h\"\n"
|
"#include \"librecomp/sections.h\"\n"
|
||||||
"\n"
|
"\n",
|
||||||
|
config.recomp_include
|
||||||
);
|
);
|
||||||
|
|
||||||
std::unordered_map<std::string, size_t> relocatable_section_indices{};
|
std::unordered_map<std::string, size_t> relocatable_section_indices{};
|
||||||
|
|
|
@ -58,7 +58,7 @@ JalResolutionResult resolve_jal(const RecompPort::Context& context, size_t cur_s
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the function's section isn't non-relocatable, add it as a candidate.
|
// If the function's section isn't relocatable, add the function as a candidate.
|
||||||
const auto& target_func_section = context.sections[target_func.section_index];
|
const auto& target_func_section = context.sections[target_func.section_index];
|
||||||
if (!target_func_section.relocatable) {
|
if (!target_func_section.relocatable) {
|
||||||
matched_funcs.push_back(target_func_index);
|
matched_funcs.push_back(target_func_index);
|
||||||
|
@ -1204,8 +1204,9 @@ bool RecompPort::recompile_function(const RecompPort::Context& context, const Re
|
||||||
if (write_header) {
|
if (write_header) {
|
||||||
// Write the file header
|
// Write the file header
|
||||||
fmt::print(output_file,
|
fmt::print(output_file,
|
||||||
"#include \"librecomp/recomp.h\"\n"
|
"{}\n"
|
||||||
"\n");
|
"\n",
|
||||||
|
config.recomp_include);
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::print(output_file,
|
fmt::print(output_file,
|
||||||
|
|
Loading…
Reference in a new issue