From da96528b5511226c24562c9a3d77cab56acaad4f Mon Sep 17 00:00:00 2001 From: pajlada Date: Wed, 18 Jun 2025 01:09:32 +0200 Subject: [PATCH] chore: slight restructuring of `check-clang-tidy.sh` (#6282) --- scripts/check-clang-tidy.sh | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/scripts/check-clang-tidy.sh b/scripts/check-clang-tidy.sh index 62965189..f65a3323 100755 --- a/scripts/check-clang-tidy.sh +++ b/scripts/check-clang-tidy.sh @@ -1,12 +1,32 @@ #!/usr/bin/env bash +# example usage: FAST=1 ./scripts/check-clang-tidy.sh --checks '-*,modernize-return-braced-init-list' --fix + set -eu clang-tidy --version -find \ - src/ \ - tests/src/ \ - benchmarks/src/ \ - mocks/include/ \ - -type f \( -name "*.hpp" -o -name "*.cpp" \) -print0 | parallel -0 -j16 -I {} clang-tidy --quiet "$@" "{}" +if [ "$FAST" = "1" ]; then + if ! command -v parallel >/dev/null 2>&1; then + echo "Missing parallel command" + exit 1 + fi + + NUM_TIDY_JOBS=${NUM_TIDY_JOBS:-$(nproc)} + + echo "Running clang-tidy with args '$*', with ${NUM_TIDY_JOBS} jobs" + + find . \( \ + -regex '\./src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./tests/src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./benchmarks/src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./mocks/include/.*\.\(hpp\|cpp\)' \ + \) | parallel --jobs "$NUM_TIDY_JOBS" --verbose clang-tidy --quiet "$@" +else + find . \( \ + -regex '\./src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./tests/src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./benchmarks/src/.*\.\(hpp\|cpp\)' -o \ + -regex '\./mocks/include/.*\.\(hpp\|cpp\)' \ + \) -exec clang-tidy --quiet "$@" {} \; +fi