Repository navigation
Expand file tree
/
Copy pathinstall-dependencies.ps1
More file actions
executable file
·73 lines (61 loc) · 2.62 KB
/
Copy pathinstall-dependencies.ps1
File metadata and controls
executable file
·73 lines (61 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
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"
}