The open source OpenXR runtime
1# Copyright 2022, Collabora, Ltd.
2# SPDX-License-Identifier: BSL-1.0
3[CmdletBinding()]
4param (
5 [Parameter()]
6 [string]
7 $IwyuBinDir,
8
9 [Parameter()]
10 [string]
11 $Python
12)
13
14$ErrorActionPreference = 'Stop'
15Push-Location $PSScriptRoot/..
16
17if (!$IwyuBinDir) {
18 $cmd = Get-Command "iwyu" -ErrorAction SilentlyContinue
19 if ($cmd) {
20 $IwyuBinDir = $cmd.Source
21 }
22}
23if (!$IwyuBinDir) {
24 Write-Error "Please specify IwyuBinDir - could not find on path"
25 return -1
26}
27
28if (!$Python) {
29 $cmd = Get-Command "python3" -ErrorAction SilentlyContinue
30 if ($cmd) {
31 $Python = $cmd.Source
32 }
33}
34if (!$Python) {
35 $cmd = Get-Command "python" -ErrorAction SilentlyContinue
36 if ($cmd) {
37 $Python = $cmd.Source
38 }
39}
40if (!$Python) {
41 Write-Error "Please specify Python - could not find on path"
42 return -1
43}
44
45$iwyuShareDir = Get-Item -Path $IwyuBinDir/../share/include-what-you-use
46
47function Create-Args {
48
49 [CmdletBinding()]
50 Param(
51
52 [Parameter(ValueFromPipeline)]
53 $FullName
54 )
55
56 process {
57 $item = Get-Item $FullName
58 Write-Output '-Xiwyu'
59 Write-Output ("--mapping_file=" + $item.FullName)
60 }
61}
62
63$python_args = @(
64 (Join-Path $IwyuBinDir "iwyu_tool.py")
65 "-p"
66 "build"
67 "src/xrt"
68 "--"
69)
70$python_args = $python_args + (Join-Path $iwyuShareDir 'iwyu.gcc.imp' | Create-Args)
71$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "*intrinsics.imp" | Create-Args)
72$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "libcxx.imp" | Create-Args)
73Write-Host $python_args
74$our_mapping_file = Join-Path (Get-Location) scripts/mapping.imp
75
76$python_args = $python_args + @("-Xiwyu", "--mapping_file=$our_mapping_file")
77# & $Python (Join-Path $IwyuBinDir "iwyu_tool.py") -p build src/xrt -- -Xiwyu "--mapping_file=$our_mapping_file" @python_args | Tee-Object -FilePath iwyu.txt -Encoding utf8
78
79Start-Process -FilePath $Python -ArgumentList $python_args -PassThru -Wait -NoNewWindow
80
81Pop-Location
82