Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
137 changes: 129 additions & 8 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,66 @@ jobs:
with:
arch: x64

- name: Check cl.exe version
run: cl.exe /Bv 2>&1 || exit 0
shell: cmd
- name: Get MSVC version
id: msvc_version
shell: pwsh
run: |
# Create a dummy source file for cl.exe /Bv
"int main() { return 0; }" | Out-File -FilePath "dummy.cpp" -Encoding ASCII

$output = & cl.exe /Bv dummy.cpp 2>&1
Write-Host "Raw cl.exe output:"
Write-Host $output

# More robust version extraction
$version = $null

# Split output into lines and search for version patterns
$lines = $output -split "`n|`r"
Write-Host "Number of lines: $($lines.Count)"

foreach ($line in $lines) {
Write-Host "Processing line: '$line'"

# Try different patterns on each line
if ($line -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found version in line: $version"
break
}
elseif ($line -match '([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found generic version in line: $version"
break
}
}

# If still no version, try the whole output as a single string
if (-not $version) {
Write-Host "Trying whole output as single string..."
if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found version in whole output: $version"
}
elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found generic version in whole output: $version"
}
}

Write-Host "Final version result: $version"

if ($version) {
Write-Host "MSVC version: $version"
Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8
} else {
Write-Host "Failed to extract MSVC version from output:"
Write-Host $output
throw "MSVC version not found in output"
}

# Clean up dummy file
Remove-Item "dummy.cpp" -ErrorAction SilentlyContinue

- name: Setup vcpkg
uses: lukka/run-vcpkg@v11.5
Expand All @@ -138,9 +195,10 @@ jobs:
uses: actions/cache@v4
with:
path: build/ALL
key: ${{ runner.os }}-cmake-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }}
key: ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-cmake-${{ github.event.inputs.cache-key-suffix || 'default' }}-
${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-
${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-
${{ runner.os }}-cmake-

- name: Remove stale CMake cache if drive letter changed
Expand Down Expand Up @@ -235,6 +293,68 @@ jobs:
- uses: ilammy/msvc-dev-cmd@v1
if: steps.check-hlsl.outputs.skip != 'true'

- name: Get MSVC version
if: steps.check-hlsl.outputs.skip != 'true'
id: msvc_version
shell: pwsh
run: |
# Create a dummy source file for cl.exe /Bv
"int main() { return 0; }" | Out-File -FilePath "dummy.cpp" -Encoding ASCII

$output = & cl.exe /Bv dummy.cpp 2>&1
Write-Host "Raw cl.exe output:"
Write-Host $output

# More robust version extraction
$version = $null

# Split output into lines and search for version patterns
$lines = $output -split "`n|`r"
Write-Host "Number of lines: $($lines.Count)"

foreach ($line in $lines) {
Write-Host "Processing line: '$line'"

# Try different patterns on each line
if ($line -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found version in line: $version"
break
}
elseif ($line -match '([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found generic version in line: $version"
break
}
}

# If still no version, try the whole output as a single string
if (-not $version) {
Write-Host "Trying whole output as single string..."
if ($output -match 'Version ([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found version in whole output: $version"
}
elseif ($output -match '([0-9]+\.[0-9]+\.[0-9]+)') {
$version = $Matches[1]
Write-Host "Found generic version in whole output: $version"
}
}

Write-Host "Final version result: $version"

if ($version) {
Write-Host "MSVC version: $version"
Add-Content -Path $env:GITHUB_OUTPUT -Value "version=$version" -Encoding UTF8
} else {
Write-Host "Failed to extract MSVC version from output:"
Write-Host $output
throw "MSVC version not found in output"
}

# Clean up dummy file
Remove-Item "dummy.cpp" -ErrorAction SilentlyContinue

- name: Setup vcpkg
if: steps.check-hlsl.outputs.skip != 'true'
uses: lukka/run-vcpkg@v11.5
Expand All @@ -246,10 +366,11 @@ jobs:
uses: actions/cache@v4
with:
path: build/ALL
key: ${{ runner.os }}-cmake-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }}
key: ${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-${{ hashFiles('.gitmodules', 'extern/**', 'CMakePresets.json', 'vcpkg.json', 'vcpkg-configuration.json') }}
restore-keys: |
${{ runner.os }}-cmake-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-
${{ runner.os }}-cmake-${{ matrix.config.name }}-
${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}-${{ github.event.inputs.cache-key-suffix || 'default' }}-
${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-${{ matrix.config.name }}-
${{ runner.os }}-cmake-msvc-${{ steps.msvc_version.outputs.version }}-
${{ runner.os }}-cmake-

- name: Remove stale CMake cache if drive letter changed
Expand Down