|
| 1 | +# build_and_test_trt_ep.ps1 |
| 2 | + |
| 3 | +# Change to the directory where this script is located |
| 4 | +Set-Location -Path $PSScriptRoot |
| 5 | +Write-Host "Current directory set to: $PSScriptRoot" |
| 6 | + |
| 7 | +# Stop on first error |
| 8 | +$ErrorActionPreference = "Stop" |
| 9 | + |
| 10 | +# Variables |
| 11 | +$SourceDir = "../" |
| 12 | +$BuildDir = "./" |
| 13 | +$BuildType = "Debug" |
| 14 | + |
| 15 | +# ORT settings |
| 16 | +$OrtVersion = "1.23.1" |
| 17 | +#$OrtZipUrl = "https://github.com/microsoft/onnxruntime/releases/download/v$OrtVersion/onnxruntime-win-x64-gpu-$OrtVersion.zip" |
| 18 | +$OrtZipUrl = "https://github.com/microsoft/onnxruntime/releases/download/v$OrtVersion/onnxruntime-win-x64-$OrtVersion.zip" |
| 19 | +$OrtZipPath = "onnxruntime.zip" |
| 20 | +$OrtHome = ".\ort_package" |
| 21 | + |
| 22 | +# Step 1: Download ONNX Runtime package |
| 23 | +if (!(Test-Path $OrtHome)) { |
| 24 | + Write-Host "=== Downloading ONNX Runtime $OrtVersion ===" |
| 25 | + Invoke-WebRequest -Uri $OrtZipUrl -OutFile $OrtZipPath |
| 26 | + |
| 27 | + Write-Host "=== Extracting ONNX Runtime to $OrtHome ===" |
| 28 | + Expand-Archive -Path $OrtZipPath -DestinationPath $OrtHome -Force |
| 29 | + |
| 30 | + # Clean up zip file |
| 31 | + Remove-Item $OrtZipPath |
| 32 | +} else { |
| 33 | + Write-Host "ONNX Runtime directory already exists. Skipping download." |
| 34 | +} |
| 35 | + |
| 36 | +# Step 2: Configure CMake |
| 37 | +$buildDir = "build" |
| 38 | +if (-Not (Test-Path $buildDir)) { |
| 39 | + Write-Host "Creating build directory..." |
| 40 | + New-Item -ItemType Directory -Path $buildDir | Out-Null |
| 41 | +} |
| 42 | +Set-Location -Path $buildDir |
| 43 | + |
| 44 | +Write-Host "=== Running CMake configure step ===" |
| 45 | +$OrtHome = "$PSScriptRoot\ort_package\onnxruntime-win-x64-$OrtVersion" |
| 46 | +cmake "-S" $SourceDir ` |
| 47 | + "-B" $BuildDir ` |
| 48 | + "-DCMAKE_BUILD_TYPE=$BuildType" ` |
| 49 | + "-DORT_HOME=$OrtHome" |
| 50 | + |
| 51 | +if ($LASTEXITCODE -ne 0) { |
| 52 | + Write-Error "CMake configuration failed!" |
| 53 | + exit 1 |
| 54 | +} |
| 55 | + |
| 56 | +# Step 3: Build |
| 57 | +Write-Host "=== Building project ===" |
| 58 | +cmake --build $BuildDir --config $BuildType --parallel |
| 59 | + |
| 60 | +if ($LASTEXITCODE -ne 0) { |
| 61 | + Write-Error "Build failed!" |
| 62 | + exit 1 |
| 63 | +} |
| 64 | + |
| 65 | +Write-Host "=== Build completed successfully! ===" |
0 commit comments