This repository has been archived on 2026-10-29. You can view files and clone it, but you cannot make any changes to its state, such as pushing and creating new issues, pull requests or comments.
CultMath/tools/compile-spirv-metal.ps1
2026-06-11 06:57:22 +01:00

34 lines
962 B
PowerShell

param(
[Parameter(Mandatory = $true)]
[string]$SpirvPath,
[Parameter(Mandatory = $true)]
[string]$OutputPath,
[int]$MslVersion = 23000,
[string]$SpirvCrossPath = ""
)
$ErrorActionPreference = "Stop"
$repoRoot = Resolve-Path (Join-Path $PSScriptRoot "..")
if (-not $SpirvCrossPath) {
$SpirvCrossPath = Join-Path $repoRoot ".tools\spirv-cross\build\spirv-cross.exe"
}
if (-not (Test-Path $SpirvCrossPath)) {
throw "SPIRV-Cross not found at '$SpirvCrossPath'. Run tools\get-spirv-cross.ps1 first or pass -SpirvCrossPath."
}
$resolvedSpirv = Resolve-Path $SpirvPath
$outputDirectory = Split-Path -Parent $OutputPath
if ($outputDirectory) {
New-Item -ItemType Directory -Force -Path $outputDirectory | Out-Null
}
& $SpirvCrossPath $resolvedSpirv --msl --msl-version $MslVersion --output $OutputPath
if ($LASTEXITCODE -ne 0) {
throw "spirv-cross failed with exit code $LASTEXITCODE."
}
Get-Item -LiteralPath $OutputPath