Skip to content

Commit fb0d464

Browse files
committed
Add format files
1 parent e41b659 commit fb0d464

File tree

2 files changed

+80
-0
lines changed

2 files changed

+80
-0
lines changed

.clang-format

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
AlignTrailingComments: true
2+
AllowAllParametersOfDeclarationOnNextLine: false
3+
AllowShortIfStatementsOnASingleLine: false
4+
AlwaysBreakTemplateDeclarations: true
5+
BasedOnStyle: LLVM
6+
BinPackArguments: false
7+
BinPackParameters: false
8+
BraceWrapping:
9+
AfterClass: false
10+
AfterControlStatement: false
11+
AfterEnum: false
12+
AfterExternBlock: false
13+
AfterFunction: true
14+
AfterNamespace: false
15+
AfterStruct: false
16+
AfterUnion: false
17+
BeforeCatch: false
18+
BeforeElse: false
19+
IndentBraces: false
20+
SplitEmptyFunction: false
21+
SplitEmptyNamespace: false
22+
SplitEmptyRecord: false
23+
BreakBeforeBraces: Custom
24+
BreakStringLiterals: false
25+
ColumnLimit: 120
26+
ConstructorInitializerAllOnOneLineOrOnePerLine: true
27+
IndentCaseLabels: false
28+
IndentWidth: 4
29+
PenaltyBreakAssignment: 2
30+
PenaltyBreakBeforeFirstCallParameter: 19
31+
PenaltyBreakComment: 10
32+
PenaltyBreakFirstLessLess: 120
33+
PenaltyBreakString: 5000
34+
PenaltyExcessCharacter: 100
35+
PenaltyReturnTypeOnItsOwnLine: 500
36+
PointerAlignment: Left
37+
SpaceBeforeParens: ControlStatements
38+
UseTab: Never

runformat

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#!/bin/bash
2+
CLANG_FORMAT_VERSION="10.0.0"
3+
CLANG_FORMAT="${CLANG_FORMAT-clang-format-10}"
4+
5+
DETECTED_VERSION=$("$CLANG_FORMAT" --version 2>&1 | awk '{ print $NF; }')
6+
if [ "$DETECTED_VERSION" != "${CLANG_FORMAT_VERSION}" ]; then
7+
echo "You should use version: ${CLANG_FORMAT_VERSION}"
8+
echo "Detected version: ${DETECTED_VERSION}"
9+
exit 1
10+
fi
11+
12+
# OS variables
13+
[ $(uname -s) = "Darwin" ] && export OSX=1 && export UNIX=1
14+
[ $(uname -s) = "Linux" ] && export LINUX=1 && export UNIX=1
15+
uname -s | grep -q "_NT-" && export WINDOWS=1
16+
17+
if [ $OSX ]
18+
then
19+
export CPUCOUNT=$(sysctl -n hw.ncpu)
20+
elif [ $LINUX ]
21+
then
22+
export CPUCOUNT=$(nproc)
23+
else
24+
export CPUCOUNT="1"
25+
fi
26+
27+
function formatCplusplus {
28+
find $1 -iname '*.h' \
29+
-o -iname '*.c' \
30+
-o -iname '*.cpp' \
31+
| xargs -n 1 -P $CPUCOUNT -I{} -t $CLANG_FORMAT --style=file -i {}
32+
33+
}
34+
35+
formatCplusplus cli/
36+
formatCplusplus democlient/
37+
formatCplusplus gui/
38+
formatCplusplus lib/
39+
formatCplusplus oss-fuzz/
40+
formatCplusplus test/
41+
formatCplusplus tools/
42+
formatCplusplus samples/

0 commit comments

Comments
 (0)