Skip to content

Commit 24aa8e7

Browse files
committed
update the pipeline for new github changes
1 parent e8c6867 commit 24aa8e7

1 file changed

Lines changed: 54 additions & 3 deletions

File tree

.github/workflows/windows-build.yml

Lines changed: 54 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,57 @@ jobs:
2828
- uses: actions/checkout@v4
2929
with:
3030
persist-credentials: false
31+
- name: Select Visual Studio generator
32+
id: vs_generator
33+
shell: pwsh
34+
run: |
35+
$ErrorActionPreference = "Stop"
36+
37+
$vswhere = Join-Path ${env:ProgramFiles(x86)} "Microsoft Visual Studio\Installer\vswhere.exe"
38+
$vsInstances = & $vswhere -latest -products * -format json | ConvertFrom-Json
39+
$vsInstance = @($vsInstances)[0]
40+
if ($null -eq $vsInstance) {
41+
Write-Error "No Visual Studio installation was found."
42+
exit 1
43+
}
44+
45+
$vsVersion = [string]$vsInstance.installationVersion
46+
if ([string]::IsNullOrWhiteSpace($vsVersion)) {
47+
Write-Error "Visual Studio installation did not report a version."
48+
exit 1
49+
}
50+
51+
$vcToolsVersionFile = Join-Path $vsInstance.installationPath "VC\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt"
52+
if (-not (Test-Path $vcToolsVersionFile)) {
53+
Write-Error "Visual Studio was found, but C++ tools were not found at $vcToolsVersionFile."
54+
exit 1
55+
}
56+
57+
$major = [int]($vsVersion.Split(".")[0])
58+
if ($major -ge 18) {
59+
$generator = "Visual Studio 18 2026"
60+
} elseif ($major -eq 17) {
61+
$generator = "Visual Studio 17 2022"
62+
} else {
63+
Write-Error "Unsupported Visual Studio version: $vsVersion"
64+
exit 1
65+
}
66+
67+
$cmake = Get-Command cmake -ErrorAction SilentlyContinue
68+
if ($null -eq $cmake) {
69+
Write-Error "CMake was not found on PATH."
70+
exit 1
71+
}
72+
73+
$cmakeHelp = & $cmake.Source --help | Out-String
74+
if (-not $cmakeHelp.Contains($generator)) {
75+
Write-Error "The installed CMake does not support the '$generator' generator."
76+
exit 1
77+
}
78+
79+
"cmake_generator=$generator" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
80+
"vs_major=$major" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
81+
Write-Host "Using CMake generator: $generator"
3182
- name: Cache vcpkg
3283
uses: actions/cache@v4
3384
with:
@@ -37,7 +88,7 @@ jobs:
3788
C:\vcpkg\buildtrees
3889
C:\vcpkg\packages
3990
C:\vcpkg\binarycache
40-
key: ${{ runner.os }}-${{ matrix.arch }}-vcpkg-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
91+
key: ${{ runner.os }}-${{ matrix.arch }}-vs${{ steps.vs_generator.outputs.vs_major }}-vcpkg-${{ hashFiles('vcpkg.json', 'vcpkg-configuration.json') }}
4192
- name: Install FFmpeg (vcpkg)
4293
shell: pwsh
4394
run: |
@@ -54,9 +105,9 @@ jobs:
54105
uses: actions/cache@v4
55106
with:
56107
path: Projects/VS/_deps
57-
key: ${{ runner.os }}-${{ matrix.arch }}-cmake-deps-${{ hashFiles('CMakeLists.txt') }}
108+
key: ${{ runner.os }}-${{ matrix.arch }}-vs${{ steps.vs_generator.outputs.vs_major }}-cmake-deps-${{ hashFiles('CMakeLists.txt') }}
58109
- name: Configure
59-
run: cmake -S . -B Projects/VS -G "Visual Studio 17 2022" -A ${{ matrix.cmake_platform }} ${{ matrix.cmake_extra_args }} -DOPENFODDER_ENABLE_FFMPEG=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }}
110+
run: cmake -S . -B Projects/VS -G "${{ steps.vs_generator.outputs.cmake_generator }}" -A ${{ matrix.cmake_platform }} ${{ matrix.cmake_extra_args }} -DOPENFODDER_ENABLE_FFMPEG=ON -DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=${{ matrix.vcpkg_triplet }}
60111
- name: Build
61112
run: cmake --build Projects/VS --config ${{ matrix.configuration }}
62113
- name: Test

0 commit comments

Comments
 (0)