-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild_wsl.ps1
More file actions
59 lines (50 loc) · 1.98 KB
/
build_wsl.ps1
File metadata and controls
59 lines (50 loc) · 1.98 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# =========================================================
# GraphBrew WSL Build Helper
# =========================================================
# Wraps make commands to run inside WSL from PowerShell.
#
# Usage:
# .\build_wsl.ps1 all # Build all kernels
# .\build_wsl.ps1 clean # Clean build artifacts
# .\build_wsl.ps1 run-bfs # Run BFS benchmark
# .\build_wsl.ps1 run-pr # Run PageRank benchmark
# .\build_wsl.ps1 all RABBIT_ENABLE=0 # Build without RabbitOrder
# .\build_wsl.ps1 help # Show make help
# .\build_wsl.ps1 shell # Open WSL shell in project dir
# =========================================================
param(
[Parameter(Position=0)]
[string]$Target = "all",
[Parameter(Position=1, ValueFromRemainingArguments=$true)]
[string[]]$ExtraArgs
)
$distro = "Ubuntu-24.04"
# Convert Windows path to WSL path
$winPath = (Get-Location).Path
$wslPath = wsl -d $distro -- wslpath -u "$winPath" 2>&1
if ($LASTEXITCODE -ne 0) {
# Fallback: manual conversion
$wslPath = $winPath -replace '\\', '/'
$wslPath = $wslPath -replace '^([A-Za-z]):', { "/mnt/" + $_.Groups[1].Value.ToLower() }
}
# Special case: open an interactive shell
if ($Target -eq "shell") {
Write-Host "Opening WSL shell in $wslPath ..." -ForegroundColor Cyan
wsl -d $distro -- bash -c "cd '$wslPath' && exec bash"
exit $LASTEXITCODE
}
# Build the make command
$makeArgs = @($Target) + $ExtraArgs
$makeCmd = "make " + ($makeArgs -join " ")
Write-Host "[GraphBrew] Running: $makeCmd" -ForegroundColor Cyan
Write-Host "[GraphBrew] Directory: $wslPath" -ForegroundColor DarkGray
Write-Host ""
wsl -d $distro -- bash -c "cd '$wslPath' && $makeCmd"
if ($LASTEXITCODE -eq 0) {
Write-Host ""
Write-Host "[GraphBrew] Success!" -ForegroundColor Green
} else {
Write-Host ""
Write-Host "[GraphBrew] Failed (exit code: $LASTEXITCODE)" -ForegroundColor Red
exit $LASTEXITCODE
}