crosvm/tools/install-deps.ps1
Vikram Auradkar 69429106d0 tools: add script to setup rust toolchain and other dependencies
BUG=b:264555939
TEST= ran the script on a non-crop windows machine

Change-Id: Ib615b45137f5da73be511d29f6655946d78455fe
Reviewed-on: https://chromium-review.googlesource.com/c/crosvm/crosvm/+/4149727
Reviewed-by: Dennis Kempin <denniskempin@google.com>
Commit-Queue: Vikram Auradkar <auradkar@google.com>
2023-01-12 23:25:39 +00:00

61 lines
2.1 KiB
PowerShell

<#
.Description
The script installs binaries needed to build and run crosvm, including rust toolchain and protoc,
in User's temp directory and sets up system environment variables.
.PARAMETER BASE_DIR
Determines where the binaries will be installed. This defaults to user's temp directory.
#>
param (
[Parameter(
Position = 0
)]
[string]$BASE_DIR = $Env:TEMP ##
)
$BASE_DIR = $BASE_DIR + "\"
$PROTOC_VERSION = '21.12'
$PROTOC_SHA256 = "71852A30CF62975358EDFCBBFF93086E8857A079C8E4D6904881AA968D65C7F9"
$PROTOC_URL = "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-win64.zip"
$PROTOC_ZIP = $BASE_DIR + 'protoc.zip'
$PROTOC_DIR = $BASE_DIR + 'protoc\'
$RUSTUP_INIT_VERSION = '1.25.1'
$RUSTUP_INIT_SHA256 = "2220DDB49FEA0E0945B1B5913E33D66BD223A67F19FD1C116BE0318DE7ED9D9C"
$RUSTUP_INIT_URL = "https://static.rust-lang.org/rustup/archive/$RUSTUP_INIT_VERSION/x86_64-pc-windows-msvc/rustup-init.exe"
$RUSTUP_INIT = $BASE_DIR + 'rustup-init.exe'
Write-Host "Installing in $BASE_DIR"
if (!(Test-Path $BASE_DIR -PathType Container)) {
New-Item -ItemType Directory -Force -Path $BASE_DIR
}
Set-Location $BASE_DIR
# Install protobuf compiler
Invoke-WebRequest $PROTOC_URL -Out $PROTOC_ZIP
Write-Host "Verifying protoc integrity"
if ((Get-FileHash $PROTOC_ZIP -Algorithm SHA256).Hash -ne $PROTOC_SHA256)
{
Write-Host "$PROTOC_ZIP sha did not match"
Break
}
Expand-Archive -Path $PROTOC_ZIP -DestinationPath $PROTOC_DIR
$Env:PATH = $Env:PATH + ";" + $PROTOC_DIR + "bin\"
# Update PATH to contain protobuf and depot_tools directory
[Environment]::SetEnvironmentVariable("Path", $Env:PATH, [System.EnvironmentVariableTarget]::User)
# Download rustup-init that helps setting up rustup and rust toolchain.
# Install protobuf compiler
Invoke-WebRequest $RUSTUP_INIT_URL -Out $RUSTUP_INIT
Write-Host "Verifying rustup_init integrity"
if ((Get-FileHash $RUSTUP_INIT -Algorithm SHA256).Hash -ne $RUSTUP_INIT_SHA256)
{
Write-Host "$RUSTUP_INIT sha did not match"
Break
}
# Install rustup and rust toolchain
& $RUSTUP_INIT