fix: update Windows build workflow for cross-compilation and improve CMake configuration
Some checks failed
Build / Build (push) Has been cancelled
MSVC Build / build-windows (windows-latest) (push) Has been cancelled

This commit is contained in:
ShiftyX1 2025-12-09 00:33:55 +03:00
parent 70aa850999
commit 21874e98c2

View File

@ -1,4 +1,4 @@
name: Windows Build (CLang)
name: Windows Build (Cross-compile)
on:
push:
@ -14,62 +14,61 @@ on:
jobs:
build-windows:
strategy:
matrix:
include:
- os: windows-latest
compiler: clang
runs-on: ${{ matrix.os }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: 'true'
- uses: msys2/setup-msys2@v2
id: msys2
name: Setup MSYS2
with:
msystem: clang64
install: >-
mingw-w64-clang-x86_64-toolchain
mingw-w64-clang-x86_64-cmake
git
- name: Install cross-compilation tools
run: |
sudo apt-get update
sudo apt-get install -y mingw-w64 cmake wget git zip
- name: Install CMake >= 3.26
run: |
wget https://github.com/Kitware/CMake/releases/download/v3.27.9/cmake-3.27.9-linux-x86_64.sh
chmod +x cmake-3.27.9-linux-x86_64.sh
sudo ./cmake-3.27.9-linux-x86_64.sh --skip-license --prefix=/usr/local
rm cmake-3.27.9-linux-x86_64.sh
- name: Set up vcpkg
shell: msys2 {0}
run: |
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.bat
./vcpkg integrate install
cd ..
- name: Configure project with CMake and vcpkg
git clone https://github.com/microsoft/vcpkg.git
cd vcpkg
./bootstrap-vcpkg.sh
cd ..
- name: Configure and build project
env:
VCPKG_DEFAULT_TRIPLET: x64-mingw-static
VCPKG_DEFAULT_HOST_TRIPLET: x64-mingw-static
shell: msys2 {0}
VCPKG_DEFAULT_TRIPLET: x64-mingw-static
VCPKG_DEFAULT_HOST_TRIPLET: x64-linux
run: |
export VCPKG_ROOT=$(pwd)/vcpkg
mkdir build
cd build
cmake -G "MinGW Makefiles" -DVCPKG_TARGET_TRIPLET=x64-mingw-static -DVC_BUILD_NAME="${{ inputs.build_name }}" -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=./vcpkg/scripts/buildsystems/vcpkg.cmake ..
cmake --build . --config Release
export VCPKG_ROOT=$(pwd)/vcpkg
mkdir build
cd build
cmake -DCMAKE_TOOLCHAIN_FILE=$VCPKG_ROOT/scripts/buildsystems/vcpkg.cmake \
-DVCPKG_TARGET_TRIPLET=x64-mingw-static \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER=x86_64-w64-mingw32-gcc \
-DCMAKE_CXX_COMPILER=x86_64-w64-mingw32-g++ \
-DCMAKE_RC_COMPILER=x86_64-w64-mingw32-windres \
-DCMAKE_BUILD_TYPE=Release \
-DVC_BUILD_NAME="${{ inputs.build_name }}" \
..
cmake --build . --config Release
- name: Package for Windows
run: |
mkdir packaged
mkdir packaged/res
cp build/VoxelEngine.exe packaged/
cp build/vctest/vctest.exe packaged/
cp build/*.dll packaged/
cp build/VoxelEngine.exe packaged/VoxelCore.exe || cp build/VoxelEngine packaged/VoxelCore.exe
cp build/vctest/vctest.exe packaged/ || cp build/vctest/vctest packaged/vctest.exe
cp build/*.dll packaged/ 2>/dev/null || true
cp -r build/res/* packaged/res/
mv packaged/VoxelEngine.exe packaged/VoxelCore.exe
- uses: actions/upload-artifact@v3
with:
name: Windows-Build
path: 'packaged/*'
- name: Run engine tests
shell: msys2 {0}
working-directory: ${{ github.workspace }}
run: |
packaged/vctest.exe -e packaged/VoxelCore.exe -d dev/tests -u build