Skip to content

Commit

Permalink
add pwsh build_samples script
Browse files Browse the repository at this point in the history
  • Loading branch information
akashchi committed Jan 16, 2024
1 parent 585a7dc commit 5531a1c
Showing 1 changed file with 58 additions and 0 deletions.
58 changes: 58 additions & 0 deletions samples/cpp/build_samples_msvc.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# Copyright (C) 2018-2024 Intel Corporation
# SPDX-License-Identifier: Apache-2.0

# Arguments parsing
param (
[string]$BuildDirectory = "",
[string]$InstallDirectory = "",
[switch]$Help,
[switch]$h
)

$SourceDirectory = Split-Path $MyInvocation.MyCommand.Path
$SamplesType = (Get-Item $SourceDirectory).Name
$BuildDirectory = if ($BuildDirectory) {$BuildDirectory} else {"$Env:USERPROFILE/Documents/Intel/OpenVINO/openvino_${SamplesType}_samples_build"}

if ($Help -or $h) {
Write-Host "
Build OpenVINO Runtime samples
Options:
-Help/-h Print the help message and exit
-BuildDirectory Specify the samples build directory. Default is $BuildDirectory
-InstallDirectory Specify the samples install directory
"
exit 0
}

if (-not $Env:INTEL_OPENVINO_DIR) {
$SetupVars = Join-Path $SourceDirectory "../../setupvars.ps1"
if (Test-Path $SetupVars) {
& $SetupVars
}
else
{
Write-Host "
Failed to set the environment variables automatically. To fix, run the following command:
<INTEL_OPENVINO_DIR>/setupvars.ps1
where INTEL_OPENVINO_DIR is the OpenVINO installation directory
"
exit 1
}
}

Set-Location -Path $SourceDirectory
New-Item -Path $BuildDirectory -ItemType Directory -Force
Set-Location $BuildDirectory
cmake -DCMAKE_DISABLE_FIND_PACKAGE_PkgConfig=ON $SourceDirectory

Write-Host "Building command: cmake --build "$BuildDirectory" --config Release --parallel"
cmake --build "$BuildDirectory" --config Release --parallel

if ($InstallDirectory) {
cmake -DCMAKE_INSTALL_PREFIX="$InstallDirectory" -DCOMPONENT=samples_bin -P "$BuildDirectory/cmake_install.cmake"
Write-Host "Samples are built and installed into $InstallDirectory"
}
else
{
Write-Host "Samples are built in $BuildDirectory"
}

0 comments on commit 5531a1c

Please sign in to comment.