Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 33 additions & 16 deletions build_common.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ class BuildProject {
$scriptsMakeArguments = "$scriptsMakeArguments -debug"
}

$handler = [MakeStdoutReceiver]::new($this.devSrcRoot, "$($this.modSrcRoot)\Src")
$handler = [MakeStdoutReceiver]::new($this)
$handler.processDescr = "compiling base game scripts"
$this._InvokeEditorCmdlet($handler, $scriptsMakeArguments, 50)

Expand All @@ -483,7 +483,7 @@ class BuildProject {
{
Write-Host "Compiling base game scripts without final_release..."
$scriptsMakeArguments = "make -nopause -unattended"
$handler = [MakeStdoutReceiver]::new($this.devSrcRoot, "$($this.modSrcRoot)\Src")
$handler = [MakeStdoutReceiver]::new($this)
$handler.processDescr = "compiling base game scripts"
$this._InvokeEditorCmdlet($handler, $scriptsMakeArguments, 50)
}
Expand All @@ -496,7 +496,7 @@ class BuildProject {
{
$scriptsMakeArguments = "$scriptsMakeArguments -debug"
}
$handler = [MakeStdoutReceiver]::new($this.devSrcRoot, "$($this.modSrcRoot)\Src")
$handler = [MakeStdoutReceiver]::new($this)
$handler.processDescr = "compiling mod scripts"
$this._InvokeEditorCmdlet($handler, $scriptsMakeArguments, 50)
}
Expand Down Expand Up @@ -1211,28 +1211,45 @@ class BufferingReceiver : StdoutReceiver {


class MakeStdoutReceiver : StdoutReceiver {
[string] $developmentDirectory
[string] $modSrcRoot
[BuildProject] $proj
[string[]] $reversePaths

MakeStdoutReceiver(
[string]$developmentDirectory,
[string]$modSrcRoot
[BuildProject]$proj
){
$this.developmentDirectory = $developmentDirectory
$this.modSrcRoot = $modSrcRoot
$this.proj = $proj
# Since later paths overwrite earlier files, check paths in reverse order
$this.reversePaths = @("$($this.proj.sdkPath)\Development\SrcOrig") +
$this.proj.include + @("$($this.proj.modSrcRoot)\Src")
[array]::Reverse($this.reversePaths)
}

[void]ParseLine([string] $outTxt) {
([StdoutReceiver]$this).ParseLine($outTxt)
$messagePattern = "^(.*)\(([0-9]*)\) : (.*)$"
if (($outTxt -Match "Error|Warning") -And ($outTxt -Match $messagePattern)) {
# And just do a regex replace on the sdk Development directory with the mod src directory.
# The pattern needs escaping to avoid backslashes in the path being interpreted as regex escapes, etc.
$pattern = [regex]::Escape($this.developmentDirectory)
# n.b. -Replace is case insensitive
$replacementTxt = $outtxt -Replace $pattern, $this.modSrcRoot
# this syntax works with both VS Code and ModBuddy
$outTxt = $replacementTxt -Replace $messagePattern, '$1($2) : $3'
# extract original path from $matches automatic variable created by above -Match
$origPath = $matches[1]

# create regex pattern specifically from the part we're interested in replacing
$pattern = [regex]::Escape("$($this.proj.sdkPath)\Development\Src")

$found = $false
foreach ($checkPath in $this.reversePaths) {
$testPath = $origPath -Replace $pattern,$checkPath
# if the file exists, it's certainly the one that caused the error
if (Test-Path $testPath) {
# Normalize path to get rid of `..`s
$testPath = [IO.Path]::GetFullPath($testPath)
# this syntax works with both VS Code and ModBuddy
$outTxt = $outTxt -Replace $messagePattern, ($testPath + '($2) : $3')
$found = $true
break
}
}
if (-not $found) {
$outTxt = $outTxt -Replace $messagePattern, ($origPath + '($2) : $3')
}
}

$summPattern = "^(Success|Failure) - ([0-9]+) error\(s\), ([0-9]+) warning\(s\) \(([0-9]+) Unique Errors, ([0-9]+) Unique Warnings\)"
Expand Down