|
| 1 | +#=============================================================================== |
| 2 | +# Copyright 2026 Intel Corporation |
| 3 | +# |
| 4 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | +# you may not use this file except in compliance with the License. |
| 6 | +# You may obtain a copy of the License at |
| 7 | +# |
| 8 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | +# |
| 10 | +# Unless required by applicable law or agreed to in writing, software |
| 11 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | +# See the License for the specific language governing permissions and |
| 14 | +# limitations under the License. |
| 15 | +#=============================================================================== |
| 16 | + |
| 17 | +param( |
| 18 | + [string]$ReleaseDir = ".\bazel-bin\release\daal\latest", |
| 19 | + [string]$ExamplesDir = "examples\oneapi\cpp", |
| 20 | + [string]$ExampleSource = "source\basic_statistics\basic_statistics_dense_batch.cpp", |
| 21 | + [string]$ExampleTarget = "basic_statistics_dense_batch" |
| 22 | +) |
| 23 | + |
| 24 | +$ErrorActionPreference = "Stop" |
| 25 | + |
| 26 | +$releasePath = (Resolve-Path $ReleaseDir).Path |
| 27 | +$examplesPath = Join-Path $releasePath $ExamplesDir |
| 28 | +$buildPath = Join-Path $examplesPath "Build" |
| 29 | + |
| 30 | +if (Test-Path $buildPath) { |
| 31 | + Remove-Item -Recurse -Force $buildPath |
| 32 | +} |
| 33 | + |
| 34 | +$pathEntries = @( |
| 35 | + (Join-Path $releasePath "redist\intel64"), |
| 36 | + (Join-Path $releasePath "lib") |
| 37 | +) |
| 38 | + |
| 39 | +$tbbDirCandidates = @( |
| 40 | + ".\oneapi\tbb\latest\lib\cmake\tbb", |
| 41 | + ".\__deps\tbb\win\tbb\lib\cmake\tbb" |
| 42 | +) |
| 43 | +$tbbRedistCandidates = @( |
| 44 | + ".\oneapi\tbb\latest\redist\intel64\vc_mt", |
| 45 | + ".\__deps\tbb\win\tbb\redist\intel64\vc_mt" |
| 46 | +) |
| 47 | + |
| 48 | +$cmakeArgs = @( |
| 49 | + "-B", $buildPath, |
| 50 | + "-S", $examplesPath, |
| 51 | + "-DONEDAL_LINK=dynamic", |
| 52 | + "-DCMAKE_PREFIX_PATH=$releasePath", |
| 53 | + "-DEXAMPLES_LIST=$ExampleTarget" |
| 54 | +) |
| 55 | + |
| 56 | +foreach ($candidate in $tbbDirCandidates) { |
| 57 | + if (Test-Path $candidate) { |
| 58 | + $cmakeArgs += "-DTBB_DIR=$((Resolve-Path $candidate).Path)" |
| 59 | + break |
| 60 | + } |
| 61 | +} |
| 62 | + |
| 63 | +foreach ($candidate in $tbbRedistCandidates) { |
| 64 | + if (Test-Path $candidate) { |
| 65 | + $pathEntries += (Resolve-Path $candidate).Path |
| 66 | + break |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +$env:PATH = (($pathEntries | Where-Object { Test-Path $_ }) -join ";") + ";" + $env:PATH |
| 71 | + |
| 72 | +Write-Host "Configuring CMake example from Bazel release: $examplesPath" |
| 73 | +cmake @cmakeArgs |
| 74 | + |
| 75 | +Write-Host "Building CMake example target: $ExampleTarget" |
| 76 | +cmake --build $buildPath --config Release --target $ExampleTarget |
| 77 | + |
| 78 | +$exampleExe = Get-ChildItem -Path @($buildPath, $examplesPath) -Recurse -Filter "$ExampleTarget.exe" -File | |
| 79 | + Select-Object -First 1 |
| 80 | +if ($null -eq $exampleExe) { |
| 81 | + Write-Host "Available executables under examples directory:" |
| 82 | + Get-ChildItem -Path $examplesPath -Recurse -Filter "*.exe" -File | ForEach-Object { Write-Host " $($_.FullName)" } |
| 83 | + throw "Cannot find built example executable: $ExampleTarget.exe" |
| 84 | +} |
| 85 | + |
| 86 | +Write-Host "Running CMake example: $($exampleExe.FullName)" |
| 87 | +Push-Location $examplesPath |
| 88 | +try { |
| 89 | + & $exampleExe.FullName |
| 90 | + if ($LASTEXITCODE -ne 0) { |
| 91 | + throw "Example failed with exit code $LASTEXITCODE" |
| 92 | + } |
| 93 | +} |
| 94 | +finally { |
| 95 | + Pop-Location |
| 96 | +} |
0 commit comments