Files
healer-man/scripts/asset-pipeline/bootstrap-ktx.ps1
T
2026-08-14 15:56:39 -04:00

38 lines
1.4 KiB
PowerShell

$ErrorActionPreference = "Stop"
$version = "4.4.2"
$expectedSha256 = "1f323b0fec19794f5e6c0425a61d4b1da396872a10be862d105f4f4b2d2957fe"
$projectRoot = (Resolve-Path (Join-Path $PSScriptRoot "../..")).Path
$toolsRoot = Join-Path $projectRoot ".tools"
$installer = Join-Path $toolsRoot "KTX-Software-$version-Windows-x64.exe"
$installDirectory = Join-Path $toolsRoot "ktx"
$downloadUrl = "https://github.com/KhronosGroup/KTX-Software/releases/download/v$version/KTX-Software-$version-Windows-x64.exe"
New-Item -ItemType Directory -Force $toolsRoot | Out-Null
if (-not (Test-Path -LiteralPath $installer)) {
Invoke-WebRequest -Uri $downloadUrl -OutFile $installer
}
$actualSha256 = (Get-FileHash -Algorithm SHA256 -LiteralPath $installer).Hash.ToLowerInvariant()
if ($actualSha256 -ne $expectedSha256) {
throw "KTX-Software installer checksum mismatch. Expected $expectedSha256, received $actualSha256."
}
$toktx = Join-Path $installDirectory "bin/toktx.exe"
if (-not (Test-Path -LiteralPath $toktx)) {
$process = Start-Process -FilePath $installer `
-ArgumentList @("/S", "/D=$installDirectory") `
-Wait `
-PassThru `
-WindowStyle Hidden
if ($process.ExitCode -ne 0) {
throw "KTX-Software installer exited with code $($process.ExitCode)."
}
}
if (-not (Test-Path -LiteralPath $toktx)) {
throw "KTX-Software installation completed without producing $toktx."
}
Write-Output "KTX-Software $version is ready at $installDirectory"