-
Notifications
You must be signed in to change notification settings - Fork 1.6k
add format target to cmake #2671
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
StephanTLavavej
merged 35 commits into
microsoft:main
from
strega-nil:add-format-to-cmakelists
May 1, 2022
Merged
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 507e12b
remove parallelize
strega-nil dd1ea10
remember to call vsdevcmd; add ERROR_ON_CLANG_FORMAT_NOT_FOUND
strega-nil bb4fa64
add a format.diff output; should correct errors
strega-nil 6a2a992
errrgh
strega-nil f552cba
aaaaaugh
strega-nil abf9330
fix build error, change how format is done
strega-nil 791e5ba
moar fixin'
strega-nil 4212816
forgot cmr :'(
strega-nil 8863e7a
forgot to skip .diff files -.-
strega-nil 1a27369
okay fix builds hopefully
strega-nil 8dc715d
Merge remote-tracking branch 'upstream/main' into strega-nil/add-form…
strega-nil cf2f367
remove hiddenf iles
strega-nil de2988d
remove format.diff file
strega-nil fd5abee
single-quotes -> double-quotes
strega-nil 070076d
(* cries *)
strega-nil 955beb6
(* cries more *)
strega-nil ae2f1e6
clean UP
strega-nil ffbff5b
fix people's problems
strega-nil abe3bd0
[TEST] try clang-format
strega-nil 0f57832
oops, need to fail the pipeline
strega-nil cce432e
NEAT
strega-nil bb3222b
vso[error] -> [error]
strega-nil a2d6aa4
how does that look?
strega-nil d32cc67
does that result in failures
strega-nil 53e0527
do tests
strega-nil 93d2186
does logissue work?
strega-nil e9ff5c4
figured it out!
strega-nil 0f539a8
clang-format
strega-nil 2688dce
[TEST] validate (tabs)
strega-nil 19d0f42
validate prettifying
strega-nil 9f899e4
more prettifying
strega-nil b8566a9
final format
strega-nil bf41006
Code review feedback, fixing missed path failures.
StephanTLavavej d4fe38f
add instructions for downloading
strega-nil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
strega-nil-ms marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
} |
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
diff --git a/azure-pipelines.yml b/azure-pipelines.yml | ||
CaseyCarter marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
strega-nil-ms marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
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() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.