forked from KhronosGroup/OpenXR-Hpp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate-openxr-hpp.ps1
74 lines (62 loc) · 1.93 KB
/
generate-openxr-hpp.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
[CmdletBinding()]
param (
[Parameter()]
[string]
$OpenXRRepo = (Join-Path (Get-Item $PSScriptRoot) "../OpenXR-SDK-Source"),
[Parameter()]
[string]
$Python = "python3",
[Parameter()]
[string]
$ClangFormat = "clang-format",
[Parameter()]
[switch]
$Noisy = $false,
[Parameter()]
[switch]
$Docs = $false,
[Parameter()]
[string]
$Doxygen = "doxygen"
)
$Headers = foreach($line in Get-Content (Join-Path $PSScriptRoot headers.txt)) {
$line = $line.Trim()
# if (($line.Length -ne 0) -and ($line -notmatch "^#")) {
if ($line -match "^openxr") {
Write-Output $line
}
}
$Registry = Join-Path "$OpenXRRepo" "specification/registry/xr.xml"
$OutputLocation = Join-Path "$PSScriptRoot" "include/openxr"
$Script = Join-Path "$PSScriptRoot" "scripts/hpp_genxr.py"
# for progress bar
$Total = $Headers.Length + 1
$Counter = 0
foreach ($header in $Headers) {
$Counter++
$OutFile = (Join-Path $OutputLocation $header)
if (Test-Path $OutFile) {
Remove-Item $OutFile
}
$myArgs = "$Script","-registry","$Registry","-o","$OutputLocation","$header"
if ($Noisy -eq $false) {
$myArgs += "-quiet"
Write-Progress -Activity "Generating Headers" -CurrentOperation $header -PercentComplete (($Counter / $Total) * 100)
}
$process = (Start-Process $Python -NoNewWindow -Wait -PassThru -ArgumentList $myArgs )
if ($process.ExitCode -ne 0) {
throw "Generation failed while generating ${header} : ${process.ExitCode}"
}
# & $ClangFormat -style=file -i $OutFile
}
Write-Host "Formatting generated files"
if ($Noisy -eq $false) {
Write-Progress -Activity "Formatting Headers" -PercentComplete 100
}
& $ClangFormat -style=file -i ($Headers | ForEach-Object { Write-Output (Join-Path $OutputLocation $_) })
if ($Docs) {
if ($Noisy -eq $false) {
Write-Progress -Activity "Generating docs"
}
& $Doxygen Doxyfile
}