mirror of
https://github.com/obsproject/obs-studio.git
synced 2024-09-20 04:42:18 +02:00
c993b6059a
Also updates main CMakeLists.txt and CMakeLists.txt for unit tests, also adds additional build directories to .gitignore file
61 lines
1.6 KiB
Bash
Executable File
61 lines
1.6 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Original source https://github.com/Project-OSRM/osrm-backend/blob/master/scripts/format.sh
|
|
|
|
set -o errexit
|
|
set -o pipefail
|
|
set -o nounset
|
|
|
|
if [ ${#} -eq 1 ]; then
|
|
VERBOSITY="--verbose"
|
|
else
|
|
VERBOSITY=""
|
|
fi
|
|
|
|
# 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-12 2> /dev/null ; then
|
|
CLANG_FORMAT=clang-format-12
|
|
elif type clang-format 2> /dev/null ; then
|
|
# Clang format found, but need to check version
|
|
CLANG_FORMAT=clang-format
|
|
V=$(clang-format --version)
|
|
if [[ $V != *"version 12.0"* ]]; then
|
|
echo "clang-format is not 12.0 (returned ${V})"
|
|
exit 1
|
|
fi
|
|
else
|
|
echo "No appropriate clang-format found (expected clang-format-12.0.0, or clang-format)"
|
|
exit 1
|
|
fi
|
|
|
|
find . -type d \( \
|
|
-path ./\*build -o \
|
|
-path ./cmake -o \
|
|
-path ./deps -o \
|
|
-path ./plugins/decklink/\*/decklink-sdk -o \
|
|
-path ./plugins/enc-amf -o \
|
|
-path ./plugins/mac-syphon/syphon-framework -o \
|
|
-path ./plugins/obs-outputs/ftl-sdk -o \
|
|
-path ./plugins/obs-vst \
|
|
\) -prune -false -type f -o \
|
|
-name '*.h' -or \
|
|
-name '*.hpp' -or \
|
|
-name '*.m' -or \
|
|
-name '*.m,' -or \
|
|
-name '*.c' -or \
|
|
-name '*.cpp' \
|
|
| xargs -L100 -P ${NPROC} ${CLANG_FORMAT} ${VERBOSITY} -i -style=file -fallback-style=none
|