1$ErrorActionPreference = "Stop"
2
3$HAKARI_VERSION = "0.9"
4
5$scriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path
6Set-Location (Split-Path -Parent $scriptPath)
7
8$hakariInstalled = $false
9try {
10 $versionOutput = cargo hakari --version 2>&1
11 if ($versionOutput -match "cargo-hakari $HAKARI_VERSION") {
12 $hakariInstalled = $true
13 }
14}
15catch {
16 $hakariInstalled = $false
17}
18
19if (-not $hakariInstalled) {
20 Write-Host "Installing cargo-hakari@^$HAKARI_VERSION..."
21 cargo install "cargo-hakari@^$HAKARI_VERSION"
22 if ($LASTEXITCODE -ne 0) {
23 throw "Failed to install cargo-hakari@^$HAKARI_VERSION"
24 }
25}
26else {
27 Write-Host "cargo-hakari@^$HAKARI_VERSION is already installed."
28}
29
30# update the workspace-hack crate
31cargo hakari generate
32if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }
33
34# make sure workspace-hack is added as a dep for all crates in the workspace
35cargo hakari manage-deps
36if ($LASTEXITCODE -ne 0) { exit $LASTEXITCODE }