Repository navigation
Expand file tree
/
Copy pathbuild.ps1
More file actions
155 lines (134 loc) · 5.61 KB
/
Copy pathbuild.ps1
File metadata and controls
155 lines (134 loc) · 5.61 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
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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
# AutoDOS Build Script
# Run this from the AutoDOS folder:
# cd C:\path\to\AutoDOS
# .\build.ps1
param(
[string]$Config = "Release"
)
$ErrorActionPreference = "Stop"
$ProjectDir = $PSScriptRoot
Write-Host ""
Write-Host "=== AutoDOS Build Script ===" -ForegroundColor Cyan
Write-Host ""
# ── Check prerequisites ───────────────────────────────────────────────────────
# Check CMake
if (-not (Get-Command cmake -ErrorAction SilentlyContinue)) {
Write-Host "ERROR: CMake not found." -ForegroundColor Red
Write-Host "Download from: https://cmake.org/download/" -ForegroundColor Yellow
Write-Host "Make sure to check 'Add to PATH' during install." -ForegroundColor Yellow
exit 1
}
Write-Host "✓ CMake found: $(cmake --version | Select-Object -First 1)" -ForegroundColor Green
# Check Git (needed for FetchContent)
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
Write-Host "ERROR: Git not found." -ForegroundColor Red
Write-Host "Download from: https://git-scm.com/" -ForegroundColor Yellow
exit 1
}
Write-Host "✓ Git found" -ForegroundColor Green
# Check miniz
if (-not (Test-Path "$ProjectDir\src\miniz.h") -or -not (Test-Path "$ProjectDir\src\miniz.c")) {
Write-Host ""
Write-Host "ERROR: miniz not found in src\" -ForegroundColor Red
Write-Host ""
Write-Host "Download miniz from:" -ForegroundColor Yellow
Write-Host " https://github.com/richgel999/miniz/releases/latest" -ForegroundColor Cyan
Write-Host ""
Write-Host "Download miniz.h and miniz.c and place both in:" -ForegroundColor Yellow
Write-Host " $ProjectDir\src\" -ForegroundColor Cyan
Write-Host ""
Write-Host "Then run this script again." -ForegroundColor Yellow
exit 1
}
Write-Host "✓ miniz found" -ForegroundColor Green
# Check games.json
if (-not (Test-Path "$ProjectDir\src\games.json")) {
Write-Host ""
Write-Host "WARNING: games.json not found in src\" -ForegroundColor Yellow
Write-Host "Copy it from your CARTRIDGE install:" -ForegroundColor Yellow
Write-Host " CARTRIDGE-v0.4.1 (39)\cartridge\rom\games.json" -ForegroundColor Cyan
Write-Host " → $ProjectDir\src\games.json" -ForegroundColor Cyan
Write-Host ""
Write-Host "Continuing without it (AutoDOS will use scorer only)..." -ForegroundColor Yellow
}
# Check DOSBox
if (-not (Test-Path "$ProjectDir\dosbox\dosbox.exe")) {
Write-Host ""
Write-Host "WARNING: dosbox\dosbox.exe not found." -ForegroundColor Yellow
Write-Host "Copy DOSBox Staging from your CARTRIDGE install:" -ForegroundColor Yellow
Write-Host " CARTRIDGE-v0.4.1 (39)\cartridge\native\dosbox-staging-win\" -ForegroundColor Cyan
Write-Host " → $ProjectDir\dosbox\" -ForegroundColor Cyan
Write-Host ""
Write-Host "Continuing build (you can add DOSBox later)..." -ForegroundColor Yellow
}
# ── Build ─────────────────────────────────────────────────────────────────────
Write-Host ""
Write-Host "Building AutoDOS ($Config)..." -ForegroundColor Cyan
$BuildDir = "$ProjectDir\build"
New-Item -ItemType Directory -Force -Path $BuildDir | Out-Null
# Configure
Write-Host ""
Write-Host "Configuring with CMake..." -ForegroundColor White
Push-Location $BuildDir
try {
cmake .. -G "Visual Studio 17 2022" -A x64
if ($LASTEXITCODE -ne 0) {
# Try VS 2019
cmake .. -G "Visual Studio 16 2019" -A x64
}
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: CMake configuration failed." -ForegroundColor Red
Write-Host "Make sure Visual Studio is installed with C++ workload." -ForegroundColor Yellow
exit 1
}
} finally {
Pop-Location
}
# Build
Write-Host ""
Write-Host "Compiling..." -ForegroundColor White
Push-Location $BuildDir
try {
cmake --build . --config $Config --parallel
if ($LASTEXITCODE -ne 0) {
Write-Host "ERROR: Build failed." -ForegroundColor Red
exit 1
}
} finally {
Pop-Location
}
# ── Package output ────────────────────────────────────────────────────────────
$ExePath = "$BuildDir\bin\$Config\AutoDOS.exe"
if (-not (Test-Path $ExePath)) {
# Try alternate output location
$ExePath = "$BuildDir\$Config\AutoDOS.exe"
}
if (Test-Path $ExePath) {
$OutDir = "$ProjectDir\dist"
New-Item -ItemType Directory -Force -Path $OutDir | Out-Null
Copy-Item $ExePath "$OutDir\AutoDOS.exe" -Force
# Copy games.json if available
if (Test-Path "$ProjectDir\src\games.json") {
Copy-Item "$ProjectDir\src\games.json" "$OutDir\games.json" -Force
}
# Copy DOSBox if available
if (Test-Path "$ProjectDir\dosbox\dosbox.exe") {
$dosboxDist = "$OutDir\dosbox"
New-Item -ItemType Directory -Force -Path $dosboxDist | Out-Null
Copy-Item "$ProjectDir\dosbox\*" $dosboxDist -Recurse -Force
}
Write-Host ""
Write-Host "=== Build successful! ===" -ForegroundColor Green
Write-Host ""
Write-Host "Output: $OutDir\AutoDOS.exe" -ForegroundColor Cyan
Write-Host ""
Write-Host "To run:" -ForegroundColor White
Write-Host " cd $OutDir" -ForegroundColor Cyan
Write-Host " .\AutoDOS.exe" -ForegroundColor Cyan
Write-Host ""
} else {
Write-Host ""
Write-Host "ERROR: AutoDOS.exe not found after build." -ForegroundColor Red
Write-Host "Check build output above for errors." -ForegroundColor Yellow
exit 1
}