Skip to content

Commit 31fa7cb

Browse files
committed
Test ci support for Mingw and MSVC
1 parent 9667fe7 commit 31fa7cb

File tree

1 file changed

+50
-68
lines changed

1 file changed

+50
-68
lines changed

.github/workflows/main.yml

Lines changed: 50 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,20 @@ jobs:
2222
compiler: clang
2323
cc: clang
2424
cxx: clang++
25-
# For now disable msvc test
26-
# - os: windows-latest
27-
# compiler: msvc
28-
# cc: cl
29-
# cxx: cl
25+
- os: windows-latest
26+
compiler: msvc
27+
cc: cl
28+
cxx: cl
29+
- os: windows-latest
30+
compiler: mingw64
31+
cc: x86_64-w64-mingw32-gcc
32+
cxx: x86_64-w64-mingw32-g++
3033

3134
steps:
3235
- name: Checkout repository
3336
uses: actions/checkout@v4
3437

35-
- name: Install prerequisites & build SDL2 v2.0.20 (Linux)
38+
- name: Install prerequisites (Linux)
3639
if: matrix.os == 'ubuntu-latest'
3740
run: |
3841
sudo apt-get update
@@ -43,65 +46,16 @@ jobs:
4346
libsdl2-dev libsdl2-ttf-dev libsdl2-mixer-dev \
4447
libglew-dev libfreetype6-dev
4548
46-
# sudo apt-get install -y \
47-
# build-essential cmake ccache git \
48-
# libgl1-mesa-dev libglu1-mesa-dev \
49-
# libx11-dev libxrandr-dev libxi-dev libxinerama-dev libxcursor-dev libxss-dev libxxf86vm-dev \
50-
# libglew-dev libfreetype6-dev libasound2-dev libpulse-dev libudev-dev libdbus-1-dev \
51-
# libmpg123-dev libvorbis-dev libflac-dev libxmp-dev \
52-
# libopusfile-dev libfluidsynth-dev libogg-dev libwavpack-dev
53-
54-
# # SDL2 v2.0.20
55-
# git clone https://github.com/libsdl-org/SDL.git SDL2
56-
# cd SDL2
57-
# git fetch --tags # ← make sure tags are present locally
58-
# git checkout release-2.0.20 # ← the correct release tag
59-
# mkdir build && cd build
60-
# cmake .. -DCMAKE_BUILD_TYPE=Release \
61-
# -DSDL_INSTALL_INCLUDEDIR=include/SDL2
62-
# make -j$(nproc)
63-
# sudo make install
64-
# sudo ldconfig
65-
# cd ../..
66-
67-
# # repeat the same pattern (fetch tags + checkout) for ttf & mixer
68-
# git clone https://github.com/libsdl-org/SDL_ttf.git SDL_ttf
69-
# cd SDL_ttf
70-
# git fetch --tags
71-
# git checkout release-2.0.15
72-
# mkdir build && cd build
73-
# cmake .. -DCMAKE_BUILD_TYPE=Release
74-
# make -j$(nproc)
75-
# sudo make install
76-
# sudo ldconfig
77-
# cd ../..
78-
79-
# git clone https://github.com/libsdl-org/SDL_mixer.git SDL_mixer
80-
# cd SDL_mixer
81-
# git fetch --tags
82-
# git checkout release-2.0.4
83-
# mkdir build && cd build
84-
# cmake .. -DCMAKE_BUILD_TYPE=Release
85-
# make -j$(nproc)
86-
# sudo make install
87-
# sudo ldconfig
88-
# cd ../..
89-
90-
- name: Cache ccache
91-
uses: actions/cache@v3
92-
with:
93-
path: ~/.ccache
94-
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
95-
restore-keys: |
96-
${{ runner.os }}-ccache-${{ matrix.compiler }}-
49+
- name: Install MinGW (Windows, MinGW only)
50+
if: matrix.os == 'windows-latest' && matrix.compiler == 'mingw64'
51+
shell: bash
52+
run: |
53+
choco install -y mingw
54+
echo "C:/ProgramData/chocolatey/bin" >> $GITHUB_PATH
9755
98-
- name: Cache CMake build
99-
uses: actions/cache@v3
100-
with:
101-
path: build
102-
key: ${{ runner.os }}-cmake-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
103-
restore-keys: |
104-
${{ runner.os }}-cmake-${{ matrix.compiler }}-
56+
- name: Setup MSVC (Windows, MSVC only)
57+
if: matrix.os == 'windows-latest' && matrix.compiler == 'msvc'
58+
uses: ilammy/msvc-dev-cmd@v1
10559

10660
- name: Configure with CMake
10761
run: |
@@ -114,15 +68,36 @@ jobs:
11468
-DCMAKE_BUILD_TYPE=Release \
11569
-DCMAKE_PREFIX_PATH="/usr/local" \
11670
..
117-
else
71+
elif [ "${{ matrix.compiler }}" = "mingw64" ]; then
11872
cmake \
73+
-G "MinGW Makefiles" \
11974
-DCMAKE_C_COMPILER=${{ matrix.cc }} \
12075
-DCMAKE_CXX_COMPILER=${{ matrix.cxx }} \
12176
-DCMAKE_BUILD_TYPE=Release \
12277
..
123-
fi
78+
else
79+
cmake \
80+
-DCMAKE_BUILD_TYPE=Release \
81+
..
82+
shell: bash
12483

125-
- name: Verify SDL2 installation (Linux)
84+
- name: Cache ccache
85+
uses: actions/cache@v3
86+
with:
87+
path: ~/.ccache
88+
key: ${{ runner.os }}-ccache-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
89+
restore-keys: |
90+
${{ runner.os }}-ccache-${{ matrix.compiler }}-
91+
92+
- name: Cache CMake build
93+
uses: actions/cache@v3
94+
with:
95+
path: build
96+
key: ${{ runner.os }}-cmake-${{ matrix.compiler }}-${{ hashFiles('**/CMakeLists.txt') }}
97+
restore-keys: |
98+
${{ runner.os }}-cmake-${{ matrix.compiler }}-
99+
100+
- name: Verify SDL2 installation (Linux only)
126101
if: matrix.os == 'ubuntu-latest'
127102
run: |
128103
echo "Includes:"
@@ -131,9 +106,16 @@ jobs:
131106
sdl2-config --version
132107
133108
- name: Build tests only
134-
run: cmake --build build --config Release --target t1 -- -j$(nproc || echo 2)
109+
run: |
110+
cd build
111+
if [ "${{ matrix.compiler }}" = "mingw64" ]; then
112+
mingw32-make -j$(nproc || echo 2) t1
113+
else
114+
cmake --build . --config Release --target t1 -- -j$(nproc || echo 2)
115+
shell: bash
135116

136117
- name: Run unit tests
137118
run: |
138119
cd build
139120
ctest --output-on-failure --parallel $(nproc || echo 2)
121+
shell: bash

0 commit comments

Comments
 (0)