Skip to content

Commit

Permalink
Use vs_buildtools directly instead of choco to install toolchain
Browse files Browse the repository at this point in the history
  • Loading branch information
zanieb committed Jan 8, 2025
1 parent 3a5469e commit c31d6ff
Showing 1 changed file with 88 additions and 6 deletions.
94 changes: 88 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,7 @@ jobs:

build-binary-windows-aarch64:
needs: determine_changes
timeout-minutes: 30
timeout-minutes: 45
if: ${{ github.repository == 'astral-sh/uv' && !contains(github.event.pull_request.labels.*.name, 'no-test') && (needs.determine_changes.outputs.code == 'true' || github.ref == 'refs/heads/main') }}
runs-on:
labels: github-windows-11-aarch64-4
Expand All @@ -578,14 +578,96 @@ jobs:
run: |
Start-Process -FilePath "LLVM-19.1.5-woa64.exe" -ArgumentList '/S' -NoNewWindow -Wait
- name: Install Build Tools (aarch64)
- name: Cache VS Build Tools Packages
uses: actions/cache@v3
with:
path: C:\ProgramData\Microsoft\VisualStudio\Packages
key: vs-build-tools-${{ runner.os }}-aarch64

- name: Cache VS Build Tools Packages
id: cache-vs-build-tools
uses: actions/cache@v3
with:
path: |
C:\ProgramData\Microsoft\VisualStudio\Packages
C:\Program Files (x86)\Microsoft Visual Studio
key: vs-build-tools-${{ runner.os }}-aarch64

- name: Install Build Tools (ARM64)
run: |
Set-ExecutionPolicy Bypass -Scope Process -Force
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072
iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
Add-Content -Path $env:GITHUB_PATH -Value "C:\ProgramData\chocolatey\bin" -Encoding utf8
choco install visualstudio2022buildtools -y --no-progress --package-parameters "--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --add Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang --add Microsoft.VisualStudio.Component.VC.CMake.Project"
choco cache list -v
Write-Host "Downloading VS Build Tools..."
Invoke-WebRequest -Uri https://aka.ms/vs/17/release/vs_buildtools.exe -OutFile vs_buildtools.exe -Verbose
Write-Host "Starting installation..."
$process = Start-Process -FilePath .\vs_buildtools.exe -ArgumentList @(
"--quiet",
"--norestart",
"--nocache",
"--wait",
"--installPath", "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools",
"--add", "Microsoft.VisualStudio.Workload.VCTools",
"--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"--add", "Microsoft.VisualStudio.Component.Windows11SDK.22621",
"--add", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang",
"--add", "Microsoft.VisualStudio.Component.VC.CMake.Project"
) -NoNewWindow -Wait -PassThru
$exitCode = $process.ExitCode
Write-Host "Installation completed with exit code: $exitCode"
# Run modify instead of repair if cache was restored
if ("${{ steps.cache-vs-build-tools.outputs.cache-hit }}" -eq 'true') {
Write-Host "Cache was restored - running modify to ensure components..."
$process = Start-Process -FilePath .\vs_buildtools.exe -ArgumentList @(
"--quiet",
"--norestart",
"--wait",
"modify",
"--installPath", "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools",
"--add", "Microsoft.VisualStudio.Workload.VCTools",
"--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"--add", "Microsoft.VisualStudio.Component.Windows11SDK.22621",
"--add", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang",
"--add", "Microsoft.VisualStudio.Component.VC.CMake.Project"
) -NoNewWindow -Wait -PassThru
$exitCode = $process.ExitCode
Write-Host "Modify completed with exit code: $exitCode"
if ($exitCode -ne 0) {
Write-Host "Modify failed - attempting full reinstall..."
$process = Start-Process -FilePath .\vs_buildtools.exe -ArgumentList @(
"--quiet",
"--norestart",
"--wait",
"--force", # Force a new installation
"--installPath", "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools",
"--add", "Microsoft.VisualStudio.Workload.VCTools",
"--add", "Microsoft.VisualStudio.Component.VC.Tools.ARM64",
"--add", "Microsoft.VisualStudio.Component.Windows11SDK.22621",
"--add", "Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Llvm.Clang",
"--add", "Microsoft.VisualStudio.Component.VC.CMake.Project"
) -NoNewWindow -Wait -PassThru
$exitCode = $process.ExitCode
Write-Host "Reinstall completed with exit code: $exitCode"
}
}
# Verify clang installation
$clangPath = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin\clang.exe"
if (Test-Path $clangPath) {
Write-Host "Clang found at: $clangPath"
& $clangPath --version
} else {
Write-Host "Clang not found at expected location: $clangPath"
Write-Host "Directory contents:"
Get-ChildItem "${env:ProgramFiles(x86)}\Microsoft Visual Studio\2022\BuildTools\VC\Tools" -Recurse | Select-Object FullName
exit 1
}
- name: Add clang to PATH and check if clang exists
run: |
Expand Down

0 comments on commit c31d6ff

Please sign in to comment.