UEScripts/inc/buildtargets.ps1

30 lines
887 B
PowerShell
Raw Normal View History

function Find-DefaultTarget {
param (
[string]$srcfolder,
# Game, Editor, Server, Client
[string]$preferred = "Editor"
)
$sourcefolder = Join-Path (Resolve-Path $srcfolder) "Source"
# Enumerate the Target.cs files in Source folder and use the default one
# This lets us not assume what the modules are called exactly
$targetFiles = Get-ChildItem "$sourcefolder\*.Target.cs"
foreach ($file in $targetfiles) {
if ($file.Name -like "*$preferred.Target.cs") {
return $file.Name.SubString(0, $file.Name.Length - 10)
}
}
# Fall back on Game if nothing else
foreach ($file in $targetfiles) {
if ($file.Name -like "*Game.Target.cs") {
return $file.Name.SubString(0, $file.Name.Length - 10)
}
}
throw "Unable to find default build target ending in $preferred"
}