-
-
Notifications
You must be signed in to change notification settings - Fork 51
chore: Add scripts to automate plugin extensions setup #1104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+335
−0
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
aa1aff9
Add console extension setup script
tustanivsky ea5720c
Fix count
tustanivsky 261f5e8
Add top level script to init multiple consoles at once
tustanivsky da1dac1
Clean up logs
tustanivsky 824ce95
Add fresh build flag
tustanivsky f0779e3
Fix path
tustanivsky File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,201 @@ | ||
param( | ||
[Parameter(Mandatory=$true)] | ||
[ValidateSet('Switch', 'PS5', 'XSX', 'XB1')] | ||
[string]$Platform, | ||
|
||
[Parameter(Mandatory=$true)] | ||
[string]$ExtensionPath | ||
) | ||
|
||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Platform-specific configuration | ||
$platformConfig = @{ | ||
'Switch' = @{ | ||
Preset = 'nx64-unreal' | ||
BuildDir = 'nx64-unreal' | ||
PlatformFolder = 'Switch' | ||
SourceDir = 'Sentry' | ||
} | ||
'PS5' = @{ | ||
Preset = 'ps5-unreal' | ||
BuildDir = 'ps5-unreal' | ||
PlatformFolder = 'PS5' | ||
SourceDir = 'Sentry' | ||
} | ||
'XSX' = @{ | ||
Preset = 'scarlett-unreal' | ||
BuildDir = 'scarlett-unreal' | ||
PlatformFolder = 'XSX' | ||
SourceDir = 'Sentry_XSX' | ||
} | ||
'XB1' = @{ | ||
Preset = 'xboxone-unreal' | ||
BuildDir = 'xboxone-unreal' | ||
PlatformFolder = 'XB1' | ||
SourceDir = 'Sentry_XB1' | ||
} | ||
} | ||
|
||
$config = $platformConfig[$Platform] | ||
$repoRoot = Resolve-Path "$PSScriptRoot/.." | ||
|
||
Write-Host "Setting up $Platform console extension..." -ForegroundColor Cyan | ||
Write-Host "Extension path: $ExtensionPath" | ||
|
||
# Step 1: Validate extension path | ||
Write-Host "`n[1/5] Validating extension path..." -ForegroundColor Yellow | ||
|
||
if (-not (Test-Path $ExtensionPath)) { | ||
throw "Extension path does not exist: $ExtensionPath" | ||
} | ||
$ExtensionPath = Resolve-Path $ExtensionPath | ||
|
||
$cmakeFile = Join-Path $ExtensionPath "CMakeLists.txt" | ||
if (-not (Test-Path $cmakeFile)) { | ||
throw "CMakeLists.txt not found in extension path: $ExtensionPath" | ||
} | ||
|
||
$unrealDir = Join-Path $ExtensionPath "unreal" | ||
if (-not (Test-Path $unrealDir)) { | ||
throw "unreal directory not found in extension path: $ExtensionPath" | ||
} | ||
|
||
$sourceDir = Join-Path $unrealDir $config.SourceDir | ||
if (-not (Test-Path $sourceDir)) { | ||
throw "Source directory not found: $sourceDir" | ||
} | ||
|
||
Write-Host " ✓ Extension path validated" -ForegroundColor Green | ||
|
||
# Step 2: Build extension | ||
Write-Host "`n[2/5] Building extension..." -ForegroundColor Yellow | ||
Write-Host " Running: cmake --workflow --preset $($config.Preset) --fresh" | ||
|
||
Push-Location $ExtensionPath | ||
try { | ||
$buildOutput = & cmake --workflow --preset $config.Preset --fresh 2>&1 | ||
if ($LASTEXITCODE -ne 0) { | ||
Write-Host $buildOutput -ForegroundColor Red | ||
throw "Build failed with exit code $LASTEXITCODE" | ||
} | ||
Write-Host " ✓ Extension built successfully" -ForegroundColor Green | ||
} finally { | ||
Pop-Location | ||
} | ||
|
||
# Verify build output exists | ||
$buildOutputDir = Join-Path $ExtensionPath "build" $config.BuildDir "unreal" "Sentry" | ||
if (-not (Test-Path $buildOutputDir)) { | ||
throw "Build output directory not found: $buildOutputDir" | ||
} | ||
|
||
# Step 3: Create directory structure in sample project | ||
Write-Host "`n[3/5] Creating directory structure..." -ForegroundColor Yellow | ||
|
||
$targetPluginRoot = Join-Path $repoRoot "sample" "Platforms" $config.PlatformFolder "Plugins" "Sentry" | ||
$targetSourceRoot = Join-Path $targetPluginRoot "Source" | ||
$targetThirdPartyDir = Join-Path $targetSourceRoot "ThirdParty" $config.PlatformFolder | ||
|
||
# Create all necessary directories | ||
$dirsToCreate = @( | ||
$targetPluginRoot, | ||
$targetSourceRoot, | ||
(Join-Path $targetSourceRoot "Sentry" "Private"), | ||
$targetThirdPartyDir | ||
) | ||
|
||
foreach ($dir in $dirsToCreate) { | ||
if (-not (Test-Path $dir)) { | ||
New-Item -ItemType Directory -Path $dir -Force | Out-Null | ||
Write-Host " Created: $dir" | ||
} | ||
} | ||
|
||
Write-Host " ✓ Directory structure created" -ForegroundColor Green | ||
|
||
# Step 4: Copy build artifacts (ThirdParty libs/headers) | ||
Write-Host "`n[4/5] Copying build artifacts..." -ForegroundColor Yellow | ||
|
||
$buildThirdPartyDir = Join-Path $buildOutputDir "Source" "ThirdParty" $config.PlatformFolder | ||
if (-not (Test-Path $buildThirdPartyDir)) { | ||
throw "Build ThirdParty directory not found: $buildThirdPartyDir" | ||
} | ||
|
||
# Remove existing ThirdParty directory if it exists to ensure clean copy | ||
if (Test-Path $targetThirdPartyDir) { | ||
Remove-Item -Path $targetThirdPartyDir -Recurse -Force | ||
} | ||
|
||
# Copy entire ThirdParty directory | ||
Copy-Item -Path $buildThirdPartyDir -Destination (Join-Path $targetSourceRoot "ThirdParty") -Recurse -Force | ||
Write-Host " Copied: ThirdParty/$($config.PlatformFolder)/" | ||
|
||
Write-Host " ✓ Build artifacts copied" -ForegroundColor Green | ||
|
||
# Step 5: Symlink source files for live editing | ||
Write-Host "`n[5/5] Creating symlinks to source files..." -ForegroundColor Yellow | ||
|
||
# Helper function to create symlink/junction | ||
function New-SymbolicLink { | ||
param( | ||
[string]$LinkPath, | ||
[string]$TargetPath | ||
) | ||
|
||
# Remove existing link if it exists | ||
if (Test-Path $LinkPath) { | ||
$item = Get-Item $LinkPath | ||
if ($item.LinkType -eq "Junction" -or $item.LinkType -eq "SymbolicLink") { | ||
$item.Delete() | ||
} else { | ||
Remove-Item -Path $LinkPath -Recurse -Force | ||
} | ||
} | ||
|
||
# Create parent directory if needed | ||
$parentDir = Split-Path -Parent $LinkPath | ||
if (-not (Test-Path $parentDir)) { | ||
New-Item -ItemType Directory -Path $parentDir -Force | Out-Null | ||
} | ||
|
||
# Create junction (works cross-platform with PowerShell) | ||
if (Test-Path $TargetPath -PathType Container) { | ||
New-Item -ItemType Junction -Path $LinkPath -Target $TargetPath | Out-Null | ||
} else { | ||
New-Item -ItemType SymbolicLink -Path $LinkPath -Target $TargetPath | Out-Null | ||
} | ||
} | ||
|
||
# Symlink .uplugin file | ||
$upluginFiles = @(Get-ChildItem -Path $sourceDir -Filter "*.uplugin" -ErrorAction SilentlyContinue) | ||
if ($upluginFiles.Count -eq 0) { | ||
throw "No .uplugin file found in $sourceDir" | ||
} | ||
$upluginTarget = $upluginFiles[0].FullName | ||
$upluginLink = Join-Path $targetPluginRoot $upluginFiles[0].Name | ||
New-SymbolicLink -LinkPath $upluginLink -TargetPath $upluginTarget | ||
Write-Host " Linked: $($upluginFiles[0].Name)" | ||
|
||
# Symlink .Build.cs file | ||
$buildcsFiles = @(Get-ChildItem -Path (Join-Path $sourceDir "Source") -Filter "*.Build.cs" -ErrorAction SilentlyContinue) | ||
if ($buildcsFiles.Count -gt 0) { | ||
$buildcsTarget = $buildcsFiles[0].FullName | ||
$buildcsLink = Join-Path $targetSourceRoot $buildcsFiles[0].Name | ||
New-SymbolicLink -LinkPath $buildcsLink -TargetPath $buildcsTarget | ||
Write-Host " Linked: Source/$($buildcsFiles[0].Name)" | ||
} | ||
|
||
# Symlink Sentry/Private directory (contains .cpp/.h files) | ||
$privateSourceDir = Join-Path $sourceDir "Source" "Sentry" "Private" | ||
if (Test-Path $privateSourceDir) { | ||
$privateTargetDir = Join-Path $targetSourceRoot "Sentry" "Private" | ||
New-SymbolicLink -LinkPath $privateTargetDir -TargetPath $privateSourceDir | ||
Write-Host " Linked: Source/Sentry/Private/" | ||
} | ||
|
||
Write-Host " ✓ Source files symlinked" -ForegroundColor Green | ||
|
||
Write-Host "`n✓ Console extension setup complete!" -ForegroundColor Green | ||
Write-Host "`nTarget location: $targetPluginRoot" -ForegroundColor Cyan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
param( | ||
[switch]$All, | ||
[switch]$Switch, | ||
[switch]$PS5, | ||
[switch]$XSX, | ||
[switch]$XB1 | ||
) | ||
|
||
Set-StrictMode -Version Latest | ||
$ErrorActionPreference = "Stop" | ||
|
||
Write-Host "Setting up console plugin extensions" -ForegroundColor Cyan | ||
|
||
# If -All is specified, enable all platforms | ||
if ($All) { | ||
$Switch = $true | ||
$PS5 = $true | ||
$XSX = $true | ||
$XB1 = $true | ||
} | ||
|
||
# Check if at least one platform is selected | ||
if (-not ($Switch -or $PS5 -or $XSX -or $XB1)) { | ||
Write-Host "Error: No platform specified. Use -All or specify individual platforms (-Switch, -PS5, -XSX, -XB1)" -ForegroundColor Red | ||
Write-Host "" | ||
Write-Host "Examples:" | ||
Write-Host " ./scripts/init-consoles.ps1 -All" | ||
Write-Host " ./scripts/init-consoles.ps1 -Switch -PS5" | ||
Write-Host " ./scripts/init-consoles.ps1 -XSX -XB1" | ||
Write-Host "" | ||
Write-Host "Environment variables required:" | ||
Write-Host " SENTRY_SWITCH_PATH - Path to sentry-switch repo" | ||
Write-Host " SENTRY_PLAYSTATION_PATH - Path to sentry-playstation repo" | ||
Write-Host " SENTRY_XBOX_PATH - Path to sentry-xbox repo" | ||
exit 1 | ||
} | ||
|
||
# Platform configuration with env var mapping | ||
$platformConfigs = @{ | ||
'Switch' = @{ | ||
EnvVar = 'SENTRY_SWITCH_PATH' | ||
Enabled = $Switch | ||
} | ||
'PS5' = @{ | ||
EnvVar = 'SENTRY_PLAYSTATION_PATH' | ||
Enabled = $PS5 | ||
} | ||
'XSX' = @{ | ||
EnvVar = 'SENTRY_XBOX_PATH' | ||
Enabled = $XSX | ||
} | ||
'XB1' = @{ | ||
EnvVar = 'SENTRY_XBOX_PATH' | ||
Enabled = $XB1 | ||
} | ||
tustanivsky marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
|
||
# Track results | ||
$results = @() | ||
|
||
# Process each enabled platform | ||
foreach ($platform in $platformConfigs.Keys | Sort-Object) { | ||
$config = $platformConfigs[$platform] | ||
|
||
if (-not $config.Enabled) { | ||
continue | ||
} | ||
|
||
Write-Host "" | ||
|
||
# Get extension path from environment variable | ||
$envVarName = $config.EnvVar | ||
$extensionPath = [Environment]::GetEnvironmentVariable($envVarName) | ||
|
||
if (-not $extensionPath) { | ||
Write-Host "ERROR: Environment variable '$envVarName' is not set" -ForegroundColor Red | ||
$results += @{ | ||
Platform = $platform | ||
Status = "Failed" | ||
Message = "Environment variable not set: $envVarName" | ||
} | ||
continue | ||
} | ||
|
||
# Call init-console-ext.ps1 for this platform | ||
try { | ||
$scriptPath = Join-Path $PSScriptRoot "init-console-ext.ps1" | ||
& $scriptPath -Platform $platform -ExtensionPath $extensionPath | ||
|
||
if ($LASTEXITCODE -ne 0) { | ||
throw "Script failed with exit code $LASTEXITCODE" | ||
} | ||
|
||
$results += @{ | ||
Platform = $platform | ||
Status = "Success" | ||
Message = "Setup completed" | ||
} | ||
} | ||
catch { | ||
Write-Host "ERROR: Failed to setup $platform - $_" -ForegroundColor Red | ||
$results += @{ | ||
Platform = $platform | ||
Status = "Failed" | ||
Message = $_.Exception.Message | ||
} | ||
} | ||
} | ||
|
||
# Summary report | ||
Write-Host "`nSummary:`n" -ForegroundColor Cyan | ||
|
||
$successCount = 0 | ||
$failCount = 0 | ||
|
||
foreach ($result in $results) { | ||
$statusColor = if ($result.Status -eq "Success") { "Green" } else { "Red" } | ||
$statusSymbol = if ($result.Status -eq "Success") { "✓" } else { "✗" } | ||
|
||
Write-Host "$statusSymbol $($result.Platform): " -NoNewline -ForegroundColor $statusColor | ||
Write-Host $result.Message | ||
|
||
if ($result.Status -eq "Success") { | ||
$successCount++ | ||
} else { | ||
$failCount++ | ||
} | ||
} | ||
|
||
Write-Host "`nTotal: $($results.Count) | Success: $successCount | Failed: $failCount" -ForegroundColor $(if ($failCount -eq 0) { "Green" } else { "Yellow" }) | ||
|
||
if ($failCount -gt 0) { | ||
exit 1 | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.