Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
4dd769b
add format target to cmake
strega-nil Apr 26, 2022
507e12b
remove parallelize
strega-nil Apr 26, 2022
dd1ea10
remember to call vsdevcmd; add ERROR_ON_CLANG_FORMAT_NOT_FOUND
strega-nil Apr 26, 2022
bb4fa64
add a format.diff output; should correct errors
strega-nil Apr 26, 2022
6a2a992
errrgh
strega-nil Apr 26, 2022
f552cba
aaaaaugh
strega-nil Apr 26, 2022
abf9330
fix build error, change how format is done
strega-nil Apr 27, 2022
791e5ba
moar fixin'
strega-nil Apr 27, 2022
4212816
forgot cmr :'(
strega-nil Apr 27, 2022
8863e7a
forgot to skip .diff files -.-
strega-nil Apr 27, 2022
1a27369
okay fix builds hopefully
strega-nil Apr 27, 2022
8dc715d
Merge remote-tracking branch 'upstream/main' into strega-nil/add-form…
strega-nil Apr 27, 2022
cf2f367
remove hiddenf iles
strega-nil Apr 27, 2022
de2988d
remove format.diff file
strega-nil Apr 27, 2022
fd5abee
single-quotes -> double-quotes
strega-nil Apr 27, 2022
070076d
(* cries *)
strega-nil Apr 27, 2022
955beb6
(* cries more *)
strega-nil Apr 27, 2022
ae2f1e6
clean UP
strega-nil Apr 27, 2022
ffbff5b
fix people's problems
strega-nil Apr 28, 2022
abe3bd0
[TEST] try clang-format
strega-nil Apr 28, 2022
0f57832
oops, need to fail the pipeline
strega-nil Apr 28, 2022
cce432e
NEAT
strega-nil Apr 28, 2022
bb3222b
vso[error] -> [error]
strega-nil Apr 28, 2022
a2d6aa4
how does that look?
strega-nil Apr 28, 2022
d32cc67
does that result in failures
strega-nil Apr 28, 2022
53e0527
do tests
strega-nil Apr 28, 2022
93d2186
does logissue work?
strega-nil Apr 28, 2022
e9ff5c4
figured it out!
strega-nil Apr 28, 2022
0f539a8
clang-format
strega-nil Apr 28, 2022
2688dce
[TEST] validate (tabs)
strega-nil Apr 28, 2022
19d0f42
validate prettifying
strega-nil Apr 28, 2022
9f899e4
more prettifying
strega-nil Apr 28, 2022
b8566a9
final format
strega-nil Apr 28, 2022
bf41006
Code review feedback, fixing missed path failures.
StephanTLavavej Apr 29, 2022
d4fe38f
add instructions for downloading
strega-nil Apr 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -86,3 +86,9 @@ if(BUILD_TESTING)
enable_testing()
add_subdirectory(tests)
endif()

add_subdirectory(tools/format)
if(CLANG_FORMAT_TARGETS)
add_custom_target(format)
add_dependencies(format ${CLANG_FORMAT_TARGETS})
endif()
25 changes: 25 additions & 0 deletions azure-devops/create-prdiff.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

[CmdletBinding(PositionalBinding = $False)]
Param(
[Parameter(Mandatory = $True)]
[String]$DiffFile
)

Start-Process -FilePath 'git' -ArgumentList 'diff' `
-NoNewWindow -Wait `
-RedirectStandardOutput $DiffFile
if (0 -ne (Get-Item -LiteralPath $DiffFile).Length) {
$msg = @(
'The formatting of the files in the repo was not what we expected.'
'Please access the diff from format.diff in the build artifacts,'
'and apply it with `git apply`.'
'Alternatively, you can run the `format` CMake target:'
' cmake --build <builddir> --target format'
''
)
Write-Host ($msg -join '`n')
Write-Host (Get-Content -LiteralPath $DiffFile)
throw
}
14 changes: 0 additions & 14 deletions azure-devops/enforce-clang-format.cmd

This file was deleted.

7 changes: 6 additions & 1 deletion azure-devops/validate-files.cmd
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
:: Copyright (c) Microsoft Corporation.
:: SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
"%1"
call "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat" ^
-host_arch=amd64 -arch=amd64 -no_logo
cmake -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release ^
-S "%1\tools\validate" -B "%TEMP%\validate-build"
cmake --build "%TEMP%\validate-build"
"%TEMP%\validate-build\validate.exe"
@echo If your build fails here, you need to fix the listed issues.
44 changes: 23 additions & 21 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ stages:
timeoutInMinutes: 90
displayName: 'Validation'
variables:
buildOutputLocation: 'D:\tools'
- name: DiffFile
value: '$(Build.ArtifactStagingDirectory)/format.diff'
steps:
- script: |
if exist "$(tmpDir)" (
Expand All @@ -29,34 +30,35 @@ stages:
clean: true
submodules: false
- script: |
if exist "$(buildOutputLocation)" (
rmdir /S /Q "$(buildOutputLocation)"
)
call "%ProgramFiles%\Microsoft Visual Studio\2022\Preview\Common7\Tools\VsDevCmd.bat" ^
-host_arch=amd64 -arch=amd64 -no_logo
cmake -G Ninja -DCMAKE_CXX_COMPILER=cl -DCMAKE_BUILD_TYPE=Release ^
-S $(Build.SourcesDirectory)\tools -B $(buildOutputLocation)
cmake --build $(buildOutputLocation)
displayName: 'Build Support Tools'
env: { TMP: $(tmpDir), TEMP: $(tmpDir) }
- task: BatchScript@1
displayName: 'Enforce clang-format'
timeoutInMinutes: 60
-host_arch=amd64 -arch=amd64 -no_logo
cmake -G Ninja -S $(Build.SourcesDirectory)/tools/format -B $(tmpDir)/format-build
cmake --build $(tmpDir)/format-build
displayName: 'clang-format'
timeoutInMinutes: 5
condition: succeededOrFailed()
inputs:
filename: 'azure-devops/enforce-clang-format.cmd'
failOnStandardError: true
arguments: '$(buildOutputLocation)/parallelize/parallelize.exe'
env: { TMP: $(tmpDir), TEMP: $(tmpDir) }
- task: BatchScript@1
displayName: 'Validate Files'
timeoutInMinutes: 2
condition: succeededOrFailed()
inputs:
filename: 'azure-devops/validate-files.cmd'
failOnStandardError: true
arguments: '$(buildOutputLocation)/validate/validate.exe'
arguments: '$(Build.SourcesDirectory)'
displayName: 'Validate Files'
timeoutInMinutes: 5
condition: succeededOrFailed()
env: { TMP: $(tmpDir), TEMP: $(tmpDir) }
- task: Powershell@2
displayName: 'Create Diff'
inputs:
filePath: azure-devops/create-prdiff.ps1
arguments: '-DiffFile $(DiffFile)'
pwsh: false
- task: PublishBuildArtifacts@1
condition: failed()
displayName: 'Publish Format and Messages File Diff'
inputs:
PathToPublish: '$(DiffFile)'
ArtifactName: 'format.diff'

- stage: Build_And_Test_x64
dependsOn: Code_Format
Expand Down
13 changes: 13 additions & 0 deletions format.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/azure-pipelines.yml b/azure-pipelines.yml
index bd4d94b8..5f5c0e36 100644
--- a/azure-pipelines.yml
+++ b/azure-pipelines.yml
@@ -53,7 +53,7 @@ stages:
inputs:
filePath: azure-devops/Create-PRDiff.ps1
arguments: '-DiffFile $(DiffFile)'
- pwsh: true
+ pwsh: false
- task: PublishBuildArtifacts@1
condition: failed()
displayName: 'Publish Format and Messages File Diff'
2 changes: 1 addition & 1 deletion tools/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ add_compile_options(/W4 /WX $<$<NOT:$<CONFIG:Debug>>:/Zi> /permissive-)

include_directories(inc)

add_subdirectory(format)
add_subdirectory(jobify)
add_subdirectory(parallelize)
add_subdirectory(validate)
81 changes: 81 additions & 0 deletions tools/format/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Copyright (c) Microsoft Corporation.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

cmake_minimum_required(VERSION 3.22)
project(msvc_standard_libraries_format NONE)

set(did_search ON)
if(NOT DEFINED CLANG_FORMAT)
message(STATUS "Searching for VS clang-format")
set(did_search OFF)
endif()

if(PROJECT_IS_TOP_LEVEL)
set(message_level FATAL_ERROR)
else()
set(message_level WARNING)
endif()

find_program(CLANG_FORMAT
NAMES clang-format
PATHS "C:/Program Files/Microsoft Visual Studio/2022/Preview/VC/Tools/Llvm/bin"
DOC "The clang-format program to use"
NO_DEFAULT_PATH
NO_CMAKE_PATH
NO_CMAKE_ENVIRONMENT_PATH
NO_SYSTEM_ENVIRONMENT_PATH
NO_CMAKE_SYSTEM_PATH
)
if(CLANG_FORMAT)
if(did_search)
message(STATUS "Searching for VS clang-format - found")
endif()

file(GLOB_RECURSE maybe-clang-format-files
"../../stl/inc/*"
"../../stl/src/*"
"../../tests/*"
"../../tools/*"
)
set(clang-format-files "")
foreach(maybe-file IN LISTS maybe-clang-format-files)
cmake_path(GET maybe-file EXTENSION LAST_ONLY extension)
if(extension MATCHES [[^(|\.cpp|\.h|\.hpp)$]])
list(APPEND clang-format-files "${maybe-file}")
endif()
endforeach()

if(NOT clang-format-files)
message("${message_level}" "Could not find any files to clang-format!")
endif()

set(clang-format-targets "")
foreach(file IN LISTS clang-format-files)
cmake_path(RELATIVE_PATH file
BASE_DIRECTORY "${CMAKE_CURRENT_LIST_DIR}/../.."
OUTPUT_VARIABLE relative-file
)
string(REPLACE "/" "_" relative-file "${relative-file}")
set(target_name "clang-format.${relative-file}")
add_custom_target("${target_name}"
COMMAND "${CLANG_FORMAT}" -style=file -i "${file}"
WORKING_DIRECTORY "${PROJECT_SOURCE_DIR}"
)
list(APPEND clang-format-targets "${target_name}")
endforeach()

if(PROJECT_IS_TOP_LEVEL)
add_custom_target(format ALL)
add_dependencies(format ${clang-format-targets})
else()
set(CLANG_FORMAT_TARGETS "${clang-format-targets}" PARENT_SCOPE)
endif()
else()
if(did_search)
message("${message_level}" "Searching for VS clang-format - not found.")
endif()

if(NOT PROJECT_IS_TOP_LEVEL)
set(CLANG_FORMAT_TARGETS "" PARENT_SCOPE)
endif()
endif()
5 changes: 0 additions & 5 deletions tools/parallelize/CMakeLists.txt

This file was deleted.

Loading