mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-05 22:00:10 -05:00
Merge topic 'clang-format-attrs'
d5f39a56clang-format.bash: Use Git attributes to mark files for formattingf6986ee4Define a custom Git attribute to mark sources using our C style2256c3a7Define a custom Git attribute to mark source files as generated
This commit is contained in:
+19
-5
@@ -1,6 +1,13 @@
|
||||
.gitattributes export-ignore
|
||||
.hooks* export-ignore
|
||||
|
||||
# Custom attribute to mark sources as using our C code style.
|
||||
[attr]our-c-style whitespace=tab-in-indent format.clang-format
|
||||
|
||||
# Custom attribute to mark sources as generated.
|
||||
# Do not perform whitespace checks. Do not format.
|
||||
[attr]generated whitespace=-tab-in-indent,-indent-with-non-tab -format.clang-format
|
||||
|
||||
bootstrap crlf=input
|
||||
configure crlf=input
|
||||
*.[1-9] crlf=input
|
||||
@@ -16,10 +23,17 @@ configure crlf=input
|
||||
*.sln -crlf
|
||||
*.vcproj -crlf
|
||||
|
||||
*.c whitespace=tab-in-indent
|
||||
*.h whitespace=tab-in-indent
|
||||
*.cxx whitespace=tab-in-indent
|
||||
*.txt whitespace=tab-in-indent
|
||||
*.cmake whitespace=tab-in-indent
|
||||
*.c our-c-style
|
||||
*.cc our-c-style
|
||||
*.cpp our-c-style
|
||||
*.cu our-c-style
|
||||
*.cxx our-c-style
|
||||
*.h our-c-style
|
||||
*.hh our-c-style
|
||||
*.hpp our-c-style
|
||||
*.hxx our-c-style
|
||||
*.notcu our-c-style
|
||||
|
||||
*.cmake whitespace=tab-in-indent
|
||||
*.rst whitespace=tab-in-indent conflict-marker-size=79
|
||||
*.txt whitespace=tab-in-indent
|
||||
|
||||
+21
-10
@@ -1,10 +1,21 @@
|
||||
# Preserve indentation style in generated code.
|
||||
cmCommandArgumentLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmCommandArgumentLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmDependsJavaLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmDependsJavaLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmExprLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmExprLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmFortranLexer.cxx whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmFortranLexer.h whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
cmListFileLexer.c whitespace=-tab-in-indent,-indent-with-non-tab
|
||||
/cmCommandArgumentLexer.cxx generated
|
||||
/cmCommandArgumentLexer.h generated
|
||||
/cmCommandArgumentParser.cxx generated
|
||||
/cmCommandArgumentParserTokens.h generated
|
||||
/cmDependsJavaLexer.cxx generated
|
||||
/cmDependsJavaLexer.h generated
|
||||
/cmDependsJavaParser.cxx generated
|
||||
/cmDependsJavaParserTokens.h generated
|
||||
/cmExprLexer.cxx generated
|
||||
/cmExprLexer.h generated
|
||||
/cmExprParser.cxx generated
|
||||
/cmExprParserTokens.h generated
|
||||
/cmFortranLexer.cxx generated
|
||||
/cmFortranLexer.h generated
|
||||
/cmFortranParser.cxx generated
|
||||
/cmFortranParserTokens.h generated
|
||||
/cmListFileLexer.c generated
|
||||
|
||||
# Do not format third-party sources.
|
||||
/bindexplib.* -format.clang-format
|
||||
/kwsys/** -format.clang-format
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
* -format.clang-format
|
||||
@@ -0,0 +1,2 @@
|
||||
# Do not format a source containing C++11 '>>' syntax as C++98.
|
||||
cxx_right_angle_brackets.cpp -format.clang-format
|
||||
@@ -0,0 +1,2 @@
|
||||
# Do not format a source where we want a long line preserved.
|
||||
pic_test.h -format.clang-format
|
||||
@@ -0,0 +1,2 @@
|
||||
# Do not format a source encoded in UTF-16.
|
||||
test_UTF-16LE.h -format.clang-format
|
||||
@@ -0,0 +1,2 @@
|
||||
# Exclude reference content from formatting.
|
||||
* -format.clang-format
|
||||
@@ -1,3 +1,7 @@
|
||||
/Git export-ignore
|
||||
/GitSetup export-ignore
|
||||
SetupForDevelopment.sh export-ignore
|
||||
|
||||
# Do not format third-party sources.
|
||||
/KWIML/** -format.clang-format
|
||||
/cm*/** -format.clang-format
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/usr/bin/env bash
|
||||
#=============================================================================
|
||||
# Copyright 2015-2016 Kitware, Inc.
|
||||
# Copyright 2015-2017 Kitware, Inc.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
@@ -106,34 +106,12 @@ case "$mode" in
|
||||
*) die "invalid mode: $mode" ;;
|
||||
esac
|
||||
|
||||
# Filter sources to which our style should apply.
|
||||
$git_ls -z -- '*.c' '*.cc' '*.cpp' '*.cxx' '*.h' '*.hh' '*.hpp' '*.hxx' '*.cu' '*.notcu' |
|
||||
# List files as selected above.
|
||||
$git_ls |
|
||||
|
||||
# Exclude lexer/parser generator input and output.
|
||||
egrep -z -v '^Source/cmCommandArgumentLexer\.' |
|
||||
egrep -z -v '^Source/cmCommandArgumentParser(\.y|\.cxx|Tokens\.h)' |
|
||||
egrep -z -v '^Source/cmDependsJavaLexer\.' |
|
||||
egrep -z -v '^Source/cmDependsJavaParser(\.y|\.cxx|Tokens\.h)' |
|
||||
egrep -z -v '^Source/cmExprLexer\.' |
|
||||
egrep -z -v '^Source/cmExprParser(\.y|\.cxx|Tokens\.h)' |
|
||||
egrep -z -v '^Source/cmFortranLexer\.' |
|
||||
egrep -z -v '^Source/cmFortranParser(\.y|\.cxx|Tokens\.h)' |
|
||||
egrep -z -v '^Source/cmListFileLexer(\.in\.l|\.c)' |
|
||||
|
||||
# Exclude third-party sources.
|
||||
egrep -z -v '^Source/bindexplib' |
|
||||
egrep -z -v '^Source/(kwsys|CursesDialog/form)/' |
|
||||
egrep -z -v '^Utilities/(KW|cm).*/' |
|
||||
|
||||
# Exclude reference content.
|
||||
egrep -z -v '^Tests/RunCMake/GenerateExportHeader/reference/' |
|
||||
|
||||
# Exclude manually-formatted sources (e.g. with long lines).
|
||||
egrep -z -v '^Tests/PositionIndependentTargets/pic_test.h' |
|
||||
egrep -z -v '^Tests/CompileFeatures/cxx_right_angle_brackets.cpp' |
|
||||
|
||||
# Exclude sources with encoding not suported by clang-format.
|
||||
egrep -z -v '^Tests/RunCMake/CommandLine/cmake_depends/test_UTF-16LE.h' |
|
||||
# Select sources with our attribute.
|
||||
git check-attr --stdin format.clang-format |
|
||||
sed -n '/: format\.clang-format: set$/ {s/:[^:]*:[^:]*$//p}' |
|
||||
|
||||
# Update sources in-place.
|
||||
xargs -0 "$clang_format" -i
|
||||
xargs -d '\n' "$clang_format" -i
|
||||
|
||||
Reference in New Issue
Block a user