From ec42054da23d5c16cb1583cd178048f923654c0b Mon Sep 17 00:00:00 2001 From: scawful Date: Mon, 29 Sep 2025 15:38:27 -0400 Subject: [PATCH] Enhance CMake configuration for improved stack management and utility separation - Increased stack size for Windows builds to prevent stack overflow during asset loading and testing. - Added separate executable for rom_patch_utility to enhance modularity and maintainability. - Updated target link libraries for both extract_vanilla_values and rom_patch_utility to ensure proper dependencies are included. - Added conditional checks to prevent building development-only utilities in CI environments. --- src/app/app.cmake | 9 +++++++++ test/CMakeLists.txt | 49 ++++++++++++++++++++++++++++++++++++++++----- 2 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/app/app.cmake b/src/app/app.cmake index 21fb273c..2141638d 100644 --- a/src/app/app.cmake +++ b/src/app/app.cmake @@ -123,6 +123,15 @@ target_link_libraries( ImGui ) +# Increase stack size on Windows to prevent stack overflow during asset loading +# Windows default is 1MB, macOS/Linux is typically 8MB +# LoadAssets() loads 223 graphics sheets and initializes multiple editors +if(MSVC) + target_link_options(yaze PRIVATE /STACK:8388608) # 8MB stack +elseif(MINGW) + target_link_options(yaze PRIVATE -Wl,--stack,8388608) +endif() + # Conditionally link ImGui Test Engine if(YAZE_ENABLE_UI_TESTS) if(TARGET ImGuiTestEngine) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index dd219940..fb52fb1e 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -117,11 +117,11 @@ if(YAZE_BUILD_TESTS AND NOT YAZE_BUILD_TESTS STREQUAL "OFF") endif() # Add vanilla value extraction utility (only for local development with ROM access) -if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS) +# IMPORTANT: Do not build in CI/release - this is a development-only utility +if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS AND NOT DEFINED ENV{GITHUB_ACTIONS}) add_executable( extract_vanilla_values unit/zelda3/extract_vanilla_values.cc - unit/zelda3/rom_patch_utility.cc ${YAZE_SRC_FILES} ) @@ -142,16 +142,49 @@ if(NOT YAZE_MINIMAL_BUILD AND YAZE_ENABLE_ROM_TESTS) target_link_libraries( extract_vanilla_values + yaze_core ${SDL_TARGETS} asar-static ${ABSL_TARGETS} ${PNG_LIBRARIES} ${OPENGL_LIBRARIES} ${CMAKE_DL_LIBS} + ImGui + ) + + # Add rom_patch_utility as a separate executable + add_executable( + rom_patch_utility + unit/zelda3/rom_patch_utility.cc + ${YAZE_SRC_FILES} + ) + + target_include_directories( + rom_patch_utility PUBLIC + ${CMAKE_SOURCE_DIR}/src/app/ + ${CMAKE_SOURCE_DIR}/src/lib/ + ${CMAKE_SOURCE_DIR}/incl/ + ${CMAKE_SOURCE_DIR}/src/ + ${CMAKE_SOURCE_DIR}/src/lib/imgui_test_engine + ${CMAKE_SOURCE_DIR}/src/lib/asar/src + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar + ${CMAKE_SOURCE_DIR}/src/lib/asar/src/asar-dll-bindings/c + ${SDL2_INCLUDE_DIR} + ${PNG_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR} + ) + + target_link_libraries( + rom_patch_utility + yaze_core + ${SDL_TARGETS} + asar-static + ${ABSL_TARGETS} + ${PNG_LIBRARIES} + ${OPENGL_LIBRARIES} + ${CMAKE_DL_LIBS} + ImGui ) - - # Note: extract_vanilla_values is a standalone utility that doesn't need yaze_c library - # It only needs the core ROM functionality which is provided by the source files endif() # Configure test executable only when tests are enabled @@ -212,6 +245,12 @@ endif() target_compile_definitions(yaze_test PRIVATE "MACOS" "stricmp=strcasecmp") elseif(WIN32) target_compile_definitions(yaze_test PRIVATE "WINDOWS") + # Increase stack size on Windows to prevent stack overflow during tests + if(MSVC) + target_link_options(yaze_test PRIVATE /STACK:8388608) # 8MB stack + elseif(MINGW) + target_link_options(yaze_test PRIVATE -Wl,--stack,8388608) + endif() endif() endif()