]>
Commit | Line | Data |
---|---|---|
3e170ce0 A |
1 | #!/bin/sh |
2 | ||
3 | # | |
4 | # Reindent CWD recursively using clang-format (assumed to be in your PATH), | |
5 | # and per-component or per-directory .clang-format style specifications. | |
6 | # | |
7 | ||
8 | CPUS=`sysctl -n hw.logicalcpu` | |
9 | CLANGFORMAT=`xcrun -find clang-format` | |
10 | ||
11 | if [ ! -x "${CLANGFORMAT}" ]; then | |
12 | echo "Could not find clang-format" 1>&2 | |
13 | exit 1 | |
14 | fi | |
15 | ||
16 | echo "Using ${CLANGFORMAT} to reindent, using concurrency of ${CPUS}" | |
17 | ||
18 | find -x . \! \( \( -name BUILD -o -name EXTERNAL_HEADERS -o -name libMicro -o -name zlib -o -name .svn -o -name .git -o -name cscope.\* -o -name \*~ \) -prune \) -type f \( -name \*.c -o -name \*.cpp \) -print0 | \ | |
19 | xargs -0 -P "${CPUS}" -n 10 "${CLANGFORMAT}" -style=file -i | |
20 | ret=$? | |
21 | ||
22 | if [ $ret -ne 0 ]; then | |
23 | echo "reindent failed: $ret" 1>&2 | |
24 | exit 1 | |
25 | fi | |
26 | ||
27 | exit 0 |