Skip to content

Commit 72e44aa

Browse files
author
Maik Roland Damm
committed
fix(setup): update script paths in setup scripts for consistency
1 parent 2d98dfe commit 72e44aa

3 files changed

Lines changed: 38 additions & 5 deletions

File tree

scripts/setup/setup-linux.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WITH_BUNDLE=0
1010
WARNINGS=()
1111

1212
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13-
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13+
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
1414

1515
if [[ -t 1 ]] && command -v tput >/dev/null 2>&1; then
1616
BOLD="$(tput bold)"
@@ -32,7 +32,7 @@ fi
3232

3333
usage() {
3434
cat <<'EOF'
35-
Usage: ./scripts/setup-linux.sh [options]
35+
Usage: ./scripts/setup/setup-linux.sh [options]
3636
3737
Set up BLXCode after a git clone on Linux. Supports apt, dnf, and pacman.
3838

scripts/setup/setup-macos.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WITH_BUNDLE=0
1010
WARNINGS=()
1111

1212
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
13-
ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
13+
ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
1414

1515
if [[ -t 1 ]] && command -v tput >/dev/null 2>&1; then
1616
BOLD="$(tput bold)"
@@ -32,7 +32,7 @@ fi
3232

3333
usage() {
3434
cat <<'EOF'
35-
Usage: ./scripts/setup-macos.sh [options]
35+
Usage: ./scripts/setup/setup-macos.sh [options]
3636
3737
Set up BLXCode after a git clone on macOS.
3838

scripts/setup/setup-windows.ps1

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ $SkipSystem = $false
77
$NoVerify = $false
88
$WithBundle = $false
99
$Warnings = New-Object System.Collections.Generic.List[string]
10+
$MinVerifyFreeBytes = [int64](10GB)
1011

1112
$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
1213
$Root = Split-Path -Parent (Split-Path -Parent $ScriptDir)
1314

1415
function Show-Usage {
1516
@"
16-
Usage: powershell -ExecutionPolicy Bypass -File scripts/setup-windows.ps1 [options]
17+
Usage: powershell -ExecutionPolicy Bypass -File scripts/setup/setup-windows.ps1 [options]
1718
1819
Set up BLXCode after a git clone on Windows.
1920
@@ -77,6 +78,34 @@ function Test-Command([string]$Name) {
7778
return $null -ne (Get-Command $Name -ErrorAction SilentlyContinue)
7879
}
7980

81+
function Format-ByteSize([int64]$Bytes) {
82+
if ($Bytes -ge 1GB) {
83+
return "{0:N1} GiB" -f ($Bytes / 1GB)
84+
}
85+
if ($Bytes -ge 1MB) {
86+
return "{0:N0} MiB" -f ($Bytes / 1MB)
87+
}
88+
return "$Bytes bytes"
89+
}
90+
91+
function Assert-FreeDiskSpace([string]$Path, [int64]$MinBytes, [string]$Purpose) {
92+
$Resolved = Resolve-Path -LiteralPath $Path -ErrorAction Stop
93+
$Qualifier = Split-Path -Qualifier $Resolved.Path
94+
if (-not $Qualifier) {
95+
return
96+
}
97+
$DriveName = $Qualifier.TrimEnd(":\")
98+
$Drive = Get-PSDrive -Name $DriveName -ErrorAction SilentlyContinue
99+
if ($null -eq $Drive) {
100+
return
101+
}
102+
if ($Drive.Free -lt $MinBytes) {
103+
$FreeText = Format-ByteSize $Drive.Free
104+
$NeedText = Format-ByteSize $MinBytes
105+
throw "Not enough free disk space for $Purpose on $Qualifier. Free: $FreeText; required: $NeedText. Run 'cargo clean', delete old build artifacts, or re-run with --no-verify after installing prerequisites."
106+
}
107+
}
108+
80109
function Invoke-Step([string]$Description, [scriptblock]$Action) {
81110
Write-Host " + $Description" -ForegroundColor DarkGray
82111
if ($script:CheckOnly) {
@@ -303,6 +332,10 @@ function Run-Verification {
303332
return
304333
}
305334

335+
if (-not $script:CheckOnly) {
336+
Assert-FreeDiskSpace $Root $script:MinVerifyFreeBytes "cargo/trunk verification"
337+
}
338+
306339
Push-Location $Root
307340
try {
308341
Invoke-Step "cargo check -p blxcode" {

0 commit comments

Comments
 (0)