-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathGenerate-HandleWrappers.ps1
More file actions
51 lines (46 loc) · 2.09 KB
/
Generate-HandleWrappers.ps1
File metadata and controls
51 lines (46 loc) · 2.09 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
<#
.SYNOPSIS
Generates the wrappers for handles from the headers in the Ubiquity.NET.LibLLVM NuGet Package
.DESCRIPTION
This is used 'off-line' (by a developer) to generate the source for the handle wrappers. It is
NOT run during an automated build as the generator itself is dependent on the CppSharp library
that only supports the X64 architecture. Automated builds may (at some point in the future)
run on any architecture supported by .NET so cannot generate the sources at build time. A developer
machine generating the wrappers is assumed X64 (Windows, Linux, or Mac)
.PARAMETER SkipRun
This parameter is used for inner loop testing to generate the response file so the paths
match the actual version of the package used. It skips actually building/running the
generator so that a developer can debug the run of that stage.
#>
Param(
[switch]$SkipRun
)
Push-Location $PSScriptRoot
$oldPath = $env:Path
try
{
$ErrorActionPreference = 'stop'
$generatorProj = '.\src\Interop\LlvmBindingsGenerator\LlvmBindingsGenerator.csproj'
$rspPath = Join-Path $PSScriptRoot 'generator.rsp'
Write-Information "Generating response file: $rspPath via GenerateResponseFile target in $generatorProj"
dotnet msbuild -tl:off -restore -target:GenerateResponseFile -property:HandleGeneratorResponeFilePath=`""$rspPath"`" $generatorProj
if(!$SkipRun)
{
Write-Information 'Generating Handle wrapper source...'
dotnet run --no-restore --project $generatorProj -- @$rspPath
}
}
catch
{
# Everything from the official docs to the various articles in the blog-sphere say this isn't needed
# and in fact it is redundant - They're all WRONG! By re-throwing the exception the original location
# information is retained and the error reported will include the correct source file and line number
# data for the error. Without this, only the error message is retained and the location information is
# Line 1, Column 1, of the outer most script file, which is, of course, completely useless.
throw
}
finally
{
Pop-Location
$env:Path = $oldPath
}