blob: 8711d7097cbe44d81271265266e7357d19154889 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
#!/usr/bin/env bash
set -euo pipefail
# Pretty fancy method to get reliable the absolute path of a shell
# script, *even if it is sourced*. Credits go to GreenFox on
# stackoverflow: http://stackoverflow.com/a/12197518/194894
pushd . > /dev/null
SCRIPTDIR="${BASH_SOURCE[0]}";
while([ -h "${SCRIPTDIR}" ]); do
cd "`dirname "${SCRIPTDIR}"`"
SCRIPTDIR="$(readlink "`basename "${SCRIPTDIR}"`")";
done
cd "`dirname "${SCRIPTDIR}"`" > /dev/null
SCRIPTDIR="`pwd`";
popd > /dev/null
ROOTDIR=$(readlink -f "${SCRIPTDIR}/..")
MAX_PROCS=$(nproc)
# Note that the --dry-run and --Werror clang-format arguments require
# clang-format 10 or higher. See https://reviews.llvm.org/D68554
find "${ROOTDIR}" -path "${ROOTDIR}/build*" -prune -o \
-type f -name '*.[c|h|cpp]' -print0 |\
xargs --null --max-args=3 --max-procs="${MAX_PROCS}" \
clang-format --style=file --dry-run -Werror
find "${ROOTDIR}" -path "${ROOTDIR}/build*" -prune -o \
-type f -name '*.py' -print0 |\
xargs --null --max-args=3 --max-procs="${MAX_PROCS}" \
yapf -p -d
|