35 lines
1.7 KiB
PowerShell
35 lines
1.7 KiB
PowerShell
param(
|
|
[Parameter(Mandatory = $true)]
|
|
[string]$CompilerPath
|
|
)
|
|
$ErrorActionPreference = 'Stop'
|
|
$compiler = (Resolve-Path -LiteralPath $CompilerPath).Path
|
|
$repo = Split-Path -Parent $PSScriptRoot
|
|
$files = @(Get-ChildItem -LiteralPath $repo -Filter 'tws_t6_*.gsc' | Sort-Object Name)
|
|
if ($files.Count -ne 5) { throw 'Expected the five TWS modules: common, HUD, AFK, lock, telemetry.' }
|
|
$common = Get-Content -LiteralPath (Join-Path $repo 'tws_t6_common.gsc') -Raw
|
|
$functions = @([regex]::Matches($common, '(?m)^([a-zA-Z_][a-zA-Z_0-9]*)\([^\r\n]*\)\s*\r?\n\{') | ForEach-Object { $_.Groups[1].Value })
|
|
foreach ($file in $files) {
|
|
$source = Get-Content -LiteralPath $file.FullName -Raw
|
|
foreach ($entry in @('main', 'init')) {
|
|
if ($source -notmatch "(?m)^$entry\(\)\s*\r?\n\{") {
|
|
throw "Missing $entry entry point in $($file.Name)"
|
|
}
|
|
}
|
|
if ($source -match 'scripts\\sp\\|maps\\_utility|#"zombiemode"') {
|
|
throw "T5-only reference in $($file.Name)"
|
|
}
|
|
foreach ($reference in [regex]::Matches($source, 'scripts\\zm\\tws_t6_common::([a-zA-Z_][a-zA-Z_0-9]*)')) {
|
|
if ($reference.Groups[1].Value -notin $functions) {
|
|
throw "Missing common function: $($reference.Groups[1].Value)"
|
|
}
|
|
}
|
|
$output = (& $compiler -m comp -g t6 -s pc -y $file.FullName 2>&1 | Out-String)
|
|
# gsc-tool can return zero even when compilation emits an error.
|
|
if ($LASTEXITCODE -ne 0 -or $output -match '(?i)error|failed' -or $output -notmatch 'compiled t6/') {
|
|
throw "Compile failed for $($file.Name):`n$output"
|
|
}
|
|
Write-Output "PASS $($file.Name)"
|
|
}
|
|
Write-Output 'All five T6 compile checks and common references passed. Runtime linking/gameplay require Plutonium.'
|