diff options
author | Konstantin Käfer <mail@kkaefer.com> | 2019-04-03 12:27:14 +0200 |
---|---|---|
committer | Konstantin Käfer <mail@kkaefer.com> | 2019-04-05 11:49:17 +0200 |
commit | 3ceabcd3ec91dbd9458d3c5b78fb12c3182636e1 (patch) | |
tree | b8be2ac790afce844178a314b42683ab9d06f744 /scripts/clang-tools.sh | |
parent | d7aaf83421261087a99d18d92eca9637c1bf72f8 (diff) | |
download | qtlocation-mapboxgl-3ceabcd3ec91dbd9458d3c5b78fb12c3182636e1.tar.gz |
[core] clang-tidy fixes
Diffstat (limited to 'scripts/clang-tools.sh')
-rwxr-xr-x | scripts/clang-tools.sh | 65 |
1 files changed, 16 insertions, 49 deletions
diff --git a/scripts/clang-tools.sh b/scripts/clang-tools.sh index 1e73951176..54a3958488 100755 --- a/scripts/clang-tools.sh +++ b/scripts/clang-tools.sh @@ -1,64 +1,31 @@ #!/usr/bin/env bash -set -e -set -o pipefail +set -euo pipefail -CLANG_TIDY_PREFIX=${CLANG_TIDY_PREFIX:-$(scripts/mason.sh PREFIX clang-tidy VERSION 4.0.1)} -CLANG_TIDY=${CLANG_TIDY:-${CLANG_TIDY_PREFIX}/bin/clang-tidy} -CLANG_APPLY=${CLANG_APPLY:-${CLANG_TIDY_PREFIX}/bin/clang-apply-replacements} +CLANG_TIDY_PREFIX=${CLANG_TIDY_PREFIX:-$(scripts/mason.sh PREFIX clang-tidy VERSION 7.0.0)} +CLANG_TIDY=${CLANG_TIDY_PREFIX}/bin/clang-tidy +CLANG_APPLY=${CLANG_TIDY_PREFIX}/bin/clang-apply-replacements -CLANG_FORMAT=${CLANG_FORMAT:-$(scripts/mason.sh PREFIX clang-format VERSION 4.0.1)/bin/clang-format} - -for CLANG_FILE in "${CLANG_TIDY} ${CLANG_APPLY} ${CLANG_FORMAT}"; do - command -v ${CLANG_TIDY} > /dev/null 2>&1 || { +for CLANG_FILE in "${CLANG_TIDY}" "${CLANG_APPLY}"; do + command -v "${CLANG_FILE}" > /dev/null 2>&1 || { echo "Can't find ${CLANG_FILE} in PATH." - if [ -z ${CLANG_FILE} ]; then + if [ -z "${CLANG_FILE}" ]; then echo "Alternatively, you can manually set ${!CLANG_FILE@}." fi exit 1 } done -cd $1 - -export CDUP=$(git rev-parse --show-cdup) -export CLANG_TIDY CLANG_APPLY CLANG_FORMAT - -function run_clang_tidy() { - FILES=$(git ls-files "src/mbgl/*.cpp" "platform/*.cpp" "test/*.cpp") - ${CLANG_TIDY_PREFIX}/share/run-clang-tidy.py -j ${JOBS} \ - -clang-tidy-binary ${CLANG_TIDY} \ - -clang-apply-replacements-binary ${CLANG_APPLY} \ - -fix ${FILES} 2>/dev/null || exit 1 -} - -function run_clang_tidy_diff() { - OUTPUT=$(git diff origin/$2 --src-prefix=${CDUP} --dst-prefix=${CDUP} | \ - ${CLANG_TIDY_PREFIX}/share/clang-tidy-diff.py \ - -clang-tidy-binary ${CLANG_TIDY} \ - 2>/dev/null) - if [[ -n $OUTPUT ]] && [[ $OUTPUT != "No relevant changes found." ]]; then - echo -e "${OUTPUT}" - exit 1 - fi -} - -function run_clang_format() { - echo "Running clang-format on $0..." - DIFF_FILES=$(git diff origin/$2 --name-only *cpp) - echo "${DIFF_FILES}" | xargs -I{} -P ${JOBS} bash -c 'run_clang_format' {} - ${CLANG_FORMAT} -i ${CDUP}/$0 || exit 1 -} - -export -f run_clang_tidy run_clang_tidy_diff run_clang_format - echo "Running Clang checks... (this might take a while)" -if [[ -n $3 ]] && [[ $3 == "--diff" ]]; then - run_clang_tidy_diff $@ - # XXX disabled until we run clang-format over the entire codebase. - #run_clang_format $@ - echo "All checks pass!" +if [[ -n ${3:-} ]] && [[ ${3:-} == "--diff" ]]; then + git diff "origin/$2" | "scripts/clang-tidy-diff.py" \ + -clang-tidy-binary "${CLANG_TIDY}" \ + -p 1 -quiet -path "$1" else - run_clang_tidy $@ + git ls-files "src/*.cpp" "test/*.cpp" "platform/*.cpp" "bin/*.cpp" | \ + xargs "${CLANG_TIDY_PREFIX}/share/run-clang-tidy.py" \ + -clang-tidy-binary "${CLANG_TIDY}" \ + -clang-apply-replacements-binary "${CLANG_APPLY}" \ + -quiet -p "$1" -fix fi |