build: Use Ninja generate in the Windows GitHub-Actions workflow.

Ninja generator will build the project much faster because of its great support for parallel build.

Also it's much more reliable and straightforward when used in automation scripts. 

* .github/workflows/CI-win.yml
  (build-windows::matrix): Change toolchain to `Ninja` and fixup arch name of Win32 to x86, since this is how the DevShell accepts it.
  (build-windows::Build):
  - Enter the VsDevShell mode to access compiler.
  - Explicitly specify CMAKE_BUILD_TYPE because Ninja is a single-config generator.
  - The arch is now determined by the dev-shell and there is no need to specify it as `-A`.
This commit is contained in:
Timofei Zhakov 2025-06-22 00:42:59 +02:00 committed by GitHub
parent 0d4f54f0f6
commit 9e6863f902
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -21,21 +21,25 @@ jobs:
fail-fast: false
matrix:
config:
- {toolchain: Visual Studio 17 2022, arch: Win32, server: 2022}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: ASAN}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2022, config: UBSAN}
- {toolchain: Visual Studio 17 2022, arch: arm64, server: 2022}
- {toolchain: Visual Studio 17 2022, arch: x64, server: 2025}
- {toolchain: Ninja, arch: x86, server: 2022}
- {toolchain: Ninja, arch: x64, server: 2022}
- {toolchain: Ninja, arch: x64, server: 2022, config: ASAN}
- {toolchain: Ninja, arch: x64, server: 2022, config: UBSAN}
- {toolchain: Ninja, arch: arm64, server: 2022}
- {toolchain: Ninja, arch: x64, server: 2025}
steps:
- uses: actions/checkout@v4
- name: Build
run:
cmake -S . -B build -DBUILD_TESTING=ON
-G "${{ matrix.config.toolchain }}" -A ${{ matrix.config.arch }}
$root = "C:\Program Files\Microsoft Visual Studio\2022\Enterprise"
Import-Module "$root\Common7\Tools\Microsoft.VisualStudio.DevShell.dll"
Enter-VsDevShell -VsInstallPath $root -DevCmdArguments "-arch=${{ matrix.arch }}"
cmake -S . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=ON
-G "${{ matrix.config.toolchain }}"
${{ matrix.config.config == 'ASAN' && '-DASAN=on -DCMAKE_MSVC_RUNTIME_LIBRARY=MultiThreaded' || '' }}
cmake --build build --config RelWithDebInfo
cmake --build build
${{ matrix.config.config == 'ASAN' && 'Copy-Item -Path "build\\*.exe" -Destination "build\\RelWithDebInfo\\"' || '' }}