Something went wrong. Try again.
Monorepo for Aesthetic.Computer aesthetic.computer
Something went wrong. Try again.
7.4 kB · 190 lines
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191# Setup Build Machine for UE5 + Perforce# Run this script on your Windows build machine (self-hosted runner)
param( [string]$P4Server = "", [string]$P4User = "", [string]$P4Workspace = "ue5_build_workspace", [string]$WorkspaceRoot = "D:\Perforce", [string]$BuildRoot = "D:\Builds", [string]$UE5Path = "C:\Program Files\Epic Games\UE_5.4")
Write-Host "=== UE5 Build Machine Setup ===" -ForegroundColor Cyan
# Check if running as Administrator$isAdmin = ([Security.Principal.WindowsPrincipal] [Security.Principal.WindowsIdentity]::GetCurrent()).IsInRole([Security.Principal.WindowsBuiltInRole]::Administrator)if (-not $isAdmin) { Write-Warning "This script should be run as Administrator for best results"}
# 1. Check PrerequisitesWrite-Host "`n[1/6] Checking Prerequisites..." -ForegroundColor Yellow
$prerequisites = @{ "Unreal Engine" = Test-Path $UE5Path "Perforce CLI (p4)" = (Get-Command p4 -ErrorAction SilentlyContinue) -ne $null "Git" = (Get-Command git -ErrorAction SilentlyContinue) -ne $null "Visual Studio" = Test-Path "C:\Program Files\Microsoft Visual Studio"}
foreach ($prereq in $prerequisites.GetEnumerator()) { $status = if ($prereq.Value) { "✓" } else { "✗" } $color = if ($prereq.Value) { "Green" } else { "Red" } Write-Host " $status $($prereq.Key)" -ForegroundColor $color}
if ($prerequisites.Values -contains $false) { Write-Host "`nMissing prerequisites. Please install:" -ForegroundColor Red $prerequisites.GetEnumerator() | Where-Object { -not $_.Value } | ForEach-Object { Write-Host " - $($_.Key)" -ForegroundColor Red } Write-Host "`nSee README.md for installation instructions" exit 1}
# 2. Create Directory StructureWrite-Host "`n[2/6] Creating Directory Structure..." -ForegroundColor Yellow
$directories = @($WorkspaceRoot, $BuildRoot, "$BuildRoot\Logs")foreach ($dir in $directories) { if (-not (Test-Path $dir)) { New-Item -ItemType Directory -Path $dir -Force | Out-Null Write-Host " Created: $dir" -ForegroundColor Green } else { Write-Host " Exists: $dir" -ForegroundColor Gray }}
# 3. Configure PerforceWrite-Host "`n[3/6] Configuring Perforce..." -ForegroundColor Yellow
if ($P4Server -and $P4User) { Write-Host " Setting Perforce environment variables..." # Set user environment variables [Environment]::SetEnvironmentVariable("P4PORT", $P4Server, "User") [Environment]::SetEnvironmentVariable("P4USER", $P4User, "User") [Environment]::SetEnvironmentVariable("P4CLIENT", $P4Workspace, "User") # Set for current session $env:P4PORT = $P4Server $env:P4USER = $P4User $env:P4CLIENT = $P4Workspace Write-Host " P4PORT: $P4Server" -ForegroundColor Green Write-Host " P4USER: $P4User" -ForegroundColor Green Write-Host " P4CLIENT: $P4Workspace" -ForegroundColor Green # Test connection Write-Host " Testing Perforce connection..." $p4Info = p4 info 2>&1 if ($LASTEXITCODE -eq 0) { Write-Host " ✓ Perforce connection successful" -ForegroundColor Green } else { Write-Host " ✗ Perforce connection failed. Check credentials and password." -ForegroundColor Red Write-Host " Run: p4 set P4PASSWD=your_password" -ForegroundColor Yellow }} else { Write-Host " Skipping Perforce configuration (no credentials provided)" -ForegroundColor Gray Write-Host " Configure manually with:" -ForegroundColor Yellow Write-Host " p4 set P4PORT=ssl:your-server.com:1666" -ForegroundColor Yellow Write-Host " p4 set P4USER=build_account" -ForegroundColor Yellow Write-Host " p4 set P4PASSWD=your_password" -ForegroundColor Yellow}
# 4. Create Perforce WorkspaceWrite-Host "`n[4/6] Creating Perforce Workspace..." -ForegroundColor Yellow
if ($P4Server -and $P4User) { $workspaceExists = p4 clients | Select-String -Pattern $P4Workspace if (-not $workspaceExists) { Write-Host " Creating workspace: $P4Workspace" $workspaceSpec = @"Client: $P4WorkspaceOwner: $P4UserRoot: $WorkspaceRootOptions: noallwrite noclobber nocompress unlocked nomodtime normdirSubmitOptions: submitunchangedLineEnd: localView: //depot/... //$P4Workspace/..."@ $workspaceSpec | p4 client -i if ($LASTEXITCODE -eq 0) { Write-Host " ✓ Workspace created successfully" -ForegroundColor Green } else { Write-Host " ✗ Failed to create workspace" -ForegroundColor Red } } else { Write-Host " Workspace already exists: $P4Workspace" -ForegroundColor Gray }} else { Write-Host " Skipping workspace creation (no P4 credentials)" -ForegroundColor Gray}
# 5. Configure Windows Performance SettingsWrite-Host "`n[5/6] Configuring Windows Performance Settings..." -ForegroundColor Yellow
if ($isAdmin) { try { # Disable Windows Defender real-time scanning for build directories Write-Host " Adding build directories to Windows Defender exclusions..." Add-MpPreference -ExclusionPath $WorkspaceRoot -ErrorAction SilentlyContinue Add-MpPreference -ExclusionPath $BuildRoot -ErrorAction SilentlyContinue Add-MpPreference -ExclusionPath $UE5Path -ErrorAction SilentlyContinue Write-Host " ✓ Defender exclusions added" -ForegroundColor Green } catch { Write-Host " Could not modify Defender settings: $_" -ForegroundColor Yellow }} else { Write-Host " Run as Administrator to configure performance settings" -ForegroundColor Yellow}
# 6. Create Build ScriptsWrite-Host "`n[6/6] Creating Helper Scripts..." -ForegroundColor Yellow
# Quick sync script$syncScript = @"# Quick Perforce SyncWrite-Host "Syncing Perforce workspace..." -ForegroundColor Cyanp4 syncWrite-Host "Done!" -ForegroundColor Green"@Set-Content -Path "$WorkspaceRoot\sync.ps1" -Value $syncScriptWrite-Host " Created: $WorkspaceRoot\sync.ps1" -ForegroundColor Green
# Environment info script$infoScript = @"Write-Host "Build Machine Info" -ForegroundColor CyanWrite-Host "==================" -ForegroundColor CyanWrite-Host "Hostname: `$env:COMPUTERNAME"Write-Host "OS: `$(Get-WmiObject Win32_OperatingSystem | Select-Object -ExpandProperty Caption)"Write-Host "CPU: `$(Get-WmiObject Win32_Processor | Select-Object -ExpandProperty Name -First 1)"Write-Host "RAM: `$([math]::Round((Get-WmiObject Win32_ComputerSystem).TotalPhysicalMemory / 1GB, 2)) GB"Write-Host ""Write-Host "UE5 Path: $UE5Path"Write-Host "Workspace: $WorkspaceRoot"Write-Host "Builds: $BuildRoot"Write-Host ""Write-Host "Perforce Info:" -ForegroundColor Yellowp4 info"@Set-Content -Path "$WorkspaceRoot\info.ps1" -Value $infoScriptWrite-Host " Created: $WorkspaceRoot\info.ps1" -ForegroundColor Green
# SummaryWrite-Host "`n=== Setup Complete! ===" -ForegroundColor GreenWrite-Host "`nNext Steps:"Write-Host "1. Configure Perforce password: p4 set P4PASSWD=your_password"Write-Host "2. Verify connection: p4 info"Write-Host "3. Edit workspace view: p4 client $P4Workspace"Write-Host "4. Initial sync: p4 sync"Write-Host "5. Configure GitHub Actions runner on this machine"Write-Host "`nHelper scripts created in: $WorkspaceRoot"Write-Host " - sync.ps1 - Quick workspace sync"Write-Host " - info.ps1 - Display build machine info"