From ec207cae060e9ddbed68f0945f7726c4ceee3132 Mon Sep 17 00:00:00 2001 From: scawful Date: Fri, 26 Sep 2025 12:47:10 -0400 Subject: [PATCH] Refactor CI workflow and CMake configuration for Windows builds - Updated the CI workflow to conditionally set up vcpkg only for non-CI Windows builds, improving build efficiency. - Simplified CMake configuration for Windows by consolidating build type checks and ensuring proper handling of resource files based on the YAZE_MINIMAL_BUILD flag. - Enhanced modularity in file dialog implementation by introducing wrapper methods for better maintainability and clarity in the codebase. --- .github/workflows/ci.yml | 16 ++++------- src/CMakeLists.txt | 41 ++++++++++++++++++++-------- src/app/core/platform/file_dialog.cc | 32 ++++++++++++++++++++++ src/app/test/test_manager.cc | 10 +++---- src/app/test/test_manager.h | 4 +-- 5 files changed, 74 insertions(+), 29 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index ffca05ec..2c82c788 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -147,9 +147,9 @@ jobs: # Install Homebrew dependencies if needed # brew install pkg-config libpng boost abseil - # Windows-specific setup - - name: Set up vcpkg (non-minimal builds only) - if: runner.os == 'Windows' && env.BUILD_TYPE != 'RelWithDebInfo' + # Windows-specific setup (skip vcpkg for CI builds) + - name: Set up vcpkg (non-CI builds only) + if: runner.os == 'Windows' && github.event_name != 'push' && github.event_name != 'pull_request' uses: lukka/run-vcpkg@v11 with: vcpkgGitCommitId: 'c8696863d371ab7f46e213d8f5ca923c4aef2a00' @@ -171,14 +171,8 @@ jobs: -Wno-dev \ -GNinja - - name: Configure CMake (Windows with vcpkg) - if: runner.os == 'Windows' && env.BUILD_TYPE != 'RelWithDebInfo' - shell: cmd - run: | - cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_TOOLCHAIN_FILE=${{ github.workspace }}/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }} -DCMAKE_POLICY_VERSION_MINIMUM=3.16 -DYAZE_MINIMAL_BUILD=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF -DYAZE_ENABLE_UI_TESTS=OFF -Wno-dev -G "${{ matrix.cmake_generator }}" -A ${{ matrix.cmake_generator_platform }} - - - name: Configure CMake (Windows minimal build) - if: runner.os == 'Windows' && env.BUILD_TYPE == 'RelWithDebInfo' + - name: Configure CMake (Windows) + if: runner.os == 'Windows' shell: cmd run: | cmake -B ${{ github.workspace }}/build -DCMAKE_BUILD_TYPE=${{ env.BUILD_TYPE }} -DCMAKE_POLICY_VERSION_MINIMUM=3.16 -DYAZE_MINIMAL_BUILD=ON -DYAZE_ENABLE_ROM_TESTS=OFF -DYAZE_ENABLE_EXPERIMENTAL_TESTS=OFF -DYAZE_ENABLE_UI_TESTS=OFF -Wno-dev -G "${{ matrix.cmake_generator }}" -A ${{ matrix.cmake_generator_platform }} diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3ed860a7..f2d9c1de 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -100,19 +100,29 @@ elseif(UNIX) target_compile_definitions(yaze PRIVATE "linux") target_compile_definitions(yaze PRIVATE "stricmp=strcasecmp") else() - set_target_properties(yaze - PROPERTIES - ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" - LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" - RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" - LINK_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/win32/yaze.res" - ) + if(YAZE_MINIMAL_BUILD) + # Skip Windows resource file in CI/minimal builds to avoid architecture conflicts + set_target_properties(yaze + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + ) + else() + set_target_properties(yaze + PROPERTIES + ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib" + RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin" + LINK_FLAGS "${CMAKE_CURRENT_SOURCE_DIR}/win32/yaze.res" + ) + endif() endif() # Yaze C API if (YAZE_BUILD_LIB) - add_library( - yaze_c SHARED + # Create source list for yaze_c + set(YAZE_C_SOURCES ./yaze.cc app/rom.cc ${YAZE_APP_EMU_SRC} @@ -123,8 +133,14 @@ if (YAZE_BUILD_LIB) ${YAZE_GUI_SRC} ${YAZE_UTIL_SRC} ${IMGUI_SRC} - ${IMGUI_TEST_ENGINE_SOURCES} ) + + # Only add ImGui Test Engine sources if UI tests are enabled + if(YAZE_ENABLE_UI_TESTS) + list(APPEND YAZE_C_SOURCES ${IMGUI_TEST_ENGINE_SOURCES}) + endif() + + add_library(yaze_c SHARED ${YAZE_C_SOURCES}) target_include_directories( yaze_c PUBLIC @@ -151,9 +167,12 @@ if (YAZE_BUILD_LIB) ImGui ) - # Conditionally link ImGui Test Engine + # Conditionally link ImGui Test Engine and set definitions if(YAZE_ENABLE_UI_TESTS AND TARGET ImGuiTestEngine) target_link_libraries(yaze_c PRIVATE ImGuiTestEngine) + target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=1) + else() + target_compile_definitions(yaze_c PRIVATE YAZE_ENABLE_IMGUI_TEST_ENGINE=0) endif() # Conditionally link PNG if available diff --git a/src/app/core/platform/file_dialog.cc b/src/app/core/platform/file_dialog.cc index 7ad5ed1d..6a424c07 100644 --- a/src/app/core/platform/file_dialog.cc +++ b/src/app/core/platform/file_dialog.cc @@ -109,7 +109,23 @@ std::string GetConfigDirectory() { #ifdef _WIN32 +// Forward declaration for the main implementation +std::string ShowOpenFileDialogImpl(); + std::string FileDialogWrapper::ShowOpenFileDialog() { + return ShowOpenFileDialogImpl(); +} + +std::string FileDialogWrapper::ShowOpenFileDialogNFD() { + // Windows doesn't use NFD in this implementation, fallback to bespoke + return ShowOpenFileDialogBespoke(); +} + +std::string FileDialogWrapper::ShowOpenFileDialogBespoke() { + return ShowOpenFileDialogImpl(); +} + +std::string ShowOpenFileDialogImpl() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); IFileDialog *pfd = NULL; @@ -141,7 +157,23 @@ std::string FileDialogWrapper::ShowOpenFileDialog() { return file_path_windows; } +// Forward declaration for folder dialog implementation +std::string ShowOpenFolderDialogImpl(); + std::string FileDialogWrapper::ShowOpenFolderDialog() { + return ShowOpenFolderDialogImpl(); +} + +std::string FileDialogWrapper::ShowOpenFolderDialogNFD() { + // Windows doesn't use NFD in this implementation, fallback to bespoke + return ShowOpenFolderDialogBespoke(); +} + +std::string FileDialogWrapper::ShowOpenFolderDialogBespoke() { + return ShowOpenFolderDialogImpl(); +} + +std::string ShowOpenFolderDialogImpl() { CoInitializeEx(NULL, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE); IFileDialog *pfd = NULL; diff --git a/src/app/test/test_manager.cc b/src/app/test/test_manager.cc index a6855249..f6ca8116 100644 --- a/src/app/test/test_manager.cc +++ b/src/app/test/test_manager.cc @@ -16,7 +16,7 @@ class EditorManager; } } -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE #include "imgui_test_engine/imgui_te_engine.h" #endif @@ -64,19 +64,19 @@ TestManager& TestManager::Get() { } TestManager::TestManager() { - // Initialize UI test engine -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +// Initialize UI test engine +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE InitializeUITesting(); #endif } TestManager::~TestManager() { -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE ShutdownUITesting(); #endif } -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE void TestManager::InitializeUITesting() { if (!ui_test_engine_) { ui_test_engine_ = ImGuiTestEngine_CreateContext(); diff --git a/src/app/test/test_manager.h b/src/app/test/test_manager.h index 17086868..12637037 100644 --- a/src/app/test/test_manager.h +++ b/src/app/test/test_manager.h @@ -20,7 +20,7 @@ class EditorManager; } } -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE #include "imgui_test_engine/imgui_te_engine.h" #else // Forward declaration when ImGui Test Engine is not available @@ -143,7 +143,7 @@ class TestManager { } // UI Testing (ImGui Test Engine integration) -#ifdef YAZE_ENABLE_IMGUI_TEST_ENGINE +#if defined(YAZE_ENABLE_IMGUI_TEST_ENGINE) && YAZE_ENABLE_IMGUI_TEST_ENGINE ImGuiTestEngine* GetUITestEngine() { return ui_test_engine_; } void InitializeUITesting(); void StopUITesting(); // Stop test engine while ImGui context is valid