2019-09-22 21:19:10 +00:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh
|
|
|
|
|
|
|
|
set +x
|
|
|
|
set -o errexit
|
|
|
|
set -o pipefail
|
|
|
|
set -o nounset
|
|
|
|
|
|
|
|
# Runs the Clang Formatter in parallel on the code base.
|
|
|
|
# Return codes:
|
|
|
|
# - 1 there are files to be formatted
|
|
|
|
# - 0 everything looks fine
|
|
|
|
|
|
|
|
# Get CPU count
|
|
|
|
OS=$(uname)
|
|
|
|
NPROC=1
|
|
|
|
if [[ $OS = "Linux" ]] ; then
|
|
|
|
NPROC=$(nproc)
|
|
|
|
elif [[ ${OS} = "Darwin" ]] ; then
|
|
|
|
NPROC=$(sysctl -n hw.physicalcpu)
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Discover clang-format
|
|
|
|
if type clang-format-8 2> /dev/null ; then
|
|
|
|
CLANG_FORMAT=clang-format-8
|
|
|
|
else
|
|
|
|
CLANG_FORMAT=clang-format
|
|
|
|
fi
|
|
|
|
|
2019-12-10 19:31:54 +00:00
|
|
|
find . -type d \( -path ./deps \
|
|
|
|
-o -path ./cmake \
|
2020-03-25 08:07:22 +00:00
|
|
|
-o -path ./plugins/decklink/win/decklink-sdk \
|
|
|
|
-o -path ./plugins/decklink/mac/decklink-sdk \
|
|
|
|
-o -path ./plugins/decklink/linux/decklink-sdk \
|
2019-12-10 19:31:54 +00:00
|
|
|
-o -path ./plugins/enc-amf \
|
|
|
|
-o -path ./plugins/mac-syphon/syphon-framework \
|
|
|
|
-o -path ./plugins/obs-outputs/ftl-sdk \
|
|
|
|
-o -path ./plugins/obs-vst \
|
|
|
|
-o -path ./build \) -prune -type f -o -name '*.h' -or -name '*.hpp' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \
|
2019-10-13 19:58:08 +00:00
|
|
|
| xargs -I{} -P ${NPROC} ${CLANG_FORMAT} -i -style=file -fallback-style=none {}
|