@@ -63,14 +63,90 @@ jobs:
6363 with :
6464 ref : ${{ inputs.ref }}
6565
66+ - name : Set up CMake
67+ run : |
68+ $cmakeVersion = "${{ matrix.config.cmake_version }}"
69+ $cmakeArch = "x86_64"
70+ $cmakeUrl = "https://github.com/Kitware/CMake/releases/download/v${cmakeVersion}/cmake-${cmakeVersion}-windows-${cmakeArch}.zip"
71+ $cmakeZip = "$env:RUNNER_TEMP\cmake-${cmakeVersion}.zip"
72+ $cmakeDir = "C:\Program Files\CMake"
73+
74+ Write-Host "Downloading CMake ${cmakeVersion} from official GitHub releases: ${cmakeUrl}"
75+
76+ # Download with retry logic
77+ $maxRetries = 3
78+ $retryCount = 0
79+ $downloaded = $false
80+
81+ while ($retryCount -lt $maxRetries -and -not $downloaded) {
82+ try {
83+ $retryCount++
84+ Write-Host "Attempt $retryCount of $maxRetries"
85+ Invoke-WebRequest -Uri $cmakeUrl -OutFile $cmakeZip -UseBasicParsing -ErrorAction Stop
86+
87+ # Verify file was downloaded and has content
88+ if (Test-Path $cmakeZip) {
89+ $fileInfo = Get-Item $cmakeZip
90+ if ($fileInfo.Length -gt 0) {
91+ Write-Host "Download successful. File size: $($fileInfo.Length) bytes"
92+ $downloaded = $true
93+ } else {
94+ Write-Host "Downloaded file is empty, retrying..."
95+ Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
96+ }
97+ }
98+ } catch {
99+ Write-Host "Download attempt $retryCount failed: $_"
100+ if ($retryCount -lt $maxRetries) {
101+ Start-Sleep -Seconds 2
102+ Remove-Item $cmakeZip -Force -ErrorAction SilentlyContinue
103+ } else {
104+ throw "Failed to download CMake after $maxRetries attempts: $_"
105+ }
106+ }
107+ }
108+
109+ # Verify it's a valid ZIP file by checking the header (ZIP files start with PK)
110+ $header = [System.IO.File]::ReadAllBytes($cmakeZip)[0..1]
111+ if (-not ($header[0] -eq 0x50 -and $header[1] -eq 0x4B)) {
112+ Write-Host "Warning: File may not be a valid ZIP. First bytes: $($header[0]), $($header[1])"
113+ Write-Host "Expected: 80, 75 (PK in hex)"
114+ throw "Downloaded file is not a valid ZIP archive"
115+ }
116+ Write-Host "ZIP file validation passed (PK header found)"
117+
118+ Write-Host "Extracting CMake to C:\Program Files"
119+ # Remove existing CMake directory if it exists
120+ if (Test-Path $cmakeDir) {
121+ Remove-Item $cmakeDir -Recurse -Force
122+ }
123+
124+ # Extract ZIP file
125+ Expand-Archive -Path $cmakeZip -DestinationPath "C:\Program Files" -Force
126+
127+ # Rename extracted folder to standard CMake directory name
128+ $extractedDir = "C:\Program Files\cmake-${cmakeVersion}-windows-${cmakeArch}"
129+ if (Test-Path $extractedDir) {
130+ Rename-Item -Path $extractedDir -NewName "CMake" -Force
131+ }
132+
133+ # Verify installation
134+ $cmakeExe = "$cmakeDir\bin\cmake.exe"
135+ if (Test-Path $cmakeExe) {
136+ Write-Host "CMake installed successfully"
137+ & $cmakeExe --version
138+ } else {
139+ throw "CMake installation verification failed: $cmakeExe not found"
140+ }
141+ shell : pwsh
142+
66143 - name : Get dependencies
67144 run : |
68145 Invoke-WebRequest -OutFile winflexbison.zip $env:WINFLEXBISON
69146 Expand-Archive winflexbison.zip -Destination C:\WinFlexBison
70147 Copy-Item -Path C:\WinFlexBison/win_bison.exe C:\WinFlexBison/bison.exe
71148 Copy-Item -Path C:\WinFlexBison/win_flex.exe C:\WinFlexBison/flex.exe
72149 echo "C:\WinFlexBison" | Out-File -FilePath $env:GITHUB_PATH -Append
73- choco install cmake.portable --version "${{ matrix.config.cmake_version }}" --force
74150 env :
75151 WINFLEXBISON : https://github.com/lexxmark/winflexbison/releases/download/v2.5.22/win_flex_bison-2.5.22.zip
76152 shell : pwsh
0 commit comments