MCPcopy Create free account
hub / github.com/N64Recomp/N64Recomp / main

Function main

RecompModTool/main.cpp:1128–1248  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1126}
1127
1128int main(int argc, const char** argv) {
1129 if (argc != 3) {
1130 fmt::print("Usage: {} [mod toml] [output folder]\n", argv[0]);
1131 return EXIT_SUCCESS;
1132 }
1133
1134 bool config_good;
1135 std::filesystem::path output_dir{ argv[2] };
1136
1137 if (!std::filesystem::exists(output_dir)) {
1138 fmt::print(stderr, "Specified output folder does not exist!\n");
1139 return EXIT_FAILURE;
1140 }
1141
1142 if (!std::filesystem::is_directory(output_dir)) {
1143 fmt::print(stderr, "Specified output folder is not a folder!\n");
1144 return EXIT_FAILURE;
1145 }
1146
1147 ModConfig config = parse_mod_config(argv[1], config_good);
1148
1149 if (!config_good) {
1150 fmt::print(stderr, "Failed to read mod config file: {}\n", argv[1]);
1151 return EXIT_FAILURE;
1152 }
1153
1154 N64Recomp::Context context{};
1155
1156 // Import symbols from symbols files that were provided.
1157 {
1158 // Create a new temporary context to read the function reference symbol file into, since it's the same format as the recompilation symbol file.
1159 std::vector<uint8_t> dummy_rom{};
1160 N64Recomp::Context reference_context{};
1161 if (!N64Recomp::Context::from_symbol_file(config.inputs.func_reference_syms_file_path, std::move(dummy_rom), reference_context, false)) {
1162 fmt::print(stderr, "Failed to load provided function reference symbol file\n");
1163 return EXIT_FAILURE;
1164 }
1165
1166 // Use the reference context to build a reference symbol list for the actual context.
1167 if (!context.import_reference_context(reference_context)) {
1168 fmt::print(stderr, "Internal error: failed to import reference context. Please report this issue.\n");
1169 return EXIT_FAILURE;
1170 }
1171 }
1172
1173 for (const std::filesystem::path& cur_data_sym_path : config.inputs.data_reference_syms_file_paths) {
1174 if (!context.read_data_reference_syms(cur_data_sym_path)) {
1175 fmt::print(stderr, "Failed to load provided data reference symbol file: {}\n", cur_data_sym_path.string());
1176 return EXIT_FAILURE;
1177 }
1178 }
1179
1180 // Copy the dependencies and optional dependencies from the config into the context.
1181 context.add_dependencies(config.manifest.dependencies);
1182 context.add_dependencies(config.manifest.optional_dependencies);
1183
1184 N64Recomp::ElfParsingConfig elf_config {
1185 .bss_section_suffix = {},

Callers

nothing calls this directly

Calls 7

parse_mod_configFunction · 0.85
build_mod_contextFunction · 0.85
write_manifestFunction · 0.85
create_mod_zipFunction · 0.85
add_dependenciesMethod · 0.80

Tested by

no test coverage detected