forked from microsoft/Azure-Kinect-Sensor-SDK
-
Notifications
You must be signed in to change notification settings - Fork 0
/
verify-windows.ps1
90 lines (74 loc) · 3.1 KB
/
verify-windows.ps1
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
85
86
87
88
89
90
# Copyright (c) Microsoft Corporation. All rights reserved.
# Licensed under the MIT License.
$ErrorActionPreference = "Stop"
function Download-ToTemp
{
param
(
[Parameter(Mandatory)]
[string] $url
)
$filename = Split-Path -Path $url -Leaf
if (-not ($filename))
{
Write-Error "Unable to parse filename from $url"
return $null
}
$tempDir = [System.IO.Path]::GetTempPath()
$path = Join-Path -Path $tempDir -ChildPath $filename
Write-Host -NoNewline "Downloading $url to $path..."
[Net.ServicePointManager]::SecurityProtocol = "tls12, tls11, tls"
Invoke-WebRequest -Uri $url -OutFile $path
Write-Host "Done"
return $path
}
# Download vswhere to temp dir
$url = "https://github.com/Microsoft/vswhere/releases/download/2.6.7/vswhere.exe"
$vswhere = Download-ToTemp -url $url
# Run vswhere to check for Visual Studio 2017 or Visual Studio 2019
$vsWhereOutput = (& $vswhere -prerelease -format xml)
$vsInstances = [xml]($vsWhereOutput)
if ((-not ($vsInstances)) -or (-not ($vsInstances.instances))) {
Write-Error "Error parsing vswhere output: $vsWhereOutput"
}
$instances = $vsInstances.SelectNodes("//instances/instance")
if ($instances.Count -eq 0) {
Write-Error "Visual Studio not installed. Please install Visual Studio 2017 or Visual Studio 2019"
}
$instances = $instances | Where-Object { [Version]$_.installationVersion -ge [Version]"15.0"}
if (-not $instances) {
Write-Error "Only Visual Studio 2017 and greater are supported"
}
# Check for cmake and ninja (installed as part of the Microsoft.VisualStudio.Component.VC.CMake.Project component)
$vsWhereOutput = (& $vswhere -prerelease -format xml -requires Microsoft.VisualStudio.Component.VC.CMake.Project)
$vsInstancesWithCMakeNinja = [xml]$vsWhereOutput
if ((-not $vsInstancesWithCMakeNinja) -or (-not ($vsInstancesWithCMakeNinja.instances))) {
if (-not (Get-Command -Name "cmake")) {
Write-Error "Unable to find cmake. Please install cmake and add it to your path"
}
if (-not (Get-Command -Name "ninja")) {
Write-Error "Unable to find ninja. Please install ninja and add it to your path"
}
}
# Check for clang-format
$vs158instances = $instances | Where-Object { [Version]$_.installationVersion -ge [Version]"15.8"}
if (-not $vs158instances) {
# Check for clang-format 6.0.0.
if (-not (Get-Command -Name "clang-format")) {
Write-Warning "clang-format 6.0.0 not detected! You will be unable to fix formatting issues."
} else {
if (-not (clang-format --version | Select-String "6.0.0")) {
Write-Warning "clang-format 6.0.0 not detected! You will be unable to fix formatting issues."
}
}
}
# Check for tar
if (-not (Get-Command -Name "tar")) {
Write-Error "Unable to find tar. Please install tar and add it to your path"
}
# Check for python 3
if (-not (Get-Command -All -Name "python" | Where-Object { $_.Version -ge [Version]"3.0" }))
{
Write-Error "Unable to find python 3. Please install python3 and add it to your path"
}
Write-Host "Machine setup. Please use Visual Studio Developer Command prompt to build."