Raw
1 param(
2 [string]$DownloadDirectory = '.dependencies'
3 )
4
5 $ErrorActionPreference = 'Stop'
6 $ProgressPreference = 'SilentlyContinue'
7
8 $GitVersion = '2.54.0.windows.1'
9 $MesonVersion = '1.11.0'
10 $RustVersion = '1.96.0'
11
12 New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null
13 New-Item -Path .git/info -ItemType Directory -Force | Out-Null
14 New-Item -Path .git/info/exclude -ItemType File -Force | Out-Null
15 Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory"
16
17 function Get-Installer {
18 param(
19 [Parameter(Mandatory = $true)][string]$Name,
20 [Parameter(Mandatory = $true)][string]$Url
21 )
22
23 $path = Join-Path $DownloadDirectory $Name
24 if (-not (Test-Path $path)) {
25 Write-Host "Downloading $Url"
26 Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300
27 }
28 return $path
29 }
30
31 function Invoke-Installer {
32 param(
33 [Parameter(Mandatory = $true)][string]$FilePath,
34 [Parameter(Mandatory = $true)][string[]]$ArgumentList
35 )
36
37 Write-Host "Running $FilePath $($ArgumentList -join ' ')"
38 $process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList
39 if ($process.ExitCode -ne 0) {
40 throw "$FilePath failed with exit code $($process.ExitCode)"
41 }
42 }
43
44 $gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', ''
45 $gitInstaller = Get-Installer "Git-Installer.exe" `
46 "https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe"
47 Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"')
48
49 $mesonMsi = Get-Installer "meson.msi" `
50 "https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi"
51 Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart')
52
53 $rustMsi = Get-Installer "rust.msi" `
54 "https://static.rust-lang.org/dist/rust-$RustVersion-x86_64-pc-windows-msvc.msi"
55 Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust', 'ADDLOCAL=Rustc,Cargo,Std', '/quiet', '/norestart')