diff options
| author | nicole mazzuca <mazzucan@outlook.com> | 2020-07-07 14:09:33 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-07 14:09:33 -0700 |
| commit | 9606917c81792c52097847fa8037907d92b161a2 (patch) | |
| tree | 6b58b8ead45c5b917542fd1585452c3715f1f604 /scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 | |
| parent | f8e975d44a6c8ae5855ece419696ea6abd050898 (diff) | |
| download | vcpkg-9606917c81792c52097847fa8037907d92b161a2.tar.gz vcpkg-9606917c81792c52097847fa8037907d92b161a2.zip | |
[vcpkg ci] Update formatting CI (#12314)
* stage checking formatting
this means that the port CI won't run if the formatting failed
* fix invalid names
* add formatting of manifests
* fix dependsOn name
* fix a thing
* CRs
* oops, typo
Diffstat (limited to 'scripts/azure-pipelines/windows/Check-CxxFormatting.ps1')
| -rw-r--r-- | scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 new file mode 100644 index 000000000..7f300164f --- /dev/null +++ b/scripts/azure-pipelines/windows/Check-CxxFormatting.ps1 @@ -0,0 +1,51 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True)] + [string]$Root, + [Parameter()] + [switch]$IgnoreErrors # allows one to just format +) + +$clangFormat = 'C:\Program Files\LLVM\bin\clang-format.exe' +if (-not (Test-Path $clangFormat)) +{ + Write-Error "clang-format not found; is it installed in the CI machines?" + 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 + + $changedFiles = & "$PSScriptRoot/Get-ChangedFiles.ps1" -Directory $toolsrc + if (-not $IgnoreErrors -and $null -ne $changedFiles) + { + $msg = @( + "", + "The formatting of the C++ files didn't match our expectation.", + "If your build fails here, you need to format the following files with:" + ) + $msg += " $(& $clangFormat -version)" + $msg += " $changedFiles" + $msg += "" + + $msg += "clang-format should produce the following diff:" + $msg += git diff $toolsrc + + Write-Error ($msg -join "`n") + throw + } +} +finally +{ + Pop-Location +} |
