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

Function parse_mod_config_inputs

RecompModTool/main.cpp:377–429  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

375}
376
377ModInputs parse_mod_config_inputs(const std::filesystem::path& basedir, const toml::table& inputs_table) {
378 ModInputs ret;
379
380 // Elf file
381 std::optional<std::string> elf_path_opt = inputs_table["elf_path"].value<std::string>();
382 if (elf_path_opt.has_value()) {
383 ret.elf_path = concat_if_not_empty(basedir, elf_path_opt.value());
384 }
385 else {
386 throw toml::parse_error("Mod toml input section is missing elf file", inputs_table.source());
387 }
388
389 // Output NRM file
390 std::optional<std::string> mod_filename_opt = inputs_table["mod_filename"].value<std::string>();
391 if (mod_filename_opt.has_value()) {
392 ret.mod_filename = std::move(mod_filename_opt.value());
393 }
394 else {
395 throw toml::parse_error("Mod toml input section is missing the output mod filename", inputs_table.source());
396 }
397
398 // Function reference symbols file
399 std::optional<std::string> func_reference_syms_file_opt = inputs_table["func_reference_syms_file"].value<std::string>();
400 if (func_reference_syms_file_opt.has_value()) {
401 ret.func_reference_syms_file_path = concat_if_not_empty(basedir, func_reference_syms_file_opt.value());
402 }
403 else {
404 throw toml::parse_error("Mod toml input section is missing function reference symbol file", inputs_table.source());
405 }
406
407 // Data reference symbols files
408 toml::node_view data_reference_syms_file_data = inputs_table["data_reference_syms_files"];
409 if (data_reference_syms_file_data.is_array()) {
410 const toml::array& array = *data_reference_syms_file_data.as_array();
411 ret.data_reference_syms_file_paths = get_toml_path_array(array, basedir);
412 }
413 else {
414 if (data_reference_syms_file_data) {
415 throw toml::parse_error("Mod toml input section is missing data reference symbol file list", inputs_table.source());
416 }
417 else {
418 throw toml::parse_error("Invalid data reference symbol file list", data_reference_syms_file_data.node()->source());
419 }
420 }
421
422 // Additional files (optional)
423 const toml::array& additional_files_array = read_toml_array(inputs_table, "additional_files", false);
424 if (!additional_files_array.empty()) {
425 ret.additional_files = get_toml_path_array(additional_files_array, basedir);
426 }
427
428 return ret;
429}
430
431ModConfig parse_mod_config(const std::filesystem::path& config_path, bool& good) {
432 ModConfig ret{};

Callers 1

parse_mod_configFunction · 0.85

Calls 2

get_toml_path_arrayFunction · 0.85
concat_if_not_emptyFunction · 0.70

Tested by

no test coverage detected