aboutsummaryrefslogtreecommitdiff
path: root/build.ps1
blob: 12b63eed788dfc03f729d65de0a351bf8b5c4940 (plain) (blame)
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# dmvop build script
# Safe to run from anywhere — navigates to script dir and restores on exit.

$ScriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$OrigDir = Get-Location

# Restore original directory on any exit
trap { Set-Location $OrigDir; break }

Set-Location $ScriptDir
Write-Host "=== Building dmvop ===" -ForegroundColor Cyan

$BuildDir = Join-Path (Get-Location) "build"
$ReleaseDir = Join-Path (Get-Location) "target\release"

cargo build --release
if ($LASTEXITCODE -ne 0) {
    Write-Host "Build failed!" -ForegroundColor Red
    Set-Location $OrigDir
    exit 1
}

# Build manager GUI
Write-Host "=== Building dmvop-gui ===" -ForegroundColor Cyan
dotnet publish manager/manager.csproj -c Release -o manager/publish
if ($LASTEXITCODE -ne 0) {
    Write-Host "GUI build failed!" -ForegroundColor Red
    Set-Location $OrigDir
    exit 1
}

# Create build directory
if (-not (Test-Path $BuildDir)) {
    New-Item -ItemType Directory -Path $BuildDir | Out-Null
}

Write-Host "=== Copying files ===" -ForegroundColor Cyan

# 1. dmvop.exe
Copy-Item (Join-Path $ReleaseDir "dmvop.exe") (Join-Path $BuildDir "dmvop.exe") -Force
Write-Host "  [OK] dmvop.exe"

# 1.5. gui launcher
$LauncherSrc = Join-Path (Get-Location) "manager\launcher\dmvop-gui.exe"
if (Test-Path $LauncherSrc) {
    Copy-Item $LauncherSrc (Join-Path $BuildDir "dmvop-gui.exe") -Force
    Write-Host "  [OK] dmvop-gui.exe"
}

# 1.6. gui
$GuiSrc = Join-Path (Get-Location) "manager\publish"
$GuiDst = Join-Path $BuildDir "gui"
if (Test-Path (Join-Path $GuiSrc "manager.exe")) {
    if (-not (Test-Path $GuiDst)) { New-Item -ItemType Directory -Path $GuiDst | Out-Null }
    Copy-Item "$GuiSrc\*" $GuiDst -Recurse -Force
    Write-Host "  [OK] gui\"
}

# 2. CUDA backend
$CudaSrc = Join-Path $ReleaseDir "cuda"
$CudaDst = Join-Path $BuildDir "cuda"
if (Test-Path $CudaSrc) {
    if (-not (Test-Path $CudaDst)) { New-Item -ItemType Directory -Path $CudaDst | Out-Null }
    Copy-Item (Join-Path $CudaSrc "*") $CudaDst -Force
    Write-Host "  [OK] cuda\"
}

# 3. CPU backend
$CpuSrc = Join-Path $ReleaseDir "cpu"
$CpuDst = Join-Path $BuildDir "cpu"
if (Test-Path $CpuSrc) {
    if (-not (Test-Path $CpuDst)) { New-Item -ItemType Directory -Path $CpuDst | Out-Null }
    Copy-Item (Join-Path $CpuSrc "*") $CpuDst -Force
    Write-Host "  [OK] cpu\"
}

# 4. dmvop.toml
$TomlSrc = Join-Path (Get-Location) "dmvop.toml"
if (Test-Path $TomlSrc) {
    Copy-Item $TomlSrc (Join-Path $BuildDir "dmvop.toml") -Force
    Write-Host "  [OK] dmvop.toml"
}

# 5. LICENSE
$LicenseSrc = Join-Path (Get-Location) "LICENSE"
if (Test-Path $LicenseSrc) {
    Copy-Item $LicenseSrc (Join-Path $BuildDir "LICENSE") -Force
    Write-Host "  [OK] LICENSE"
}

# 6. README.md
$ReadmeSrc = Join-Path (Get-Location) "README.md"
if (Test-Path $ReadmeSrc) {
    Copy-Item $ReadmeSrc (Join-Path $BuildDir "README.md") -Force
    Write-Host "  [OK] README.md"
}

Write-Host "=== Done! Build output in: $BuildDir ===" -ForegroundColor Green
Write-Host ""
Write-Host "Contents:" -ForegroundColor Cyan
Get-ChildItem $BuildDir -Recurse | ForEach-Object { "  $($_.Name)" }

# Restore original directory
Set-Location $OrigDir