From 7fab525f42cce3a62d13efc1e2aaa6f918050cde Mon Sep 17 00:00:00 2001 From: Guus Waals <_@guusw.nl> Date: Wed, 25 Sep 2024 23:50:01 +0800 Subject: [PATCH] PCH and recursive dump --- game_re/CMakeLists.txt | 7 +++++++ game_re/r3/binders/auto_pch.cxx | 1 + scripts/re3lib/FunctionDumper.java | 17 +++++++++++++++++ 3 files changed, 25 insertions(+) create mode 100644 game_re/r3/binders/auto_pch.cxx diff --git a/game_re/CMakeLists.txt b/game_re/CMakeLists.txt index e25c01d4..884bc131 100644 --- a/game_re/CMakeLists.txt +++ b/game_re/CMakeLists.txt @@ -52,6 +52,9 @@ target_sources(game_re PRIVATE # Ignore -Wformat-security target_compile_options(game_re PRIVATE -Wno-format-security) +# Ignore -Wmicrosoft-cast +target_compile_options(game_re PRIVATE -Wno-microsoft-cast) + # Automatically re-run CMake if any gh_*.cxx files change # due to ghidra script runs set_property( @@ -59,3 +62,7 @@ set_property( APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/gh_cmake_timestamp ) + +target_precompile_headers(game_re PRIVATE + "$<$:${CMAKE_CURRENT_SOURCE_DIR}/r3/binders/auto_pch.cxx>" +) diff --git a/game_re/r3/binders/auto_pch.cxx b/game_re/r3/binders/auto_pch.cxx new file mode 100644 index 00000000..3f69be13 --- /dev/null +++ b/game_re/r3/binders/auto_pch.cxx @@ -0,0 +1 @@ +#include "auto.h" \ No newline at end of file diff --git a/scripts/re3lib/FunctionDumper.java b/scripts/re3lib/FunctionDumper.java index b419b4f8..13a6b2df 100644 --- a/scripts/re3lib/FunctionDumper.java +++ b/scripts/re3lib/FunctionDumper.java @@ -31,6 +31,8 @@ public class FunctionDumper { HashSet
functionAddrBlackList = new HashSet<>(); public boolean createdFile = false; + // Collects functions called by the current function + public HashSet functionReferences = new HashSet<>(); static final Pattern fieldAccessRegex = Pattern.compile("^_([0-9]+)_([0-9]+)_$"); @@ -101,6 +103,20 @@ public class FunctionDumper { } } + public static boolean isDumpedFix(Function function) { + String sanitizedFunctionName = Utils.sanitizeIdentifier(function.getName()); + String fileName = sanitizedFunctionName + ".cxx"; + File f0 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName); + return f0.exists(); + } + + public static boolean isDumpedAuto(Function function) { + String sanitizedFunctionName = Utils.sanitizeIdentifier(function.getName()); + String fileName = sanitizedFunctionName + ".cxx"; + File f0 = new File(RecompileConfig.INSTANCE.dirDecompAuto, fileName); + return f0.exists(); + } + public void dump(Function function) throws Exception { String sanitizedFunctionName = Utils.sanitizeIdentifier(function.getName()); @@ -111,6 +127,7 @@ public class FunctionDumper { if (stubFile.exists()) { script.println("Removing function stub " + stubFile); stubFile.delete(); + createdFile = true; } File f0 = new File(RecompileConfig.INSTANCE.dirDecompFix, fileName);