1
0

install-deps.ps1 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <#
  2. .Description
  3. The script installs binaries needed to build and run crosvm, including rust toolchain and protoc,
  4. in User's temp directory and sets up system environment variables.
  5. .PARAMETER BASE_DIR
  6. Determines where the binaries will be installed. This defaults to user's temp directory.
  7. #>
  8. param (
  9. [Parameter(
  10. Position = 0
  11. )]
  12. [string]$BASE_DIR = $Env:TEMP ##
  13. )
  14. $BASE_DIR = $BASE_DIR + "\"
  15. $PROTOC_VERSION = '21.12'
  16. $PROTOC_SHA256 = "71852A30CF62975358EDFCBBFF93086E8857A079C8E4D6904881AA968D65C7F9"
  17. $PROTOC_URL = "https://github.com/protocolbuffers/protobuf/releases/download/v$PROTOC_VERSION/protoc-$PROTOC_VERSION-win64.zip"
  18. $PROTOC_ZIP = $BASE_DIR + 'protoc.zip'
  19. $PROTOC_DIR = $BASE_DIR + 'protoc\'
  20. $RUSTUP_INIT_VERSION = '1.25.1'
  21. $RUSTUP_INIT_SHA256 = "2220DDB49FEA0E0945B1B5913E33D66BD223A67F19FD1C116BE0318DE7ED9D9C"
  22. $RUSTUP_INIT_URL = "https://static.rust-lang.org/rustup/archive/$RUSTUP_INIT_VERSION/x86_64-pc-windows-msvc/rustup-init.exe"
  23. $RUSTUP_INIT = $BASE_DIR + 'rustup-init.exe'
  24. $CARGO_BINSTALL_VERSION = 'v0.19.3'
  25. $CARGO_BINSTALL_URL = "https://github.com/cargo-bins/cargo-binstall/releases/download/$CARGO_BINSTALL_VERSION/cargo-binstall-x86_64-pc-windows-msvc.zip"
  26. Write-Host "Installing in $BASE_DIR"
  27. if (!(Test-Path $BASE_DIR -PathType Container)) {
  28. New-Item -ItemType Directory -Force -Path $BASE_DIR
  29. }
  30. Set-Location $BASE_DIR
  31. # Install protobuf compiler
  32. Invoke-WebRequest $PROTOC_URL -Out $PROTOC_ZIP
  33. Write-Host "Verifying protoc integrity"
  34. if ((Get-FileHash $PROTOC_ZIP -Algorithm SHA256).Hash -ne $PROTOC_SHA256)
  35. {
  36. Write-Host "$PROTOC_ZIP sha did not match"
  37. Break
  38. }
  39. Expand-Archive -Path $PROTOC_ZIP -DestinationPath $PROTOC_DIR
  40. $Env:PATH = $Env:PATH + ";" + $PROTOC_DIR + "bin\"
  41. # Update PATH to contain protobuf and depot_tools directory
  42. [Environment]::SetEnvironmentVariable("Path", $Env:PATH, [System.EnvironmentVariableTarget]::User)
  43. # Download rustup-init that helps setting up rustup and rust toolchain.
  44. # Install protobuf compiler
  45. Invoke-WebRequest $RUSTUP_INIT_URL -Out $RUSTUP_INIT
  46. Write-Host "Verifying rustup_init integrity"
  47. if ((Get-FileHash $RUSTUP_INIT -Algorithm SHA256).Hash -ne $RUSTUP_INIT_SHA256)
  48. {
  49. Write-Host "$RUSTUP_INIT sha did not match"
  50. Break
  51. }
  52. # Install rustup and rust toolchain
  53. & $RUSTUP_INIT
  54. # Update PATH to to contain cargo home directory.
  55. [Environment]::SetEnvironmentVariable("Path", $Env:PATH, [System.EnvironmentVariableTarget]::User)
  56. # Cargo extension to install binary packages from github
  57. $BINSTALL_ZIP = New-TemporaryFile
  58. Invoke-WebRequest $CARGO_BINSTALL_URL -Out $BINSTALL_ZIP
  59. $BINSTALL_DEST=((Get-Command cargo) | Get-Item).DirectoryName
  60. Expand-Archive -Path $BINSTALL_ZIP -DestinationPath $BINSTALL_DEST
  61. # Nextest is an improved test runner for cargo
  62. cargo binstall --no-confirm cargo-nextest --version "0.9.49"