diff options
Diffstat (limited to 'scripts')
| -rw-r--r-- | scripts/azure-pipelines/windows/azure-pipelines.yml | 6 | ||||
| -rw-r--r-- | scripts/azure-pipelines/windows/check-formatting.ps1 | 54 | ||||
| -rw-r--r-- | scripts/azure-pipelines/windows/provision-image.txt | 24 |
3 files changed, 84 insertions, 0 deletions
diff --git a/scripts/azure-pipelines/windows/azure-pipelines.yml b/scripts/azure-pipelines/windows/azure-pipelines.yml index a76b6afdf..1d18c0339 100644 --- a/scripts/azure-pipelines/windows/azure-pipelines.yml +++ b/scripts/azure-pipelines/windows/azure-pipelines.yml @@ -20,6 +20,12 @@ jobs: condition: always()
inputs:
filePath: 'scripts/azure-pipelines/windows/disk-space.ps1'
+ - task: Powershell@2
+ displayName: 'Check C++ Formatting'
+ condition: eq('${{ parameters.triplet }}', 'x86-windows')
+ inputs:
+ filePath: 'scripts/azure-pipelines/windows/check-formatting.ps1'
+ arguments: '-Toolsrc ./toolsrc'
# Note: D: is the Azure machines' temporary disk.
- task: CmdLine@2
displayName: 'Build vcpkg'
diff --git a/scripts/azure-pipelines/windows/check-formatting.ps1 b/scripts/azure-pipelines/windows/check-formatting.ps1 new file mode 100644 index 000000000..e3c3d213e --- /dev/null +++ b/scripts/azure-pipelines/windows/check-formatting.ps1 @@ -0,0 +1,54 @@ +[CmdletBinding()] +Param( + [Parameter(Mandatory=$True)] + [string]$Toolsrc, + [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 $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 = git status --porcelain $Toolsrc | ForEach-Object { + (-split $_)[1] + } + + 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 +} diff --git a/scripts/azure-pipelines/windows/provision-image.txt b/scripts/azure-pipelines/windows/provision-image.txt index 2d2790ec7..798b96e9a 100644 --- a/scripts/azure-pipelines/windows/provision-image.txt +++ b/scripts/azure-pipelines/windows/provision-image.txt @@ -393,6 +393,30 @@ Function InstallLLVM { <#
.SYNOPSIS
+Installs LLVM.
+
+.DESCRIPTION
+InstallLLVM installs LLVM from the supplied URL.
+
+.PARAMETER Url
+The URL of the LLVM installer.
+#>
+Function InstallLLVM {
+ try {
+ Write-Host 'Downloading LLVM...'
+ [string]$installerPath = Get-TempFilePath -Extension 'exe'
+ curl.exe -L -o $installerPath -s -S $Url
+ Write-Host 'Installing LLVM...'
+ $proc = Start-Process -FilePath $installerPath -ArgumentList @('/S') -NoNewWindow -Wait -PassThru
+ PrintMsiExitCodeMessage $proc.ExitCode
+ }
+ catch {
+ Write-Error "Failed to install LLVM! $($_.Exception.Message)"
+ }
+}
+
+<#
+.SYNOPSIS
Installs MPI
.DESCRIPTION
|
