summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMalkierian <malkierian@gmail.com>2026-08-14 11:54:09 -0700
committerGitHub <noreply@github.com>2026-08-14 18:54:09 +0000
commit9782faba44b0cb1510f5256f86781aa2ae47dfaf (patch)
tree4f894d421b885cbb27b79a8cd1609be4020540ff
parentdb147f6a0a1e16d62986d4ed48b9d6f7924397ea (diff)
Torch CMake and Extraction Flow cleanup (#7063)
* Fix yaml-cpp inclusion for VS building. * Fix double-finds for rom files in the binary directory. * Fix archive generation targets. * Port over Proxy's change on 2ship to old ROM deletion to search all applicable subdirectories.
-rw-r--r--CMakeLists.txt7
-rw-r--r--soh/CMakeLists.txt6
-rw-r--r--soh/soh/OTRGlobals.cpp40
3 files changed, 38 insertions, 15 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 63642b0f5..752c9cd82 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -241,6 +241,8 @@ foreach(_torch_game SM64 MK64 SF64 PM64 FZERO BK64 MARIO_ARTIST)
set(BUILD_${_torch_game} OFF CACHE BOOL "" FORCE)
endforeach()
+add_compile_definitions(YAML_CPP_STATIC_DEFINE)
+
add_subdirectory(torch)
# Build-time ROM extraction. soh links torch as a static library, which compiles out torch's
@@ -258,6 +260,11 @@ add_executable(soh-o2r-packer EXCLUDE_FROM_ALL
)
target_link_libraries(soh-o2r-packer PRIVATE torch)
+if(MSVC)
+ set_target_properties(soh-torch soh-o2r-packer PROPERTIES
+ MSVC_RUNTIME_LIBRARY "$<IF:$<CONFIG:Debug>,MultiThreadedDebug,MultiThreaded>")
+endif()
+
# Target to generate OTRs. SOH_ROM_PATH takes roms and/or directories of roms; torch names each
# archive (oot.o2r or oot-mq.o2r) from its hash, so a vanilla and a master quest rom produce both
# in one run. soh.o2r comes from GenerateSohOtr, chained below.
diff --git a/soh/CMakeLists.txt b/soh/CMakeLists.txt
index 192493472..33b45c26e 100644
--- a/soh/CMakeLists.txt
+++ b/soh/CMakeLists.txt
@@ -227,12 +227,6 @@ set(ALL_FILES
################################################################################
add_executable(${PROJECT_NAME} ${ALL_FILES})
-if(MSVC)
- # yaml-cpp, reached through torch's headers, trips the dll-interface warnings, and soh
- # builds with /WX.
- set_source_files_properties(soh/Extractor/TorchExtract.cpp PROPERTIES COMPILE_OPTIONS "/wd4251;/wd4275")
-endif()
-
if (CMAKE_SYSTEM_NAME STREQUAL "Windows")
use_props(${PROJECT_NAME} "${CMAKE_CONFIGURATION_TYPES}" "${DEFAULT_CXX_PROPS}")
endif()
diff --git a/soh/soh/OTRGlobals.cpp b/soh/soh/OTRGlobals.cpp
index 792194646..1bf777a52 100644
--- a/soh/soh/OTRGlobals.cpp
+++ b/soh/soh/OTRGlobals.cpp
@@ -396,6 +396,19 @@ namespace SohGui {
extern std::shared_ptr<SohGui::SohMenu> mSohMenu;
}
+static bool RemoveArchiveAcrossAppDirs(const std::string& fileName) {
+ for (const std::string& path : { Ship::Context::GetPathRelativeToAppDirectory(fileName, appShortName),
+ Ship::Context::GetPathRelativeToAppBundle(fileName), "./" + fileName }) {
+ std::error_code err;
+ if (std::filesystem::remove(path, err)) {
+ SPDLOG_INFO("Removed outdated archive {}", path);
+ } else if (err) {
+ SPDLOG_ERROR("Failed to remove outdated archive {}: {}", path, err.message());
+ }
+ }
+ return !std::filesystem::exists(Ship::Context::LocateFileAcrossAppDirs(fileName, appShortName));
+}
+
void OTRGlobals::RunExtract(int argc, char* argv[]) {
bool extractDone = false;
ExtractSteps extractStep = ES_PORT_ARCHIVE;
@@ -420,8 +433,8 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) {
bool generatedIsMQ = false;
std::atomic<size_t> extractCount = 0, totalExtract = 0;
- std::string installPath = Ship::Context::GetAppBundlePath();
- std::string dataPath = Ship::Context::GetAppDirectoryPath(appShortName);
+ std::string installPath = std::filesystem::absolute(Ship::Context::GetAppBundlePath()).string();
+ std::string dataPath = std::filesystem::absolute(Ship::Context::GetAppDirectoryPath(appShortName)).string();
std::string file;
#if defined(__SWITCH__)
@@ -445,11 +458,18 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) {
"re-extract them from the download or.\n\nExiting...",
"OK", "", [&]() { exit(1); });
} else if (shouldRegen) {
- SohGui::RegisterPopup("Outdated ROM Archives",
- "Your oot.o2r or oot-mq.o2r were created with incompatible versions of SoH.\nYou will "
- "now be redirected to re-extract them.");
- std::filesystem::remove("oot.o2r");
- std::filesystem::remove("oot-mq.o2r");
+ if (RemoveArchiveAcrossAppDirs("oot.o2r") && RemoveArchiveAcrossAppDirs("oot-mq.o2r")) {
+ SohGui::RegisterPopup(
+ "Outdated ROM Archives",
+ "Your oot.o2r or oot-mq.o2r were created with incompatible versions of SoH.\nYou will "
+ "now be redirected to re-extract them.");
+ } else {
+ SohGui::RegisterPopup(
+ "Outdated ROM Archives",
+ "Your oot.o2r or oot-mq.o2r were created with incompatible\nversions of SoH, but they"
+ "could not be removed\nautomatically. Please delete them now and re-launch.\nExiting...",
+ "OK", "", [&]() { exit(1); });
+ }
}
std::shared_ptr<BS::thread_pool> threadPool = std::make_shared<BS::thread_pool>(1);
@@ -637,8 +657,10 @@ void OTRGlobals::RunExtract(int argc, char* argv[]) {
extract = Extractor();
extract.SetSearchPath(installPath);
extract.GetRoms(args);
- extract.SetSearchPath(dataPath);
- extract.GetRoms(args);
+ if (installPath != dataPath) {
+ extract.SetSearchPath(dataPath);
+ extract.GetRoms(args);
+ }
if (!args.empty()) {
promptStep = PS_WAIT;
SohGui::RegisterPopup(