Skip to content

Commit

Permalink
Enforce ASCII and whitespace conventions (#229)
Browse files Browse the repository at this point in the history
Fixes #141.

* Change LF to CRLF.
* Remove UTF-8 BOMs.
* Add validate.cpp.
* Add validate to CMakeLists.txt.
* Add validate to azure-devops.
* Wrap enforce-clang-format.cmd.
* Code review feedback: abort().
* Code review feedback: Assign previous3.
* Code review feedback: Don't catch everything.
* Code review feedback: MaxErrorsForDisallowedCharacters.
* Cleanup: Remove `enabled: true`.
* Code review feedback: Character code comments.
* Code review feedback: Allow certain files to be tabby.
* Code review feedback: Use native wchar_t paths.
  • Loading branch information
StephanTLavavej authored Oct 30, 2019
1 parent b9eb320 commit 9c1c63c
Show file tree
Hide file tree
Showing 13 changed files with 442 additions and 215 deletions.
14 changes: 7 additions & 7 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
fetchRecurseSubmodules = false
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[submodule "vcpkg"]
path = vcpkg
url = https://github.com/microsoft/vcpkg.git
fetchRecurseSubmodules = false
2 changes: 1 addition & 1 deletion CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
{
"configurations": [
{
"name": "x86",
Expand Down
10 changes: 9 additions & 1 deletion azure-devops/enforce-clang-format.cmd
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
:: Copyright (c) Microsoft Corporation.
:: SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"%1" "clang-format.exe -style=file -i" stl/inc stl/inc/cvt stl/inc/experimental stl/src tools/inc tools/jobify/jobify.cpp tools/parallelize/parallelize.cpp
"%1" "clang-format.exe -style=file -i" ^
stl/inc ^
stl/inc/cvt ^
stl/inc/experimental ^
stl/src ^
tools/inc ^
tools/jobify/jobify.cpp ^
tools/parallelize/parallelize.cpp ^
tools/validate/validate.cpp
@echo If your build fails here, you need to format the following files with
@clang-format.exe --version
@git status --porcelain stl tools 1>&2
128 changes: 64 additions & 64 deletions azure-devops/install_msvc_preview.ps1
Original file line number Diff line number Diff line change
@@ -1,64 +1,64 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
$ErrorActionPreference = "Stop"

Function InstallVS
{
# Microsoft hosted agents do not have the required MSVC Preview for building MSVC STL.
# This step installs MSVC Preview, only on Microsoft hosted agents.

Param(
[String]$WorkLoads,
[String]$Sku,
[String]$VSBootstrapperURL)
$exitCode = -1
try
{
Write-Host "Downloading bootstrapper ..."
[string]$bootstrapperExe = Join-Path ${env:Temp} ([System.IO.Path]::GetRandomFileName() + ".exe")
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile $bootstrapperExe

$Arguments = ('/c', $bootstrapperExe, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache')

Write-Host "Starting Install: $Arguments"
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode

if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful!'
}
else
{
Write-Host -Object "Nonzero exit code returned by the installation process : $exitCode."
}
}
catch
{
Write-Host -Object "Failed to install Visual Studio!"
Write-Host -Object $_.Exception.Message
exit $exitCode
}

exit $exitCode
}

# Invalidate the standard installation of VS on the hosted agent.
Move-Item "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/" "C:/Program Files (x86)/Microsoft Visual Studio/2019/nouse/" -Verbose

$WorkLoads = '--add Microsoft.VisualStudio.Component.VC.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.18362 '

$ReleaseInPath = 'Preview'
$Sku = 'Enterprise'
$VSBootstrapperURL = 'https://aka.ms/vs/16/pre/vs_buildtools.exe'

$ErrorActionPreference = 'Stop'

# Install VS
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL

exit $exitCode
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
$ErrorActionPreference = "Stop"

Function InstallVS
{
# Microsoft hosted agents do not have the required MSVC Preview for building MSVC STL.
# This step installs MSVC Preview, only on Microsoft hosted agents.

Param(
[String]$WorkLoads,
[String]$Sku,
[String]$VSBootstrapperURL)
$exitCode = -1
try
{
Write-Host "Downloading bootstrapper ..."
[string]$bootstrapperExe = Join-Path ${env:Temp} ([System.IO.Path]::GetRandomFileName() + ".exe")
Invoke-WebRequest -Uri $VSBootstrapperURL -OutFile $bootstrapperExe

$Arguments = ('/c', $bootstrapperExe, $WorkLoads, '--quiet', '--norestart', '--wait', '--nocache')

Write-Host "Starting Install: $Arguments"
$process = Start-Process -FilePath cmd.exe -ArgumentList $Arguments -Wait -PassThru
$exitCode = $process.ExitCode

if ($exitCode -eq 0 -or $exitCode -eq 3010)
{
Write-Host -Object 'Installation successful!'
}
else
{
Write-Host -Object "Nonzero exit code returned by the installation process : $exitCode."
}
}
catch
{
Write-Host -Object "Failed to install Visual Studio!"
Write-Host -Object $_.Exception.Message
exit $exitCode
}

exit $exitCode
}

# Invalidate the standard installation of VS on the hosted agent.
Move-Item "C:/Program Files (x86)/Microsoft Visual Studio/2019/Enterprise/" "C:/Program Files (x86)/Microsoft Visual Studio/2019/nouse/" -Verbose

$WorkLoads = '--add Microsoft.VisualStudio.Component.VC.CLI.Support ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM64 ' + `
'--add Microsoft.VisualStudio.Component.VC.Tools.ARM ' + `
'--add Microsoft.VisualStudio.Component.Windows10SDK.18362 '

$ReleaseInPath = 'Preview'
$Sku = 'Enterprise'
$VSBootstrapperURL = 'https://aka.ms/vs/16/pre/vs_buildtools.exe'

$ErrorActionPreference = 'Stop'

# Install VS
$exitCode = InstallVS -WorkLoads $WorkLoads -Sku $Sku -VSBootstrapperURL $VSBootstrapperURL

exit $exitCode
131 changes: 68 additions & 63 deletions azure-devops/run_build.yml
Original file line number Diff line number Diff line change
@@ -1,63 +1,68 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
parameters:
targetPlatform: 'x64'

jobs:
- job: ${{ parameters.targetPlatform }}
pool:
name: STL

variables:
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'
vcpkgResponseFile: $(Build.SourcesDirectory)/vcpkg_windows.txt
steps:
- checkout: self
submodules: recursive
- task: PowerShell@2
displayName: 'Install MSVC Preview'
# on "Hosted" agents only:
condition: or(contains(variables['Agent.Name'], 'Azure Pipelines'), contains(variables['Agent.Name'], 'Hosted Agent'))
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/azure-devops/install_msvc_preview.ps1
- task: CacheBeta@0
displayName: Cache vcpkg
inputs:
key: $(vcpkgResponseFile) | $(Build.SourcesDirectory)/.git/modules/vcpkg/HEAD
path: '$(vcpkgLocation)'
- task: run-vcpkg@0
displayName: 'Run vcpkg to Install boost-build'
inputs:
vcpkgArguments: 'boost-build:x86-windows'
vcpkgDirectory: '$(vcpkgLocation)'
- task: run-vcpkg@0
displayName: 'Run vcpkg'
inputs:
vcpkgArguments: '@$(vcpkgResponseFile)'
vcpkgDirectory: '$(vcpkgLocation)'
vcpkgTriplet: ${{ parameters.targetPlatform }}-windows
- task: run-cmake@0
displayName: 'Build Support Tools'
enabled: true
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
cmakeListsTxtPath: 'tools/CMakeSettings.json'
useVcpkgToolchainFile: true
configurationRegexFilter: '.*x64-Release.*'
buildDirectory: $(Build.ArtifactStagingDirectory)/tools
- task: BatchScript@1
displayName: 'Enforce clang-format'
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
filename: 'azure-devops/enforce-clang-format.cmd'
failOnStandardError: true
arguments: '$(Build.ArtifactStagingDirectory)/tools/parallelize/parallelize.exe'
- task: run-cmake@0
displayName: 'Build the STL'
enabled: true
inputs:
cmakeListsTxtPath: 'CMakeSettings.json'
useVcpkgToolchainFile: true
configurationRegexFilter: '.*${{ parameters.targetPlatform }}.*'
buildDirectory: $(Build.ArtifactStagingDirectory)/${{ parameters.targetPlatform }}
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
parameters:
targetPlatform: 'x64'

jobs:
- job: ${{ parameters.targetPlatform }}
pool:
name: STL

variables:
vcpkgLocation: '$(Build.SourcesDirectory)/vcpkg'
vcpkgResponseFile: $(Build.SourcesDirectory)/vcpkg_windows.txt
steps:
- checkout: self
submodules: recursive
- task: PowerShell@2
displayName: 'Install MSVC Preview'
# on "Hosted" agents only:
condition: or(contains(variables['Agent.Name'], 'Azure Pipelines'), contains(variables['Agent.Name'], 'Hosted Agent'))
inputs:
targetType: filePath
filePath: $(Build.SourcesDirectory)/azure-devops/install_msvc_preview.ps1
- task: CacheBeta@0
displayName: Cache vcpkg
inputs:
key: $(vcpkgResponseFile) | $(Build.SourcesDirectory)/.git/modules/vcpkg/HEAD
path: '$(vcpkgLocation)'
- task: run-vcpkg@0
displayName: 'Run vcpkg to Install boost-build'
inputs:
vcpkgArguments: 'boost-build:x86-windows'
vcpkgDirectory: '$(vcpkgLocation)'
- task: run-vcpkg@0
displayName: 'Run vcpkg'
inputs:
vcpkgArguments: '@$(vcpkgResponseFile)'
vcpkgDirectory: '$(vcpkgLocation)'
vcpkgTriplet: ${{ parameters.targetPlatform }}-windows
- task: run-cmake@0
displayName: 'Build Support Tools'
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
cmakeListsTxtPath: 'tools/CMakeSettings.json'
useVcpkgToolchainFile: true
configurationRegexFilter: '.*x64-Release.*'
buildDirectory: $(Build.ArtifactStagingDirectory)/tools
- task: BatchScript@1
displayName: 'Enforce clang-format'
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
filename: 'azure-devops/enforce-clang-format.cmd'
failOnStandardError: true
arguments: '$(Build.ArtifactStagingDirectory)/tools/parallelize/parallelize.exe'
- task: BatchScript@1
displayName: 'Validate Files'
condition: eq('${{ parameters.targetPlatform }}', 'x64')
inputs:
filename: 'azure-devops/validate-files.cmd'
failOnStandardError: true
arguments: '$(Build.ArtifactStagingDirectory)/tools/validate/validate.exe'
- task: run-cmake@0
displayName: 'Build the STL'
inputs:
cmakeListsTxtPath: 'CMakeSettings.json'
useVcpkgToolchainFile: true
configurationRegexFilter: '.*${{ parameters.targetPlatform }}.*'
buildDirectory: $(Build.ArtifactStagingDirectory)/${{ parameters.targetPlatform }}
4 changes: 4 additions & 0 deletions azure-devops/validate-files.cmd
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
:: Copyright (c) Microsoft Corporation.
:: SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"%1"
@echo If your build fails here, you need to fix the listed issues.
42 changes: 21 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Build STL targeting x86, x64, arm, arm64

jobs:
- template: azure-devops/run_build.yml
parameters:
targetPlatform: x86

- template: azure-devops/run_build.yml
parameters:
targetPlatform: x64

- template: azure-devops/run_build.yml
parameters:
targetPlatform: arm

- template: azure-devops/run_build.yml
parameters:
targetPlatform: arm64
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Build STL targeting x86, x64, arm, arm64

jobs:
- template: azure-devops/run_build.yml
parameters:
targetPlatform: x86

- template: azure-devops/run_build.yml
parameters:
targetPlatform: x64

- template: azure-devops/run_build.yml
parameters:
targetPlatform: arm

- template: azure-devops/run_build.yml
parameters:
targetPlatform: arm64
Loading

0 comments on commit 9c1c63c

Please sign in to comment.