-
Notifications
You must be signed in to change notification settings - Fork 25
/
format.ps1
54 lines (48 loc) · 1.3 KB
/
format.ps1
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
function ShouldFormat($FileName)
{
return $FileName -clike "*.h" `
-or $FileName -clike "*.c" `
-or $FileName -clike "*.cpp" `
-or $FileName -clike "*.cc"
}
function FormatFiles($Root)
{
if (Test-Path -Path $Root -PathType Leaf)
{
if (ShouldFormat($Root))
{
Write-Output "Formatting $($Root)"
clang-format -i --style=file $File.Path
}
continue
}
$Folder = (New-Object -Com Scripting.FileSystemObject).GetFolder($Root)
$Files = $Folder.Files | Where-Object { ShouldFormat($_.Name) }
foreach ($File in $Files)
{
Write-Output "Formatting $($File.Path)"
clang-format -i --style=file $File.Path
}
foreach ($SubFolder in $Folder.Subfolders)
{
$CurrentItem = Get-Item $SubFolder.Path -ErrorAction SilentlyContinue
if ($CurrentItem -and !$CurrentItem.Attributes.ToString().Contains("ReparsePoint"))
{
FormatFiles($SubFolder.Path)
}
}
}
$ErrorActionPreference = "Stop"
foreach ($Item in Get-ChildItem $PSScriptRoot)
{
if ($Item.Name -ne "build" -and $Item.Name -ne "third_party")
{
FormatFiles($Item.FullName)
}
}
black .
pylint build.py
pylint generate_op_defs_core.py
pylint test/plugin
pylint tfdml
Write-Output "Done!"