mirror of
https://github.com/open-goal/jak-project
synced 2026-08-21 14:54:53 -04:00
[decompiler] Clean up config more (#458)
* remove global config * fix dir
This commit is contained in:
+21
-20
@@ -25,20 +25,20 @@ int main(int argc, char** argv) {
|
||||
}
|
||||
|
||||
// collect all files to process
|
||||
set_config(argv[1]);
|
||||
auto config = read_config_file(argv[1]);
|
||||
std::string in_folder = argv[2];
|
||||
std::string out_folder = argv[3];
|
||||
|
||||
std::vector<std::string> dgos, objs, strs;
|
||||
for (const auto& dgo_name : get_config().dgo_names) {
|
||||
for (const auto& dgo_name : config.dgo_names) {
|
||||
dgos.push_back(file_util::combine_path(in_folder, dgo_name));
|
||||
}
|
||||
|
||||
for (const auto& obj_name : get_config().object_file_names) {
|
||||
for (const auto& obj_name : config.object_file_names) {
|
||||
objs.push_back(file_util::combine_path(in_folder, obj_name));
|
||||
}
|
||||
|
||||
for (const auto& str_name : get_config().str_file_names) {
|
||||
for (const auto& str_name : config.str_file_names) {
|
||||
strs.push_back(file_util::combine_path(in_folder, str_name));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ int main(int argc, char** argv) {
|
||||
|
||||
// build file database
|
||||
lg::info("Setting up object file DB...");
|
||||
ObjectFileDB db(dgos, get_config().obj_file_name_map_file, objs, strs);
|
||||
ObjectFileDB db(dgos, config.obj_file_name_map_file, objs, strs, config);
|
||||
|
||||
// write out DGO file info
|
||||
file_util::write_text_file(file_util::combine_path(out_folder, "dgo.txt"),
|
||||
@@ -56,57 +56,58 @@ int main(int argc, char** argv) {
|
||||
db.generate_obj_listing());
|
||||
|
||||
// dump raw objs
|
||||
if (get_config().dump_objs) {
|
||||
if (config.dump_objs) {
|
||||
auto path = file_util::combine_path(out_folder, "raw_obj");
|
||||
file_util::create_dir_if_needed(path);
|
||||
db.dump_raw_objects(path);
|
||||
}
|
||||
|
||||
// process files (required for all analysis)
|
||||
db.process_link_data();
|
||||
db.find_code();
|
||||
db.process_link_data(config);
|
||||
db.find_code(config);
|
||||
db.process_labels();
|
||||
|
||||
// print disassembly
|
||||
if (get_config().disassemble_code || get_config().disassemble_data) {
|
||||
db.write_disassembly(out_folder, get_config().disassemble_data, get_config().disassemble_code);
|
||||
if (config.disassemble_code || config.disassemble_data) {
|
||||
db.write_disassembly(out_folder, config.disassemble_data, config.disassemble_code,
|
||||
config.write_hex_near_instructions);
|
||||
}
|
||||
|
||||
// regenerate all-types if needed
|
||||
if (get_config().regenerate_all_types) {
|
||||
db.analyze_functions_ir1();
|
||||
if (config.regenerate_all_types) {
|
||||
db.analyze_functions_ir1(config);
|
||||
file_util::write_text_file(file_util::combine_path(out_folder, "type_defs.gc"),
|
||||
db.all_type_defs);
|
||||
}
|
||||
|
||||
// main decompile.
|
||||
if (get_config().decompile_code) {
|
||||
db.analyze_functions_ir2(out_folder);
|
||||
if (config.decompile_code) {
|
||||
db.analyze_functions_ir2(out_folder, config);
|
||||
}
|
||||
|
||||
// write out all symbols TODO - organize by file
|
||||
file_util::write_text_file(file_util::combine_path(out_folder, "all-syms.gc"),
|
||||
db.dts.dump_symbol_types());
|
||||
|
||||
if (get_config().hexdump_code || get_config().hexdump_data) {
|
||||
db.write_object_file_words(out_folder, get_config().hexdump_data, get_config().hexdump_code);
|
||||
if (config.hexdump_code || config.hexdump_data) {
|
||||
db.write_object_file_words(out_folder, config.hexdump_data, config.hexdump_code);
|
||||
}
|
||||
|
||||
// data stuff
|
||||
if (get_config().write_scripts) {
|
||||
if (config.write_scripts) {
|
||||
db.find_and_write_scripts(out_folder);
|
||||
}
|
||||
|
||||
if (get_config().process_game_text) {
|
||||
if (config.process_game_text) {
|
||||
auto result = db.process_game_text_files();
|
||||
file_util::write_text_file(file_util::get_file_path({"assets", "game_text.txt"}), result);
|
||||
}
|
||||
|
||||
if (get_config().process_tpages) {
|
||||
if (config.process_tpages) {
|
||||
db.process_tpages();
|
||||
}
|
||||
|
||||
if (get_config().process_game_count) {
|
||||
if (config.process_game_count) {
|
||||
auto result = db.process_game_count_file();
|
||||
file_util::write_text_file(file_util::get_file_path({"assets", "game_count.txt"}), result);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user