forked from esp8266/Arduino
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrestyle.sh
executable file
·91 lines (75 loc) · 1.89 KB
/
restyle.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#!/bin/sh
set -e
org=$(cd ${0%/*}; pwd)
cd ${org}/..
pwd
test -d cores/esp8266
test -d libraries
#########################################
makeClangConf()
{
IndentWidth="$1"
IndentCaseLabels="$2"
BreakBeforeBraces="$3"
cat << EOF > .clang-format
BasedOnStyle: WebKit
SortIncludes: false
AlignTrailingComments: true
ColumnLimit: 100
KeepEmptyLinesAtTheStartOfBlocks: false
SpaceBeforeInheritanceColon: false
SpacesBeforeTrailingComments: 2
AlignTrailingComments: true
AlignConsecutiveAssignments: Consecutive
AlignConsecutiveBitFields: Consecutive
AlignConsecutiveDeclarations: Consecutive
AlignAfterOpenBracket: Align
AlignOperands: Align
BreakConstructorInitializers: AfterColon
BreakBeforeBinaryOperators: All
BreakBeforeTernaryOperators: false
BreakBeforeConceptDeclarations: true
FixNamespaceComments: true
NamespaceIndentation: Inner
BreakBeforeBraces: ${BreakBeforeBraces}
IndentWidth: ${IndentWidth}
IndentCaseLabels: ${IndentCaseLabels}
EOF
}
#########################################
# 'all' variable should be "cores/esp8266 libraries"
all="
libraries/ESP8266mDNS
libraries/Wire
libraries/lwIP*
cores/esp8266/Lwip*
cores/esp8266/debug*
cores/esp8266/core_esp8266_si2c.cpp
cores/esp8266/StreamString.*
cores/esp8266/StreamSend.*
libraries/Netdump
tests
"
#########################################
# restyling core
makeClangConf 4 false Allman
for d in $all; do
if [ -d "$d" ]; then
echo "-------- directory $d:"
for e in c cpp h; do
find $d -name "*.$e" -exec clang-format-12 -i {} \;
done
else
echo "-------- file $d:"
clang-format-12 -i ${d}
fi
done
#########################################
# restyling arduino examples
makeClangConf 2 true Attach
for d in libraries; do
echo "-------- examples in $d:"
find $d -name "*.ino" -exec clang-format-12 -i {} \;
done
#########################################
rm -f .clang-format