blob: a20a9ce0ba3d1227d7db5693d869f9040af9d6f6 (
plain)
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
|
[CmdletBinding()]
Param(
[Parameter(Mandatory=$True)]
[string]$Root
)
$Root = Resolve-Path -LiteralPath $Root
$clangFormat = Get-Command 'clang-format' -ErrorAction 'SilentlyContinue'
if ($null -ne $clangFormat)
{
$clangFormat = $clangFormat.Source
}
if ($IsWindows)
{
if ([String]::IsNullOrEmpty($clangFormat) -or -not (Test-Path $clangFormat))
{
$clangFormat = 'C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\x64\bin\clang-format.exe'
}
if (-not (Test-Path $clangFormat))
{
$clangFormat = 'C:\Program Files\LLVM\bin\clang-format.exe'
}
}
if ([String]::IsNullOrEmpty($clangFormat) -or -not (Test-Path $clangFormat))
{
Write-Error 'clang-format not found; is it installed?'
throw
}
$toolsrc = Get-Item "$Root/toolsrc"
Push-Location $toolsrc
try
{
$files = Get-ChildItem -Recurse -LiteralPath "$toolsrc/src" -Filter '*.cpp'
$files += Get-ChildItem -Recurse -LiteralPath "$toolsrc/include/vcpkg" -Filter '*.h'
$files += Get-ChildItem -Recurse -LiteralPath "$toolsrc/include/vcpkg-test" -Filter '*.h'
$files += Get-Item "$toolsrc/include/pch.h"
$fileNames = $files.FullName
& $clangFormat -style=file -i @fileNames
}
finally
{
Pop-Location
}
|