# ============================================================ # CBE Emulator - Windows build script (PowerShell) # Run on Windows with JDK 14+ installed. # Usage: # .\build-windows.ps1 # builds app-image (folder with .exe) # .\build-windows.ps1 -Type msi # builds MSI installer # .\build-windows.ps1 -Type exe # builds EXE installer # ============================================================ param( [ValidateSet('app-image', 'msi', 'exe')] [string]$Type = 'app-image' ) $ErrorActionPreference = 'Stop' Set-Location $PSScriptRoot Write-Host "" Write-Host "=== CBE Emulator - Windows build ===" -ForegroundColor Cyan Write-Host "" # 1. Build Write-Host "[1/4] Building Gradle project..." -ForegroundColor Yellow & .\gradlew.bat :modules:gui:stage --no-daemon if ($LASTEXITCODE -ne 0) { Write-Error "Gradle build failed"; exit 1 } # 2. Detect jpackage $jpackage = (Get-Command jpackage -ErrorAction SilentlyContinue) if (-not $jpackage) { Write-Error "jpackage not found in PATH. Please install JDK 14+." exit 1 } # 3. jpackage $stageDir = "modules\gui\build\stage" $outDir = "build\installer" if (Test-Path $outDir) { Remove-Item -Recurse -Force $outDir } New-Item -ItemType Directory -Path $outDir | Out-Null Write-Host "[2/4] Running jpackage (type=$Type)..." -ForegroundColor Yellow & jpackage ` --input $stageDir ` --dest $outDir ` --name CBE-Emulator ` --main-jar cbe-emu.jar ` --main-class com.cbe.gui.Main ` --app-version 0.1.0 ` --vendor "CBE Project" ` --description "CBE Platform - Emulator" ` --type $Type ` --java-options "-Xmx256m" if ($LASTEXITCODE -ne 0) { Write-Error "jpackage failed"; exit 1 } Write-Host "[3/4] Output:" -ForegroundColor Green Get-ChildItem $outDir | ForEach-Object { Write-Host " $($_.FullName)" } # 4. Stage example plugins $pluginsDir = "build\plugins" if (-not (Test-Path $pluginsDir)) { New-Item -ItemType Directory -Path $pluginsDir | Out-Null } Copy-Item "examples\tiny-cpu.cpu\*" -Recurse -Force -Destination $pluginsDir Copy-Item "examples\basic-ram.ram\*" -Recurse -Force -Destination $pluginsDir Copy-Item "examples\vga-display.gpu\*" -Recurse -Force -Destination $pluginsDir Write-Host "" Write-Host "[4/4] Done." -ForegroundColor Green Write-Host "Installer/output: $outDir" -ForegroundColor Green Write-Host "Example plugins: $pluginsDir" -ForegroundColor Green Write-Host "" Write-Host "For app-image type, the launcher is at:" -ForegroundColor Cyan Write-Host " $outDir\CBE-Emulator\CBE-Emulator.exe" -ForegroundColor White