# Compiles the loader plus the self test and runs it. # # ASCII only, for the same reason as build.ps1: PowerShell 5.1 misreads a .ps1 # that has no byte order mark. $ErrorActionPreference = 'Stop' $Repo = Split-Path -Parent $PSScriptRoot if (-not $Repo) { $Repo = $PSCommandPath | Split-Path -Parent | Split-Path -Parent } $Out = Join-Path $Repo 'build' function Say($text) { Write-Host " $text" -ForegroundColor Cyan } New-Item -ItemType Directory -Force -Path $Out | Out-Null $mainOut = Join-Path $Out 'classes' Remove-Item $mainOut -Recurse -Force -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path $mainOut | Out-Null $mainFiles = @(Get-ChildItem (Join-Path $Repo 'src\main\java') -Recurse -Filter '*.java' | ForEach-Object { $_.FullName }) & javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -d $mainOut $mainFiles if ($LASTEXITCODE -ne 0) { Write-Host ' Main failed.' -ForegroundColor Red; exit 1 } $testOut = Join-Path $Out 'test-classes' Remove-Item $testOut -Recurse -Force -ErrorAction SilentlyContinue New-Item -ItemType Directory -Force -Path $testOut | Out-Null $testFiles = @(Get-ChildItem (Join-Path $Repo 'src\test\java') -Recurse -Filter '*.java' | ForEach-Object { $_.FullName }) & javac -encoding UTF-8 --release 17 -Xlint:-options -nowarn -cp $mainOut -d $testOut $testFiles if ($LASTEXITCODE -ne 0) { Write-Host ' Test failed to compile.' -ForegroundColor Red; exit 1 } Say "compiled $($mainFiles.Count) main + $($testFiles.Count) test files" & java -cp "$mainOut;$testOut" net.rustnotmc.test.SelfTest (Join-Path $Out 'selftest') if ($LASTEXITCODE -ne 0) { Write-Host '' Write-Host ' SELFTEST FAILED' -ForegroundColor Red exit 1 } Write-Host '' Write-Host ' Self test passed.' -ForegroundColor Green