mirror of
https://github.com/warpdotdev/warp.git
synced 2026-05-08 16:21:08 +08:00
## Description We have been saying that installing Visual Studio is required to build Warp. however, the whole thing isn't needed, just the MSVC Build Tools. That is available through winget and we can easily automate that in the script. ## Testing This worked when setting up a dev env on a new Windows device. --------- Co-authored-by: oz-for-oss[bot] <277970191+oz-for-oss[bot]@users.noreply.github.com>
72 lines
3.1 KiB
PowerShell
72 lines
3.1 KiB
PowerShell
#!/usr/bin/env powershell
|
|
|
|
$ErrorActionPreference = 'Stop'
|
|
|
|
# Git for Windows can be installed system-wide (Program Files) or per-user (LOCALAPPDATA\Programs\Git).
|
|
$gitBinCandidates = @(
|
|
"$env:PROGRAMFILES\Git\bin",
|
|
"$env:LOCALAPPDATA\Programs\Git\bin"
|
|
)
|
|
$gitBinDir = $gitBinCandidates | Where-Object { Test-Path -PathType Container $_ } | Select-Object -First 1
|
|
if (-not $gitBinDir) {
|
|
Write-Error 'Git for Windows is required. Please install it at:'
|
|
Write-Error 'https://gitforwindows.org/'
|
|
exit 1
|
|
}
|
|
|
|
if (-not (Get-Command -Name cargo -Type Application -ErrorAction SilentlyContinue)) {
|
|
Write-Output 'Installing rust...'
|
|
Invoke-WebRequest -Uri 'https://win.rustup.rs/x86_64' -OutFile "$env:Temp\rustup-init.exe"
|
|
& "$env:Temp\rustup-init.exe"
|
|
Write-Output 'Please start a new terminal session so that cargo is in your PATH'
|
|
exit 1
|
|
}
|
|
|
|
# Visual Studio Build Tools (MSVC compiler + linker + Windows SDK) are required to link Rust crates
|
|
# targeting x86_64-pc-windows-msvc.
|
|
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
|
|
$haveMsvcBuildTools = $false
|
|
if (Test-Path $vswhere) {
|
|
$vsInstall = & $vswhere -latest -products * `
|
|
-requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 Microsoft.VisualStudio.Component.Windows11SDK.22621 `
|
|
-property installationPath
|
|
if ($vsInstall) { $haveMsvcBuildTools = $true }
|
|
}
|
|
if (-not $haveMsvcBuildTools) {
|
|
Write-Output 'Installing Visual Studio Build Tools (MSVC + Windows SDK)...'
|
|
winget install -e --id Microsoft.VisualStudio.2022.BuildTools `
|
|
--accept-package-agreements --accept-source-agreements `
|
|
--override '--passive --wait --norestart --add Microsoft.VisualStudio.Workload.VCTools --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows11SDK.22621 --includeRecommended'
|
|
if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
|
|
}
|
|
|
|
# A bash executable should come with Git for Windows
|
|
& "$gitBinDir\bash.exe" "$PWD\script\install_cargo_test_deps"
|
|
|
|
# Needed in wasm compilation for parsing the version of wasm-bindgen
|
|
winget install jqlang.jq
|
|
|
|
# CMake is needed to build some dependencies, e.g.: sentry-contrib-native.
|
|
winget install -e --id Kitware.CMake
|
|
|
|
# We use InnoSetup to build our release bundle installer.
|
|
winget install -e --id JRSoftware.InnoSetup
|
|
|
|
# If we don't see gcloud command, try adding the install location to the PATH.
|
|
if (-not (Get-Command -Name gcloud -Type Application -ErrorAction SilentlyContinue)) {
|
|
$env:PATH += ";$env:LOCALAPPDATA\Google\Cloud SDK\google-cloud-sdk\bin"
|
|
}
|
|
|
|
# If we still don't see it, install it.
|
|
if (-not (Get-Command -Name gcloud -Type Application -ErrorAction SilentlyContinue)) {
|
|
(New-Object Net.WebClient).DownloadFile('https://dl.google.com/dl/cloudsdk/channels/rapid/GoogleCloudSDKInstaller.exe', "$env:Temp\GoogleCloudSDKInstaller.exe")
|
|
Start-Process "$env:Temp\GoogleCloudSDKInstaller.exe" -Wait
|
|
}
|
|
|
|
[string]$identityToken = gcloud auth print-identity-token
|
|
if ($identityToken.Trim().Length -eq 0) {
|
|
Write-Output 'gcloud CLI authentication missing. Press enter to continue...'
|
|
Read-Host
|
|
gcloud auth login
|
|
}
|