mirror of
https://github.com/open-goal/jak-project
synced 2026-08-02 00:34:13 -04:00
decomp: automatically format the outputs for jak 1 if future updates occur
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "common/util/FileUtil.h"
|
||||
#include "common/util/Timer.h"
|
||||
#include "common/util/string_util.h"
|
||||
#include <common/formatter/formatter.h>
|
||||
|
||||
#include "decompiler/IR2/Form.h"
|
||||
#include "decompiler/analysis/analyze_inspect_method.h"
|
||||
@@ -872,9 +873,22 @@ void ObjectFileDB::ir2_write_results(const fs::path& output_dir,
|
||||
auto file_name = output_dir / (obj.to_unique_name() + "_ir2.asm");
|
||||
file_util::write_text_file(file_name, file_text);
|
||||
|
||||
auto final = ir2_final_out(obj, imports, {});
|
||||
auto unformatted_code = ir2_final_out(obj, imports, {});
|
||||
auto final_name = output_dir / (obj.to_unique_name() + "_disasm.gc");
|
||||
file_util::write_text_file(final_name, final);
|
||||
if (config.format_code) {
|
||||
const auto formatted_code = formatter::format_code(unformatted_code);
|
||||
if (!formatted_code) {
|
||||
lg::error(
|
||||
"Was unable to format the decompiled result of {}, make a github issue. Writing "
|
||||
"unformatted code",
|
||||
obj.to_unique_name());
|
||||
file_util::write_text_file(final_name, unformatted_code);
|
||||
} else {
|
||||
file_util::write_text_file(final_name, formatted_code.value());
|
||||
}
|
||||
} else {
|
||||
file_util::write_text_file(final_name, unformatted_code);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -96,6 +96,9 @@ Config make_config_via_json(nlohmann::json& json) {
|
||||
}
|
||||
config.disassemble_code = json.at("disassemble_code").get<bool>();
|
||||
config.decompile_code = json.at("decompile_code").get<bool>();
|
||||
if (json.contains("format_code")) {
|
||||
config.format_code = json.at("format_code").get<bool>();
|
||||
}
|
||||
config.write_hex_near_instructions = json.at("write_hex_near_instructions").get<bool>();
|
||||
config.write_scripts = json.at("write_scripts").get<bool>();
|
||||
config.disassemble_data = json.at("disassemble_data").get<bool>();
|
||||
|
||||
@@ -111,6 +111,7 @@ struct Config {
|
||||
|
||||
bool disassemble_code = false;
|
||||
bool decompile_code = false;
|
||||
bool format_code = false;
|
||||
bool write_scripts = false;
|
||||
bool disassemble_data = false;
|
||||
bool process_tpages = false;
|
||||
|
||||
@@ -23,6 +23,10 @@
|
||||
// run the first pass of the decompiler
|
||||
"find_functions": true,
|
||||
|
||||
// will attempt to run the decompiled output through the OpenGOAL formatter
|
||||
// this will be skipped in offline tests
|
||||
"format_code": true,
|
||||
|
||||
////////////////////////////
|
||||
// DATA ANALYSIS OPTIONS
|
||||
////////////////////////////
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
*
|
||||
!.gitignore
|
||||
!hash.md5
|
||||
@@ -12,7 +12,8 @@
|
||||
std::unordered_map<std::string, std::string> game_name_to_all_types = {
|
||||
{"jak1", "jak1/all-types.gc"},
|
||||
{"jak2", "jak2/all-types.gc"},
|
||||
{"jak3", "jak3/all-types.gc"}};
|
||||
{"jak3", "jak3/all-types.gc"},
|
||||
{"jakx", "jakx/all-types.gc"}};
|
||||
|
||||
void disassemble(OfflineTestDecompiler& dc) {
|
||||
dc.db->process_link_data(*dc.config);
|
||||
|
||||
@@ -38,6 +38,9 @@ OfflineTestDecompiler setup_decompiler(const OfflineTestWorkGroup& work,
|
||||
object_files.insert(file.name_in_dgo); // todo, make this work with unique_name
|
||||
}
|
||||
|
||||
// skip formatting, adds unnecessary time to the process and the formatter has not been optimized
|
||||
// yet
|
||||
dc.config->format_code = false;
|
||||
dc.config->allowed_objects = object_files;
|
||||
// don't try to do this because we can't write the file
|
||||
dc.config->generate_symbol_definition_map = false;
|
||||
|
||||
Reference in New Issue
Block a user