From 0d611e02f4e47006553d605794b7d911aea20e7f Mon Sep 17 00:00:00 2001 From: nircoe Date: Sun, 27 Sep 2026 12:16:58 +0300 Subject: [PATCH 1/3] [Build]: Fix MinGW DLL copying in Windows CI --- .github/workflows/ci-windows.yml | 9 ------- cmake/utils.cmake | 42 ++++++++++++++++++++++++++++++++ tests/CMakeLists.txt | 2 ++ 3 files changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml index 84c051e..945e0ad 100644 --- a/.github/workflows/ci-windows.yml +++ b/.github/workflows/ci-windows.yml @@ -130,15 +130,6 @@ jobs: working-directory: build/tests run: | set -o pipefail - if [ "${{ matrix.compiler }}" == "gcc" ]; then - # For MinGW - copy DLLs directly (no PATH manipulation) - GCC_DIR=$(dirname $(which gcc)) - echo "GCC directory: $GCC_DIR" - echo "Copying DLLs from $GCC_DIR" - cp "$GCC_DIR"/libgcc*.dll . 2>/dev/null || echo "No libgcc DLLs found" - cp "$GCC_DIR"/libstdc*.dll . 2>/dev/null || echo "No libstdc DLLs found" - cp "$GCC_DIR"/libwinpthread*.dll . 2>/dev/null || echo "No libwinpthread DLLs found" - fi echo "Running gamecoe tests" ./gamecoe_tests.exe | tee test_output.log # testcoe currently reports a skipped test as failed. Narrow this back to skips only diff --git a/cmake/utils.cmake b/cmake/utils.cmake index e1c7a2b..717761f 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -13,4 +13,46 @@ function(copy_gamecoe_assets_to_build_root exe) COMMENT "[gamecoe] Copying gamecoe assets to build root" WORKING_DIRECTORY ${CMAKE_BINARY_DIR} ) +endfunction() + +# Automatically copies required MinGW DLLs to target directory on Windows + +function(copy_mingw_dlls_to_target target_name) + if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + message(STATUS "[gamecoe] Setting up automatic MinGW DLL copying for ${target_name}") + + # Get the compiler directory + get_filename_component(COMPILER_DIR ${CMAKE_CXX_COMPILER} DIRECTORY) + + # List of DLLs that might be needed for MinGW + set(MINGW_DLLS + libgcc_s_seh-1.dll # 64-bit SEH exception handling + libgcc_s_dw2-1.dll # 32-bit Dwarf2 exception handling + libstdc++-6.dll # C++ standard library + libwinpthread-1.dll # Threading support + ) + + foreach(dll ${MINGW_DLLS}) + set(dll_path "${COMPILER_DIR}/${dll}") + if(EXISTS "${dll_path}") + message(STATUS "[gamecoe] Found ${dll} at ${dll_path}") + add_custom_command(TARGET ${target_name} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + "${dll_path}" + "$/${dll}" + COMMENT "[gamecoe] Copying MinGW DLL: ${dll}" + VERBATIM + ) + else() + message(STATUS "[gamecoe] ${dll} not found, skipping") + endif() + endforeach() + endif() +endfunction() + +# Alternative function for multiple targets +function(copy_mingw_dlls_to_targets) + foreach(target_name ${ARGN}) + copy_mingw_dlls_to_target(${target_name}) + endforeach() endfunction() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0509841..5016b25 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,6 +37,8 @@ if(WIN32) COMMAND_EXPAND_LISTS) endif() +copy_mingw_dlls_to_target(gamecoe_tests) + # game::create() needs soundcoe's default audio root to exist next to the test binary if(GAMECOE_USE_SOUNDCOE) add_custom_command(TARGET gamecoe_tests POST_BUILD From a5c9633efdf9ec79e03b6f0ccc346c7d03b1ecf6 Mon Sep 17 00:00:00 2001 From: nircoe Date: Sun, 27 Sep 2026 12:49:20 +0300 Subject: [PATCH 2/3] Remove redundant CI installs --- .github/workflows/ci-linux.yml | 2 +- .github/workflows/ci-macos.yml | 5 ----- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/ci-linux.yml b/.github/workflows/ci-linux.yml index dd1b03a..1ad4e4e 100644 --- a/.github/workflows/ci-linux.yml +++ b/.github/workflows/ci-linux.yml @@ -47,7 +47,7 @@ jobs: - name: Install dependencies run: | sudo apt-get update - sudo apt-get install -y ninja-build xvfb xorg-dev libgl1-mesa-dev libglu1-mesa-dev libgl1-mesa-dri + sudo apt-get install -y xorg-dev libgl1-mesa-dev libglu1-mesa-dev libgl1-mesa-dri shell: bash - name: Install GCC 16 diff --git a/.github/workflows/ci-macos.yml b/.github/workflows/ci-macos.yml index 67207cc..2bca1f9 100644 --- a/.github/workflows/ci-macos.yml +++ b/.github/workflows/ci-macos.yml @@ -32,11 +32,6 @@ jobs: with: submodules: 'recursive' - - name: Install ninja-build - run: | - brew install ninja - shell: bash - - name: Setup ccache uses: hendrikmuhs/ccache-action@v1.2 with: From e63a43fed0f51d497167ecf3c8da03e15ee3ef7e Mon Sep 17 00:00:00 2001 From: nircoe Date: Sun, 27 Sep 2026 16:19:59 +0300 Subject: [PATCH 3/3] Prefix gamecoe_ cmake utils functions --- cmake/utils.cmake | 6 +++--- tests/CMakeLists.txt | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/utils.cmake b/cmake/utils.cmake index 717761f..eed5abd 100644 --- a/cmake/utils.cmake +++ b/cmake/utils.cmake @@ -17,7 +17,7 @@ endfunction() # Automatically copies required MinGW DLLs to target directory on Windows -function(copy_mingw_dlls_to_target target_name) +function(gamecoe_copy_mingw_dlls_to_target target_name) if(WIN32 AND CMAKE_CXX_COMPILER_ID STREQUAL "GNU") message(STATUS "[gamecoe] Setting up automatic MinGW DLL copying for ${target_name}") @@ -51,8 +51,8 @@ function(copy_mingw_dlls_to_target target_name) endfunction() # Alternative function for multiple targets -function(copy_mingw_dlls_to_targets) +function(gamecoe_copy_mingw_dlls_to_targets) foreach(target_name ${ARGN}) - copy_mingw_dlls_to_target(${target_name}) + gamecoe_copy_mingw_dlls_to_target(${target_name}) endforeach() endfunction() \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 5016b25..c7b3d49 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -37,7 +37,7 @@ if(WIN32) COMMAND_EXPAND_LISTS) endif() -copy_mingw_dlls_to_target(gamecoe_tests) +gamecoe_copy_mingw_dlls_to_target(gamecoe_tests) # game::create() needs soundcoe's default audio root to exist next to the test binary if(GAMECOE_USE_SOUNDCOE)