0
0
mirror of https://github.com/obsproject/obs-studio.git synced 2024-09-20 13:08:50 +02:00
obs-studio/formatcode.sh
Ryan Foster 2c5b1a837f CI: Update clang-format from 10 to 12
Microsoft Visual Studio 2019 ships with LLVM/Clang 12 as of Visual
Studio 2019 16.11.0 (August 10, 2021). LLVM/Clang 12 is available on all
platforms. This change should make it easier to have clang-format "just
work" on dev systems and be consistent across platforms without having
to use an outdated version.
2021-10-13 20:00:04 +11:00

43 lines
1.3 KiB
Bash
Executable File

#!/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" || $OS = "Darwin" ]] ; then
NPROC=$(getconf _NPROCESSORS_ONLN)
fi
# Discover clang-format
if type clang-format-12 2> /dev/null ; then
CLANG_FORMAT=clang-format-12
elif type clang-format-10 2> /dev/null ; then
CLANG_FORMAT=clang-format-10
elif type clang-format-8 2> /dev/null ; then
CLANG_FORMAT=clang-format-8
else
CLANG_FORMAT=clang-format
fi
find . -type d \( -path ./deps \
-o -path ./cmake \
-o -path ./plugins/decklink/win/decklink-sdk \
-o -path ./plugins/decklink/mac/decklink-sdk \
-o -path ./plugins/decklink/linux/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 \
-o -path ./build \) -prune -type f -o -name '*.h' -or -name '*.hpp' -or -name '*.m' -or -name '*.mm' -or -name '*.c' -or -name '*.cpp' \
| xargs -L100 -P${NPROC} ${CLANG_FORMAT} -i -style=file -fallback-style=none