Monorepo for Aesthetic.Computer
aesthetic.computer
1# Local Windows Build Script for false.work (SpiderLily)
2# Run from Windows host to build UE5 project locally (not on GCP)
3
4param(
5 [switch]$NoSync,
6 [string]$Platform = "Win64",
7 [string]$Config = "Shipping",
8 [string]$Version = (Get-Date -Format "yyyy.MM.dd-HHmm"),
9 [ValidateSet("auto", "ultra", "high", "medium")]
10 [string]$Quality = "auto",
11 [switch]$AutoPackage
12)
13
14$ErrorActionPreference = "Stop"
15
16# Quality preset suffix for filename
17$QualitySuffix = if ($Quality -ne "auto") { "-$Quality" } else { "" }
18
19Write-Host "=========================================" -ForegroundColor Cyan
20Write-Host "false.work Local Windows Build" -ForegroundColor Cyan
21Write-Host "=========================================" -ForegroundColor Cyan
22Write-Host "Platform: $Platform"
23Write-Host "Config: $Config"
24Write-Host "Version: $Version"
25Write-Host "Quality: $Quality" -ForegroundColor $(if ($Quality -eq "ultra") { "Magenta" } elseif ($Quality -eq "high") { "Yellow" } else { "White" })
26Write-Host "AutoPackage: $AutoPackage"
27Write-Host "NoSync: $NoSync" -ForegroundColor $(if ($NoSync) { "Green" } else { "Gray" })
28Write-Host ""
29
30# Configuration - Update these paths for your local setup
31$UE5Path = "C:\Program Files\Epic Games\UE_5.6"
32$ProjectRoot = "C:\Perforce\SpiderLily\SL_main" # Updated to include SL_main subdirectory
33$ProjectFile = "$ProjectRoot\SpiderLily.uproject"
34$OutputDir = "$env:USERPROFILE\Desktop\SpiderLily-$Version"
35
36# Check if UE5 exists
37if (!(Test-Path $UE5Path)) {
38 Write-Host "WARNING: UE5 not found at: $UE5Path" -ForegroundColor Yellow
39 Write-Host ""
40 Write-Host "Please update the `$UE5Path variable in this script to point to your UE5 installation."
41 Write-Host ""
42 Write-Host "Common locations:"
43 Write-Host " - C:\Program Files\Epic Games\UE_5.7"
44 Write-Host " - C:\Program Files\Epic Games\UE_5.6"
45 Write-Host " - C:\UE5"
46 Write-Host ""
47 exit 1
48}
49
50# Check if project exists
51if (!(Test-Path $ProjectFile)) {
52 Write-Host "WARNING: Project not found at: $ProjectFile" -ForegroundColor Yellow
53 Write-Host ""
54 Write-Host "Please update the `$ProjectRoot variable in this script to point to your SpiderLily project."
55 Write-Host ""
56 exit 1
57}
58
59Write-Host "[OK] Found UE5: $UE5Path" -ForegroundColor Green
60Write-Host "[OK] Found Project: $ProjectFile" -ForegroundColor Green
61Write-Host ""
62
63# Optional: Sync from Perforce if configured (skip if -NoSync)
64if ($NoSync) {
65 Write-Host "[SKIP] Perforce sync skipped (-NoSync flag). Using local changes." -ForegroundColor Yellow
66 Write-Host ""
67} elseif (Get-Command p4 -ErrorAction SilentlyContinue) {
68 if ($AutoPackage) {
69 # Auto mode: sync without prompting
70 Write-Host "Auto: Syncing from Perforce..." -ForegroundColor Yellow
71 Set-Location $ProjectRoot
72 p4 sync
73 if ($LASTEXITCODE -ne 0) {
74 Write-Warning "Perforce sync failed, continuing with existing files..."
75 }
76 # Show recent changes
77 p4 changes -m 5 ...
78 Write-Host ""
79 } else {
80 # Interactive mode: prompt user
81 $response = Read-Host "Sync from Perforce? (y/N)"
82 if ($response -eq "y" -or $response -eq "Y") {
83 Write-Host "Syncing from Perforce..." -ForegroundColor Yellow
84 Set-Location $ProjectRoot
85 p4 sync
86 if ($LASTEXITCODE -ne 0) {
87 Write-Warning "Perforce sync failed, continuing with existing files..."
88 }
89 Write-Host ""
90 }
91 }
92}
93
94# Build
95Write-Host "Building $Platform package..." -ForegroundColor Yellow
96Write-Host " This may take 10-30 minutes depending on your hardware..." -ForegroundColor Gray
97Write-Host ""
98
99# Create temporary GameUserSettings.ini for quality preset if not "auto"
100$TempSettingsCreated = $false
101$GameUserSettingsPath = "$ProjectRoot\Config\DefaultGameUserSettings.ini"
102
103if ($Quality -ne "auto") {
104 Write-Host "Applying $Quality quality preset..." -ForegroundColor Cyan
105
106 # Quality level mapping: 0=Low, 1=Medium, 2=High, 3=Epic, 4=Cinematic
107 $QualityLevel = switch ($Quality) {
108 "medium" { 1 }
109 "high" { 3 } # Epic
110 "ultra" { 4 } # Cinematic
111 default { 3 }
112 }
113
114 $SettingsContent = @"
115[ScalabilityGroups]
116sg.ResolutionQuality=100
117sg.ViewDistanceQuality=$QualityLevel
118sg.AntiAliasingQuality=$QualityLevel
119sg.ShadowQuality=$QualityLevel
120sg.GlobalIlluminationQuality=$QualityLevel
121sg.ReflectionQuality=$QualityLevel
122sg.PostProcessQuality=$QualityLevel
123sg.TextureQuality=$QualityLevel
124sg.EffectsQuality=$QualityLevel
125sg.FoliageQuality=$QualityLevel
126sg.ShadingQuality=$QualityLevel
127
128[/Script/Engine.GameUserSettings]
129bUseDesiredScreenHeight=False
130DesiredScreenWidth=1920
131DesiredScreenHeight=1080
132LastUserConfirmedDesiredScreenWidth=1920
133LastUserConfirmedDesiredScreenHeight=1080
134LastRecommendedScreenWidth=-1
135LastRecommendedScreenHeight=-1
136LastCPUBenchmarkResult=-1
137LastGPUBenchmarkResult=-1
138LastCPUBenchmarkSteps=0
139LastGPUBenchmarkSteps=0
140LastGPUBenchmarkMultiplier=1
141bUseDynamicResolution=False
142bUseHDRDisplayOutput=True
143HDRDisplayOutputNits=1000
144"@
145
146 # Backup existing if present
147 if (Test-Path $GameUserSettingsPath) {
148 Copy-Item $GameUserSettingsPath "$GameUserSettingsPath.backup" -Force
149 }
150
151 Set-Content -Path $GameUserSettingsPath -Value $SettingsContent -Encoding UTF8
152 $TempSettingsCreated = $true
153 Write-Host "Created quality preset config: $GameUserSettingsPath" -ForegroundColor Green
154}
155
156# Run FMOD GenerateAssets commandlet before cooking
157# This generates FMOD bank assets that normally get created when opening the editor
158# Required for command-line builds: https://fmod.com/docs/2.03/unreal/user-guide.html#commandlet
159$UnrealEditor = "$UE5Path\Engine\Binaries\Win64\UnrealEditor-Cmd.exe"
160Write-Host ""
161Write-Host "Running FMOD GenerateAssets commandlet..." -ForegroundColor Yellow
162& $UnrealEditor $ProjectFile -run=FMODGenerateAssets
163if ($LASTEXITCODE -ne 0) {
164 Write-Warning "FMOD GenerateAssets commandlet returned non-zero exit code, continuing anyway..."
165}
166
167$RunUAT = "$UE5Path\Engine\Build\BatchFiles\RunUAT.bat"
168
169& $RunUAT BuildCookRun `
170 "-project=$ProjectFile" `
171 "-platform=$Platform" `
172 "-clientconfig=$Config" `
173 -cook `
174 -build `
175 -stage `
176 -pak `
177 -archive `
178 "-archivedirectory=$OutputDir" `
179 -noP4 `
180 -utf8output `
181 -NoLiveCoding `
182 -nocompileeditor `
183 -iterate `
184 -IgnoreCookErrors
185
186if ($LASTEXITCODE -ne 0) {
187 # Cleanup temp settings on failure
188 if ($TempSettingsCreated -and (Test-Path "$GameUserSettingsPath.backup")) {
189 Move-Item "$GameUserSettingsPath.backup" $GameUserSettingsPath -Force
190 } elseif ($TempSettingsCreated) {
191 Remove-Item $GameUserSettingsPath -Force -ErrorAction SilentlyContinue
192 }
193 Write-Host ""
194 Write-Host "[ERROR] Build failed!" -ForegroundColor Red
195 exit 1
196}
197
198# Cleanup temp settings after successful build
199if ($TempSettingsCreated) {
200 if (Test-Path "$GameUserSettingsPath.backup") {
201 Move-Item "$GameUserSettingsPath.backup" $GameUserSettingsPath -Force
202 } else {
203 Remove-Item $GameUserSettingsPath -Force -ErrorAction SilentlyContinue
204 }
205 Write-Host "Cleaned up temporary quality preset config" -ForegroundColor Gray
206}
207
208Write-Host ""
209Write-Host "[SUCCESS] Build complete!" -ForegroundColor Green
210Write-Host ""
211Write-Host "Output location:" -ForegroundColor Cyan
212Write-Host " $OutputDir"
213Write-Host ""
214
215# Optionally or automatically compress
216if ($AutoPackage) {
217 Write-Host ""
218 Write-Host "Auto: Compressing build to ZIP..." -ForegroundColor Yellow
219 $ArchiveName = "spiderlily-windows-$Version$QualitySuffix.zip"
220 $ArchivePath = "$env:USERPROFILE\Desktop\$ArchiveName"
221
222 if (Test-Path "C:\Program Files\7-Zip\7z.exe") {
223 & "C:\Program Files\7-Zip\7z.exe" a -tzip "$ArchivePath" "$OutputDir\Windows\*" | Out-Default
224 } else {
225 Compress-Archive -Path "$OutputDir\Windows\*" -DestinationPath "$ArchivePath" -CompressionLevel Optimal -Force
226 }
227
228 if (Test-Path $ArchivePath) {
229 $ArchiveSize = (Get-Item $ArchivePath).Length / 1MB
230 $SizeRounded = [math]::Round($ArchiveSize, 2)
231 Write-Host "Created: $ArchiveName ($SizeRounded MB)" -ForegroundColor Green
232 Write-Host " $ArchivePath"
233 } else {
234 Write-Host "Failed to create archive: $ArchivePath" -ForegroundColor Red
235 exit 1
236 }
237} else {
238 $response = Read-Host "Compress build to ZIP? (y/N)"
239 if ($response -eq "y" -or $response -eq "Y") {
240 Write-Host ""
241 Write-Host "Compressing..." -ForegroundColor Yellow
242
243 $ArchiveName = "SpiderLily-$Platform-$Version.zip"
244 $BuildsDir = "$ProjectRoot\Builds"
245
246 # Create Builds directory if it doesn't exist
247 if (!(Test-Path $BuildsDir)) {
248 New-Item -ItemType Directory -Path $BuildsDir -Force | Out-Null
249 }
250
251 $ArchivePath = "$BuildsDir\$ArchiveName"
252
253 if (Test-Path "C:\Program Files\7-Zip\7z.exe") {
254 & "C:\Program Files\7-Zip\7z.exe" a -tzip "$ArchivePath" "$OutputDir\*"
255 } else {
256 Compress-Archive -Path "$OutputDir\*" -DestinationPath "$ArchivePath" -CompressionLevel Optimal -Force
257 }
258
259 $ArchiveSize = (Get-Item $ArchivePath).Length / 1MB
260 $SizeRounded = [math]::Round($ArchiveSize, 2)
261 Write-Host "Created: $ArchiveName ($SizeRounded MB)" -ForegroundColor Green
262 Write-Host " $ArchivePath"
263 }
264}
265
266Write-Host ""
267Write-Host "Done!" -ForegroundColor Green
268Write-Host ""