-
Notifications
You must be signed in to change notification settings - Fork 121
Expand file tree
/
Copy pathbuild_no-options.ps1
More file actions
84 lines (70 loc) · 2.23 KB
/
Copy pathbuild_no-options.ps1
File metadata and controls
84 lines (70 loc) · 2.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[CmdletBinding(PositionalBinding = $false)]
param(
[ValidateSet("DML", "CUDA", "")]
[string]$Backend = "",
[ValidateSet("Release", "RelWithDebInfo", "MinSizeRel", "Debug")]
[string]$Configuration = "Release",
[switch]$Help,
[switch]$NonInteractive,
[switch]$DryRun
)
Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"
function Select-Backend {
param([switch]$NonInteractive)
if ($NonInteractive) {
throw "Backend is required in non-interactive mode. Use -Backend DML or -Backend CUDA."
}
Write-Host "Select build backend"
Write-Host " 1) DML"
Write-Host " 2) CUDA"
while ($true) {
$choice = Read-Host "Choose DML or CUDA"
if ($null -eq $choice) {
throw "No backend was selected."
}
switch -Regex ($choice.Trim()) {
"^(1|d|dml)$" { return "DML" }
"^(2|c|cuda)$" { return "CUDA" }
}
Write-Host "Please enter DML, CUDA, 1, or 2."
}
}
if ($Help) {
Write-Host "Usage:"
Write-Host " .\build_no-options.bat"
Write-Host " powershell -ExecutionPolicy Bypass -File .\build_no-options.ps1 -Backend DML"
Write-Host " powershell -ExecutionPolicy Bypass -File .\build_no-options.ps1 -Backend CUDA"
Write-Host ""
Write-Host "Runs cmake --build against an existing build tree. Dependencies and OpenCV must already be prepared."
exit 0
}
$repoRoot = Split-Path -Parent $MyInvocation.MyCommand.Path
. (Join-Path $repoRoot "tools\build_common.ps1")
if ([string]::IsNullOrWhiteSpace($Backend)) {
$Backend = Select-Backend -NonInteractive:$NonInteractive
}
$buildDir = if ($Backend -eq "CUDA") {
"build\cuda"
}
else {
"build\dml"
}
$buildPath = Join-Path $repoRoot $buildDir
if (-not (Test-Path -LiteralPath $buildPath)) {
throw "Build tree not found: $buildPath. Run BUILDER first to prepare dependencies and configure this backend."
}
Write-Host "[build_no-options] Running $Backend main-program build..."
$buildArgs = @(
"--build", $buildPath,
"--config", $Configuration,
"--target", "ai",
"--parallel"
)
if ($DryRun) {
Write-Host ">> cmake $($buildArgs -join ' ')"
exit 0
}
Import-VisualStudioEnvironment
& "cmake" @buildArgs
exit $LASTEXITCODE