]> git.saurik.com Git - apple/xnu.git/blame - tools/reindent.sh
xnu-3789.1.32.tar.gz
[apple/xnu.git] / tools / reindent.sh
CommitLineData
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
8CPUS=`sysctl -n hw.logicalcpu`
9CLANGFORMAT=`xcrun -find clang-format`
10
11if [ ! -x "${CLANGFORMAT}" ]; then
12 echo "Could not find clang-format" 1>&2
13 exit 1
14fi
15
16echo "Using ${CLANGFORMAT} to reindent, using concurrency of ${CPUS}"
17
18find -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
20ret=$?
21
22if [ $ret -ne 0 ]; then
23 echo "reindent failed: $ret" 1>&2
24 exit 1
25fi
26
27exit 0