File: run_iwyu.ps1

package info (click to toggle)
monado 25.0.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 22,708 kB
  • sloc: cpp: 175,132; ansic: 141,570; python: 2,913; java: 753; xml: 735; sh: 403; javascript: 255; makefile: 58
file content (82 lines) | stat: -rw-r--r-- 2,047 bytes parent folder | download
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright 2022, Collabora, Ltd.
# SPDX-License-Identifier: BSL-1.0
[CmdletBinding()]
param (
    [Parameter()]
    [string]
    $IwyuBinDir,

    [Parameter()]
    [string]
    $Python
)

$ErrorActionPreference = 'Stop'
Push-Location $PSScriptRoot/..

if (!$IwyuBinDir) {
    $cmd = Get-Command "iwyu" -ErrorAction SilentlyContinue
    if ($cmd) {
        $IwyuBinDir = $cmd.Source
    }
}
if (!$IwyuBinDir) {
    Write-Error "Please specify IwyuBinDir - could not find on path"
    return -1
}

if (!$Python) {
    $cmd = Get-Command "python3" -ErrorAction SilentlyContinue
    if ($cmd) {
        $Python = $cmd.Source
    }
}
if (!$Python) {
    $cmd = Get-Command "python" -ErrorAction SilentlyContinue
    if ($cmd) {
        $Python = $cmd.Source
    }
}
if (!$Python) {
    Write-Error "Please specify Python - could not find on path"
    return -1
}

$iwyuShareDir = Get-Item -Path $IwyuBinDir/../share/include-what-you-use

function Create-Args {

    [CmdletBinding()]
    Param(

        [Parameter(ValueFromPipeline)]
        $FullName
    )

    process {
        $item = Get-Item $FullName
        Write-Output '-Xiwyu'
        Write-Output ("--mapping_file=" + $item.FullName)
    }
}

$python_args = @(
    (Join-Path $IwyuBinDir "iwyu_tool.py")
    "-p"
    "build"
    "src/xrt"
    "--"
)
$python_args = $python_args + (Join-Path $iwyuShareDir 'iwyu.gcc.imp' | Create-Args)
$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "*intrinsics.imp" | Create-Args)
$python_args = $python_args + (Get-ChildItem -Path $iwyuShareDir -Filter "libcxx.imp" | Create-Args)
Write-Host $python_args
$our_mapping_file = Join-Path (Get-Location) scripts/mapping.imp

$python_args = $python_args + @("-Xiwyu", "--mapping_file=$our_mapping_file")
# & $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

Start-Process -FilePath $Python -ArgumentList $python_args -PassThru -Wait -NoNewWindow

Pop-Location