43 lines
1023 B
Bash
Executable File
43 lines
1023 B
Bash
Executable File
#!/bin/bash
|
|
UNCRUSTIFY_VERSION="0.72.0"
|
|
UNCRUSTIFY="${UNCRUSTIFY-uncrustify}"
|
|
|
|
DETECTED_VERSION=$("$UNCRUSTIFY" --version 2>&1 | grep -o -E '[0-9.]+')
|
|
if [ "$DETECTED_VERSION" != "${UNCRUSTIFY_VERSION}" ]; then
|
|
echo "You should use version: ${UNCRUSTIFY_VERSION}"
|
|
echo "Detected version: ${DETECTED_VERSION}"
|
|
exit 1
|
|
fi
|
|
|
|
# OS variables
|
|
[ $(uname -s) = "Darwin" ] && export OSX=1 && export UNIX=1
|
|
[ $(uname -s) = "Linux" ] && export LINUX=1 && export UNIX=1
|
|
uname -s | grep -q "_NT-" && export WINDOWS=1
|
|
|
|
if [ $OSX ]
|
|
then
|
|
export CPUCOUNT=$(sysctl -n hw.ncpu)
|
|
elif [ $LINUX ]
|
|
then
|
|
export CPUCOUNT=$(nproc)
|
|
else
|
|
export CPUCOUNT="1"
|
|
fi
|
|
|
|
function formatCplusplus {
|
|
find $1 -iname '*.h' \
|
|
-o -iname '*.c' \
|
|
-o -iname '*.cpp' \
|
|
| xargs -n 1 -P $CPUCOUNT -I{} -t $UNCRUSTIFY -c .uncrustify.cfg --no-backup {}
|
|
|
|
}
|
|
|
|
formatCplusplus cli/
|
|
formatCplusplus democlient/
|
|
formatCplusplus gui/
|
|
formatCplusplus lib/
|
|
formatCplusplus oss-fuzz/
|
|
formatCplusplus test/
|
|
formatCplusplus tools/
|
|
formatCplusplus samples/
|