-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgenerate.ps1
More file actions
64 lines (52 loc) · 1.83 KB
/
Copy pathgenerate.ps1
File metadata and controls
64 lines (52 loc) · 1.83 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
#!/usr/bin/env pwsh
param(
[Parameter(Mandatory)]
[string]$AppLifecycleWinmd,
[Parameter(Mandatory)]
[string]$RefList,
[Parameter(Mandatory)]
[string]$BootstrapDll,
[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))
}
$AppLifecycleWinmd = Resolve-CallerPath $AppLifecycleWinmd
$RefList = Resolve-CallerPath $RefList
$BootstrapDll = Resolve-CallerPath $BootstrapDll
foreach ($path in @($AppLifecycleWinmd, $RefList, $BootstrapDll)) {
if (-not (Test-Path -LiteralPath $path -PathType Leaf)) {
throw "Required input was not found: $path"
}
}
$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"
$runtime = Join-Path $PSScriptRoot ".runtime"
if (Test-Path -LiteralPath $output) {
Remove-Item -LiteralPath $output -Recurse -Force
}
New-Item -ItemType Directory -Force -Path $output, $runtime | Out-Null
& $codegenCommand generate `
--winmd $AppLifecycleWinmd `
--ref-list $RefList `
--class-name "Microsoft.Windows.AppLifecycle.AppInstance" `
--lang py `
--output $output
if ($LASTEXITCODE -ne 0) {
throw "dynwinrt-codegen failed with exit code $LASTEXITCODE"
}
Copy-Item -LiteralPath $BootstrapDll `
-Destination (Join-Path $runtime "Microsoft.WindowsAppRuntime.Bootstrap.dll") `
-Force
Write-Host "Generated AppLifecycle bindings in $output"
Write-Host "Copied the bootstrap DLL to $runtime"