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

Function main

src/main.cpp:294–1114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

292}
293
294int main(int argc, char** argv) {
295 auto exit_failure = [] (const std::string& error_str) {
296 fmt::vprint(stderr, error_str, fmt::make_format_args());
297 std::exit(EXIT_FAILURE);
298 };
299
300 bool dumping_context = false;
301
302 if (argc < 2) {
303 fmt::print("Usage: {} <config file> [--dump-context]\n", argv[0]);
304 return EXIT_SUCCESS;
305 }
306
307 const char* config_path = argv[1];
308
309 for (size_t i = 2; i < argc; i++) {
310 std::string_view cur_arg = argv[i];
311 if (cur_arg == "--dump-context") {
312 dumping_context = true;
313 }
314 else {
315 fmt::print("Unknown argument \"{}\"\n", cur_arg);
316 return EXIT_FAILURE;
317 }
318 }
319
320 N64Recomp::Config config{ config_path };
321 if (!config.good()) {
322 exit_failure(fmt::format("Failed to load config file: {}\n", config_path));
323 }
324
325 RabbitizerConfig_Cfg.pseudos.pseudoMove = false;
326 RabbitizerConfig_Cfg.pseudos.pseudoBeqz = false;
327 RabbitizerConfig_Cfg.pseudos.pseudoBnez = false;
328 RabbitizerConfig_Cfg.pseudos.pseudoNot = false;
329 RabbitizerConfig_Cfg.pseudos.pseudoBal = false;
330
331 std::vector<std::string> relocatable_sections_ordered{};
332
333 if (!config.relocatable_sections_path.empty()) {
334 if (!read_list_file(config.relocatable_sections_path, relocatable_sections_ordered)) {
335 exit_failure(fmt::format("Failed to load the relocatable section list file: {}\n", (const char*)config.relocatable_sections_path.u8string().c_str()));
336 }
337 }
338
339 std::unordered_set<std::string> relocatable_sections{};
340 relocatable_sections.insert(relocatable_sections_ordered.begin(), relocatable_sections_ordered.end());
341
342 std::unordered_set<std::string> ignored_syms_set{};
343 ignored_syms_set.insert(config.ignored_funcs.begin(), config.ignored_funcs.end());
344
345 N64Recomp::Context context{};
346
347 if (!config.elf_path.empty() && !config.symbols_file_path.empty()) {
348 exit_failure("Config file cannot provide both an elf and a symbols file\n");
349 }
350
351 // Build a context from the provided elf file.

Callers

nothing calls this directly

Calls 12

read_list_fileFunction · 0.85
add_manual_functionsFunction · 0.85
dump_contextFunction · 0.85
is_manual_patch_symbolFunction · 0.85
read_fileFunction · 0.70
byteswapFunction · 0.50
goodMethod · 0.45

Tested by

no test coverage detected