-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: nicole mazzuca <[email protected]> Co-authored-by: Stephan T. Lavavej <[email protected]>
- Loading branch information
1 parent
fa51112
commit d849a95
Showing
11 changed files
with
198 additions
and
320 deletions.
There are no files selected for viewing
This file contains 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 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,29 @@ | ||
# 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) { | ||
$message = @( | ||
'##vso[task.logissue type=error]The formatting of the files in the repo was not what we expected.' | ||
'Please access the diff from format.diff in the build artifacts' | ||
'(you can download it by clicking the three dots at the right)' | ||
'and apply it with `git apply`.' | ||
'Alternatively, you can run the `format` CMake target:' | ||
' cmake --build <builddir> --target format' | ||
'' | ||
'##[group]Expected formatting - click to expand diff' | ||
Get-Content -LiteralPath $DiffFile -Raw | ||
'##[endgroup]' | ||
"##vso[artifact.upload artifactname=format.diff]$DiffFile" | ||
'##vso[task.complete result=Failed]DONE' | ||
) | ||
Write-Host ($message -join "`n") | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains 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 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 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,71 @@ | ||
# 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 OFF) | ||
if(NOT DEFINED CLANG_FORMAT) | ||
message(STATUS "Searching for VS clang-format") | ||
set(did_search ON) | ||
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 FILENAME filename) | ||
cmake_path(GET maybe_file EXTENSION LAST_ONLY extension) | ||
if(extension MATCHES [[^(|\.cpp|\.h|\.hpp)$]] AND NOT filename MATCHES [[^\.]]) | ||
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() | ||
|
||
add_custom_target(clang-format-all ALL) | ||
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}" | ||
) | ||
add_dependencies(clang-format-all "${target_name}") | ||
endforeach() | ||
else() | ||
if(did_search) | ||
message("${message_level}" "Searching for VS clang-format - not found.") | ||
endif() | ||
endif() |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.