-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgenerate.ps1
More file actions
54 lines (46 loc) · 1.59 KB
/
Copy pathgenerate.ps1
File metadata and controls
54 lines (46 loc) · 1.59 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
#!/usr/bin/env pwsh
param(
[string]$Winmd,
[string]$Codegen = "dynwinrt-codegen"
)
$ErrorActionPreference = "Stop"
$caller = (Get-Location).Path
function Resolve-CallerPath([string]$Path) {
if ([System.IO.Path]::IsPathRooted($Path)) {
return [System.IO.Path]::GetFullPath($Path)
}
return [System.IO.Path]::GetFullPath((Join-Path $caller $Path))
}
if ($Winmd) {
$Winmd = Resolve-CallerPath $Winmd
} else {
$Winmd = Get-ChildItem `
"C:\Program Files (x86)\Windows Kits\10\UnionMetadata" `
-Filter Windows.winmd `
-Recurse `
-ErrorAction SilentlyContinue |
Sort-Object FullName -Descending |
Select-Object -First 1 -ExpandProperty FullName
}
if (-not $Winmd -or -not (Test-Path -LiteralPath $Winmd -PathType Leaf)) {
throw "Windows.winmd was not found. Install a Windows 10/11 SDK or pass -Winmd."
}
$codegenCandidate = Resolve-CallerPath $Codegen
if (Test-Path -LiteralPath $codegenCandidate -PathType Leaf) {
$codegenCommand = $codegenCandidate
} else {
$codegenCommand = (Get-Command $Codegen -ErrorAction Stop).Source
}
$output = Join-Path $PSScriptRoot "generated"
if (Test-Path -LiteralPath $output) {
Remove-Item -LiteralPath $output -Recurse -Force
}
& $codegenCommand generate `
--winmd $Winmd `
--class-name "Windows.Security.Cryptography.CryptographicBuffer,Windows.Security.Cryptography.Core.HashAlgorithmProvider" `
--lang py `
--output $output
if ($LASTEXITCODE -ne 0) {
throw "dynwinrt-codegen failed with exit code $LASTEXITCODE"
}
Write-Host "Generated cryptography bindings in $output"