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

Method Config

src/config.cpp:288–527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

286}
287
288N64Recomp::Config::Config(const char* path) {
289 // Start this config out as bad so that it has to finish parsing without errors to be good.
290 entrypoint = 0;
291 bad = true;
292 toml::table config_data{};
293
294 try {
295 config_data = toml::parse_file(path);
296 std::filesystem::path basedir = std::filesystem::path{ path }.parent_path();
297
298 // Input section (required)
299 const auto input_data = config_data["input"];
300 const auto entrypoint_data = input_data["entrypoint"];
301
302 if (entrypoint_data) {
303 const auto entrypoint_value = entrypoint_data.value<uint32_t>();
304 if (entrypoint_value.has_value()) {
305 entrypoint = (int32_t)entrypoint_value.value();
306 has_entrypoint = true;
307 }
308 else {
309 throw toml::parse_error("Invalid entrypoint", entrypoint_data.node()->source());
310 }
311 }
312 else {
313 has_entrypoint = false;
314 }
315
316 std::optional<std::string> elf_path_opt = input_data["elf_path"].value<std::string>();
317 if (elf_path_opt.has_value()) {
318 elf_path = concat_if_not_empty(basedir, elf_path_opt.value());
319 }
320
321 std::optional<std::string> symbols_file_path_opt = input_data["symbols_file_path"].value<std::string>();
322 if (symbols_file_path_opt.has_value()) {
323 symbols_file_path = concat_if_not_empty(basedir, symbols_file_path_opt.value());
324 }
325
326 std::optional<std::string> rom_file_path_opt = input_data["rom_file_path"].value<std::string>();
327 if (rom_file_path_opt.has_value()) {
328 rom_file_path = concat_if_not_empty(basedir, rom_file_path_opt.value());
329 }
330
331 std::optional<std::string> output_func_path_opt = input_data["output_func_path"].value<std::string>();
332 if (output_func_path_opt.has_value()) {
333 output_func_path = concat_if_not_empty(basedir, output_func_path_opt.value());
334 }
335 else {
336 throw toml::parse_error("Missing output_func_path in config file", input_data.node()->source());
337 }
338
339 std::optional<std::string> relocatable_sections_path_opt = input_data["relocatable_sections_path"].value<std::string>();
340 if (relocatable_sections_path_opt.has_value()) {
341 relocatable_sections_path = concat_if_not_empty(basedir, relocatable_sections_path_opt.value());
342 }
343 else {
344 relocatable_sections_path = "";
345 }

Callers

nothing calls this directly

Calls 10

get_manual_funcsFunction · 0.85
get_func_sizesFunction · 0.85
get_mdebug_mappingsFunction · 0.85
get_stubbed_funcsFunction · 0.85
get_ignored_funcsFunction · 0.85
get_renamed_funcsFunction · 0.85
get_instruction_patchesFunction · 0.85
get_function_hooksFunction · 0.85
get_data_syms_pathsFunction · 0.85
concat_if_not_emptyFunction · 0.70

Tested by

no test coverage detected