Skip to content

Commit d19e1c2

Browse files
authored
Use the same clang-format ESDK does (#2)
* Use the same clang-format ESDK does * Use GitHub Actions to check the clang-format
1 parent 88765f4 commit d19e1c2

File tree

3 files changed

+189
-0
lines changed

3 files changed

+189
-0
lines changed

.clang-format

+150
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
---
2+
Language: Cpp
3+
# BasedOnStyle: Google
4+
AccessModifierOffset: -1
5+
AlignAfterOpenBracket: AlwaysBreak
6+
AlignConsecutiveAssignments: true
7+
AlignConsecutiveDeclarations: false
8+
AlignEscapedNewlines: Left
9+
AlignOperands: true
10+
AlignTrailingComments: true
11+
AllowAllParametersOfDeclarationOnNextLine: true
12+
AllowShortBlocksOnASingleLine: false
13+
AllowShortCaseLabelsOnASingleLine: true
14+
AllowShortFunctionsOnASingleLine: Empty
15+
AllowShortIfStatementsOnASingleLine: true
16+
AllowShortLoopsOnASingleLine: true
17+
AlwaysBreakAfterDefinitionReturnType: None
18+
AlwaysBreakAfterReturnType: None
19+
AlwaysBreakBeforeMultilineStrings: true
20+
AlwaysBreakTemplateDeclarations: Yes
21+
BinPackArguments: false
22+
BinPackParameters: false
23+
BraceWrapping:
24+
AfterClass: false
25+
AfterControlStatement: false
26+
AfterEnum: false
27+
AfterFunction: false
28+
AfterNamespace: false
29+
AfterObjCDeclaration: false
30+
AfterStruct: false
31+
AfterUnion: false
32+
AfterExternBlock: false
33+
BeforeCatch: false
34+
BeforeElse: false
35+
IndentBraces: false
36+
SplitEmptyFunction: true
37+
SplitEmptyRecord: true
38+
SplitEmptyNamespace: true
39+
BreakBeforeBinaryOperators: None
40+
BreakBeforeBraces: Attach
41+
BreakBeforeInheritanceComma: false
42+
BreakInheritanceList: BeforeColon
43+
BreakBeforeTernaryOperators: true
44+
BreakConstructorInitializersBeforeComma: false
45+
BreakConstructorInitializers: BeforeColon
46+
BreakAfterJavaFieldAnnotations: false
47+
BreakStringLiterals: true
48+
ColumnLimit: 120
49+
CommentPragmas: '^ IWYU pragma:'
50+
CompactNamespaces: false
51+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
52+
ConstructorInitializerIndentWidth: 4
53+
ContinuationIndentWidth: 4
54+
Cpp11BracedListStyle: false
55+
DerivePointerAlignment: false
56+
DisableFormat: false
57+
ExperimentalAutoDetectBinPacking: false
58+
FixNamespaceComments: true
59+
ForEachMacros:
60+
- foreach
61+
- Q_FOREACH
62+
- BOOST_FOREACH
63+
IncludeBlocks: Preserve
64+
IncludeCategories:
65+
- Regex: '^<ext/.*\.h>'
66+
Priority: 2
67+
- Regex: '^<.*\.h>'
68+
Priority: 1
69+
- Regex: '^<.*'
70+
Priority: 2
71+
- Regex: '.*'
72+
Priority: 3
73+
IncludeIsMainRegex: '([-_](test|unittest))?$'
74+
IndentCaseLabels: true
75+
IndentPPDirectives: AfterHash
76+
IndentWidth: 4
77+
IndentWrappedFunctionNames: false
78+
JavaScriptQuotes: Leave
79+
JavaScriptWrapImports: true
80+
KeepEmptyLinesAtTheStartOfBlocks: false
81+
MacroBlockBegin: ''
82+
MacroBlockEnd: ''
83+
MaxEmptyLinesToKeep: 1
84+
NamespaceIndentation: None
85+
ObjCBinPackProtocolList: Never
86+
ObjCBlockIndentWidth: 2
87+
ObjCSpaceAfterProperty: false
88+
ObjCSpaceBeforeProtocolList: true
89+
PenaltyBreakAssignment: 2
90+
PenaltyBreakBeforeFirstCallParameter: 1
91+
PenaltyBreakComment: 300
92+
PenaltyBreakFirstLessLess: 120
93+
PenaltyBreakString: 1000
94+
PenaltyBreakTemplateDeclaration: 10
95+
PenaltyExcessCharacter: 1000000
96+
PenaltyReturnTypeOnItsOwnLine: 200
97+
PointerAlignment: Right
98+
RawStringFormats:
99+
- Language: Cpp
100+
Delimiters:
101+
- cc
102+
- CC
103+
- cpp
104+
- Cpp
105+
- CPP
106+
- 'c++'
107+
- 'C++'
108+
CanonicalDelimiter: ''
109+
BasedOnStyle: google
110+
- Language: TextProto
111+
Delimiters:
112+
- pb
113+
- PB
114+
- proto
115+
- PROTO
116+
EnclosingFunctions:
117+
- EqualsProto
118+
- EquivToProto
119+
- PARSE_PARTIAL_TEXT_PROTO
120+
- PARSE_TEST_PROTO
121+
- PARSE_TEXT_PROTO
122+
- ParseTextOrDie
123+
- ParseTextProtoOrDie
124+
CanonicalDelimiter: ''
125+
BasedOnStyle: google
126+
ReflowComments: true
127+
SortIncludes: true
128+
SortUsingDeclarations: true
129+
SpaceAfterCStyleCast: false
130+
SpaceAfterTemplateKeyword: true
131+
SpaceBeforeAssignmentOperators: true
132+
SpaceBeforeCpp11BracedList: false
133+
SpaceBeforeCtorInitializerColon: true
134+
SpaceBeforeInheritanceColon: true
135+
SpaceBeforeParens: ControlStatements
136+
SpaceBeforeRangeBasedForLoopColon: true
137+
SpaceInEmptyParentheses: false
138+
SpacesBeforeTrailingComments: 2
139+
SpacesInAngles: false
140+
SpacesInContainerLiterals: true
141+
SpacesInCStyleCastParentheses: false
142+
SpacesInParentheses: false
143+
SpacesInSquareBrackets: false
144+
Standard: Auto
145+
StatementMacros:
146+
- Q_UNUSED
147+
- QT_REQUIRE_VERSION
148+
TabWidth: 8
149+
UseTab: Never
150+
...

.github/workflows/clang-format.yml

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
name: test-clang-format
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
8+
jobs:
9+
build:
10+
runs-on: ubuntu-latest
11+
12+
steps:
13+
- uses: actions/checkout@v2
14+
- uses: DoozyX/[email protected]
15+
with:
16+
source: '.'
17+
exclude: 'docker-images,doxygen,examples,testing-resources'
18+
extensions: 'h,c,cpp'
19+
clangFormatVersion: 9

reformat.sh

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/bin/bash
2+
3+
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License"). You may not use
6+
# this file except in compliance with the License. A copy of the License is
7+
# located at
8+
#
9+
# http://aws.amazon.com/apache2.0/
10+
#
11+
# or in the "license" file accompanying this file. This file is distributed on an
12+
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13+
# implied. See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
# The command used to generate the clang-format config file is:
17+
# clang-format --style=Google -dump-config
18+
19+
set -euxo pipefail
20+
find . -name '*.h' -or -name '*.c' -or -name '*.cpp' | xargs clang-format -i

0 commit comments

Comments
 (0)