Files
git-mirror/ci/install-dependencies.ps1
Junio C Hamano d3c33f0b3e Merge branch 'ps/meson-improvements' into seen
The build configurations for Meson have been optimized to avoid
recompiling HTTP sources multiple times and to utilize precompiled
headers for test-helpers and unit tests, reducing clean build times.
Additionally, the shell completion tests and GitLab CI MSVC runner
jobs have been fixed.

* ps/meson-improvements:
  gitlab-ci: fix hanging MSVC jobs
  meson: update wrappers
  meson: fix outdated completion helpers
  meson: use precompiled headers for unit tests
  meson: use precompiled headers for our test-helper
  meson: don't recompile git-remote-http(1) multiple times for tests
  meson: avoid recompiling HTTP sources several times
2026-09-27 15:01:05 -07:00

74 lines
2.6 KiB
PowerShell
Executable File

param(
[string]$DownloadDirectory = '.dependencies',
[switch]$Mingw
)
$ErrorActionPreference = 'Stop'
$ProgressPreference = 'SilentlyContinue'
$GitVersion = '2.54.0.windows.1'
$MesonVersion = '1.11.0'
$RustVersion = '1.96.0'
New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null
New-Item -Path .git/info -ItemType Directory -Force | Out-Null
if (-not (Test-Path .git/info/exclude)) {
New-Item -Path .git/info/exclude -ItemType File | Out-Null
}
Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory"
function Get-Installer {
param(
[Parameter(Mandatory = $true)][string]$Name,
[Parameter(Mandatory = $true)][string]$Url
)
$path = Join-Path $DownloadDirectory $Name
if (-not (Test-Path $path)) {
Write-Host "Downloading $Url"
Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300
}
return $path
}
function Invoke-Installer {
param(
[Parameter(Mandatory = $true)][string]$FilePath,
[Parameter(Mandatory = $true)][string[]]$ArgumentList
)
Write-Host "Running $FilePath $($ArgumentList -join ' ')"
$process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList
if ($process.ExitCode -ne 0) {
throw "$FilePath failed with exit code $($process.ExitCode)"
}
}
$rustTarget = if ($Mingw) { 'gnu' } else { 'msvc' }
$rustMsi = Get-Installer "rust-$rustTarget.msi" (
"https://static.rust-lang.org/dist/" +
"rust-$RustVersion-x86_64-pc-windows-$rustTarget.msi")
Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust',
"ADDLOCAL=Rustc,Cargo,Std$(if ($Mingw) { ',Gcc' })", '/quiet', '/norestart')
if ($Mingw) {
return
}
$gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', ''
$gitInstaller = Get-Installer "Git-Installer.exe" `
"https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe"
Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"')
$mesonMsi = Get-Installer "meson.msi" `
"https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi"
Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart')
# Disable Git Credential Manager, which is auto-configured by PortableGit.
# GitLab's runner picks up this Git in its cleanup stage and runs `git
# credential reject`, which hangs in GCM and makes the job time out.
& "C:\Program Files\Git\bin\git.exe" config unset --all --system credential.helper
if ($LASTEXITCODE -ne 0 -and $LASTEXITCODE -ne 5) {
throw "Failed to unset credential.helper with exit code $LASTEXITCODE"
}