diff --git a/include/recomp_port.h b/include/recomp_port.h index e70f3ae..80e50c0 100644 --- a/include/recomp_port.h +++ b/include/recomp_port.h @@ -85,6 +85,7 @@ namespace RecompPort { std::vector manual_func_sizes; std::vector manual_functions; std::string bss_section_suffix; + std::string recomp_include; Config(const char* path); bool good() { return !bad; } diff --git a/src/config.cpp b/src/config.cpp index 7126e55..8933d26 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -408,6 +408,14 @@ RecompPort::Config::Config(const char* path) { unpaired_lo16_warnings = true; } + std::optional recomp_include_opt = input_data["recomp_include"].value(); + if (recomp_include_opt.has_value()) { + recomp_include = recomp_include_opt.value(); + } + else { + recomp_include = "#include \"librecomp/recomp.h\""; + } + // Patches section (optional) toml::node_view patches_data = config_data["patches"]; if (patches_data.is_table()) { diff --git a/src/main.cpp b/src/main.cpp index d95ad65..615ae88 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1683,12 +1683,13 @@ int main(int argc, char** argv) { std::ofstream func_header_file{ config.output_func_path / "funcs.h" }; fmt::print(func_header_file, - "#include \"librecomp/recomp.h\"\n" + "{}\n" "\n" "#ifdef __cplusplus\n" "extern \"C\" {{\n" "#endif\n" - "\n" + "\n", + config.recomp_include ); std::vector> 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")); // Write the file header fmt::print(single_output_file, - "#include \"librecomp/recomp.h\"\n" + "{}\n" "#include \"funcs.h\"\n" - "\n"); + "\n", + config.recomp_include); } //#pragma omp parallel for @@ -1902,8 +1904,9 @@ int main(int argc, char** argv) { std::ofstream lookup_file{ config.output_func_path / "lookup.cpp" }; fmt::print(lookup_file, - "#include \"librecomp/recomp.h\"\n" - "\n" + "{}\n" + "\n", + config.recomp_include ); fmt::print(lookup_file, @@ -1928,10 +1931,11 @@ int main(int argc, char** argv) { std::string section_load_table = "static SectionTableEntry section_table[] = {\n"; fmt::print(overlay_file, - "#include \"librecomp/recomp.h\"\n" + "{}\n" "#include \"funcs.h\"\n" "#include \"librecomp/sections.h\"\n" - "\n" + "\n", + config.recomp_include ); std::unordered_map relocatable_section_indices{}; diff --git a/src/recompilation.cpp b/src/recompilation.cpp index 26efb2c..07c679b 100644 --- a/src/recompilation.cpp +++ b/src/recompilation.cpp @@ -58,7 +58,7 @@ JalResolutionResult resolve_jal(const RecompPort::Context& context, size_t cur_s 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]; if (!target_func_section.relocatable) { matched_funcs.push_back(target_func_index); @@ -1204,8 +1204,9 @@ bool RecompPort::recompile_function(const RecompPort::Context& context, const Re if (write_header) { // Write the file header fmt::print(output_file, - "#include \"librecomp/recomp.h\"\n" - "\n"); + "{}\n" + "\n", + config.recomp_include); } fmt::print(output_file,