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.
This commit is contained in:
Malkierian
2026-08-14 11:54:09 -07:00
committed by GitHub
parent db147f6a0a
commit 9782faba44
3 changed files with 38 additions and 15 deletions
+7
View File
@@ -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.
-6
View File
@@ -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()
+31 -9
View File
@@ -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(