From 9e6863f9025e159bdfd012858b3a9bb855e7df88 Mon Sep 17 00:00:00 2001 From: Timofei Zhakov Date: Sun, 22 Jun 2025 00:42:59 +0200 Subject: [PATCH] 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`. --- .github/workflows/CI-win.yml | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/.github/workflows/CI-win.yml b/.github/workflows/CI-win.yml index 0e0a75f4d..a1d0cc4fd 100644 --- a/.github/workflows/CI-win.yml +++ b/.github/workflows/CI-win.yml @@ -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\\"' || '' }}