-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgenerate.ps1
More file actions
58 lines (48 loc) · 1.78 KB
/
Copy pathgenerate.ps1
File metadata and controls
58 lines (48 loc) · 1.78 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
#!/usr/bin/env pwsh
param(
[ValidateSet("x64", "arm64")]
[string]$Architecture = "x64",
[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))
}
. (Join-Path $PSScriptRoot "..\Resolve-WinAppSdkInputs.ps1")
$inputs = Resolve-DynWinRTWinAppSdkInputs `
-SampleRoot $PSScriptRoot `
-PrimaryWinmdNames "Microsoft.Windows.AppLifecycle.winmd" `
-Architecture $Architecture
$AppLifecycleWinmd = $inputs.PrimaryWinmds["Microsoft.Windows.AppLifecycle.winmd"]
$RefList = $inputs.RefList
$BootstrapDll = $inputs.BootstrapDll
$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"