-
Notifications
You must be signed in to change notification settings - Fork 1
/
Update-OpenXR.ps1
92 lines (75 loc) · 3.57 KB
/
Update-OpenXR.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
91
92
# Get the Visual Studio executable for building
$vsExe = & "C:\Program Files (x86)\Microsoft Visual Studio\Installer\vswhere.exe" -property productPath
# This tell VS to build with a partcular 'Release|x64' style mode
function Build {
param([parameter(Mandatory)][string] $mode)
& $vsExe 'OPENXR.sln' '/Build' $mode '/Project' 'ALL_BUILD' | Out-Null
return $LASTEXITCODE
}
# This'll build and copy files for a particular OpenXR configuration
function Build-Config {
param([parameter(Mandatory)][string] $config, [parameter(Mandatory)][string] $target)
Write-Host "Beginning build: $config"
Push-Location -Path $config
# Build release and debug mode for this configuration
$result = Build -mode "Release|$target"
if ($result -ne 0) {
Write-Host "--- $config build failed! Stopping build! ---" -ForegroundColor red
exit
}
$result = Build -mode "Debug|$target"
if ($result -ne 0) {
Write-Host "--- $config debug build failed! Stopping build! ---" -ForegroundColor red
exit
}
Write-Host "Built $config complete!" -ForegroundColor green
#copy files into the project
Copy-Item -Path "src\loader\Release\openxr_loader.lib" -Destination "..\..\..\StereoKitC\lib\bin\$config\Release\openxr_loader.lib" -Force -Confirm:$false
Copy-Item -Path "src\loader\Debug\openxr_loader.lib" -Destination "..\..\..\StereoKitC\lib\bin\$config\Debug\openxr_loader.lib" -Force -Confirm:$false
Copy-Item -Path "src\loader\Debug\openxr_loader.pdb" -Destination "..\..\..\StereoKitC\lib\bin\$config\Debug\openxr_loader.pdb" -Force -Confirm:$false
Pop-Location
}
# Clone the repository
& git clone "https://github.com/KhronosGroup/OpenXR-SDK.git"
Push-Location -Path "OpenXR-SDK"
# Create build folders
New-Item -Path . -Name "build" -ItemType "directory" | Out-Null
Push-Location -Path "build"
New-Item -Path . -Name "x64" -ItemType "directory" | Out-Null
New-Item -Path . -Name "x64_UWP" -ItemType "directory" | Out-Null
New-Item -Path . -Name "ARM64" -ItemType "directory" | Out-Null
New-Item -Path . -Name "ARM64_UWP" -ItemType "directory" | Out-Null
# cmake each project configuration
Push-Location -Path "x64"
Write-Host 'Making x64' -ForegroundColor green
& cmake -G "Visual Studio 16 2019" -A x64 ../..
Write-Host 'Made x64' -ForegroundColor green
Pop-Location
Push-Location -Path "x64_UWP"
Write-Host 'Making x64_UWP' -ForegroundColor green
& cmake -G "Visual Studio 16 2019" -A x64 "-DCMAKE_SYSTEM_NAME=WindowsStore" "-DCMAKE_SYSTEM_VERSION=10.0" "-DDYNAMIC_LOADER=OFF" ../..
Write-Host 'Made x64_UWP' -ForegroundColor green
Pop-Location
Push-Location -Path "ARM64"
Write-Host 'Making ARM64' -ForegroundColor green
& cmake -G "Visual Studio 16 2019" -A ARM64 ../..
Write-Host 'Made ARM64' -ForegroundColor green
Pop-Location
Push-Location -Path "ARM64_UWP"
Write-Host 'Making ARM64_UWP' -ForegroundColor green
& cmake -G "Visual Studio 16 2019" -A ARM64 "-DCMAKE_SYSTEM_NAME=WindowsStore" "-DCMAKE_SYSTEM_VERSION=10.0" "-DDYNAMIC_LOADER=OFF" ../..
Write-Host 'Made ARM64_UWP' -ForegroundColor green
Pop-Location
# Now we'll build each project
Build-Config -config "x64" -target "x64"
Build-Config -config "x64_UWP" -target "x64"
Build-Config -config "ARM64" -target "ARM64"
Build-Config -config "ARM64_UWP" -target "ARM64"
Pop-Location
# Copy include files
Write-Host 'Copying headers'
Copy-Item -Path "include\openxr\*.h" -Destination "..\StereoKitC\lib\include\openxr" -Force -Confirm:$false
Write-Host 'Headers copied!' -ForegroundColor green
# Clean up and delete files!
Pop-Location
Remove-Item -Path "OpenXR-SDK" -Recurse -Force -Confirm:$false