-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SCRIPTS] Introduce
build_samples
for Powershell (#22185)
* add pwsh build_samples script * install ps1 script, use it for win workflow * correct syntax * use pwsh script in win cc samples building * align args; add aliases; rm postfixes * return postfix for bat
- Loading branch information
Showing
4 changed files
with
113 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Copyright (C) 2018-2024 Intel Corporation | ||
# SPDX-License-Identifier: Apache-2.0 | ||
|
||
# Arguments parsing | ||
param ( | ||
[Alias("b")] | ||
[string]$BuildDirectory = "", | ||
|
||
[Alias("i")] | ||
[string]$InstallDirectory = "", | ||
|
||
[Alias("h")] | ||
[switch]$Help | ||
) | ||
|
||
$ErrorActionPreference = "Stop" | ||
|
||
$SourceDirectory = Split-Path $MyInvocation.MyCommand.Path | ||
$SamplesType = (Get-Item $SourceDirectory).Name | ||
$DefaultBuildDirectory = "$Env:USERPROFILE/Documents/Intel/OpenVINO/openvino_${SamplesType}_samples_build" | ||
|
||
if ($Help) { | ||
Write-Host " | ||
Build OpenVINO Runtime samples | ||
Options: | ||
-h/-Help Print the help message and exit | ||
-b/-BuildDirectory Specify the samples build directory. Default is '$DefaultBuildDirectory' | ||
-i/-InstallDirectory Specify the samples install directory | ||
" | ||
exit 0 | ||
} | ||
|
||
$BuildDirectory = if ($BuildDirectory) {$BuildDirectory} else {$DefaultBuildDirectory} | ||
|
||
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 . --config Release --parallel" | ||
cmake --build . --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" | ||
} |