diff options
| author | Florian Fischer <florian.fl.fischer@fau.de> | 2020-05-04 11:10:26 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fl.fischer@fau.de> | 2020-05-04 11:10:26 +0200 |
| commit | 436187efa55385c2bec80981d255566d5083c9e8 (patch) | |
| tree | d844402679c49910327f2cd6b358a239db68af2b /tools | |
| parent | c24348eb207fdd124b61212c27ab6951279ce322 (diff) | |
| download | chattymalloc-436187efa55385c2bec80981d255566d5083c9e8.tar.gz chattymalloc-436187efa55385c2bec80981d255566d5083c9e8.zip | |
copy speedymalloc's build system
Thanks to Florian Schmaus for most of the work.
Diffstat (limited to 'tools')
| -rwxr-xr-x | tools/check-format | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/check-format b/tools/check-format new file mode 100755 index 0000000..414ddc4 --- /dev/null +++ b/tools/check-format @@ -0,0 +1,26 @@ +#!/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 |
