feat: parallelize clang-format-all.sh (#6281)
this can be enabled by setting the FAST environment variable to 1
This commit is contained in:
@@ -1,10 +1,30 @@
|
|||||||
#!/bin/bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
read -p "Are you sure you want to run clang-format on all source files? (y/n) " -n 1 -r
|
read -p "Are you sure you want to run clang-format on all source files? (y/n) " -n 1 -r
|
||||||
echo
|
echo
|
||||||
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
if [[ $REPLY =~ ^[Yy]$ ]]; then
|
||||||
find src/ \( -iname "*.hpp" -o -iname "*.cpp" \) -exec clang-format -i {} \;
|
if [ "$FAST" = "1" ]; then
|
||||||
find tests/src/ \( -iname "*.hpp" -o -iname "*.cpp" \) -exec clang-format -i {} \;
|
if ! command -v parallel >/dev/null 2>&1; then
|
||||||
find benchmarks/src/ \( -iname "*.hpp" -o -iname "*.cpp" \) -exec clang-format -i {} \;
|
echo "Missing parallel command"
|
||||||
find mocks/include/ \( -iname "*.hpp" -o -iname "*.cpp" \) -exec clang-format -i {} \;
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
NUM_FORMAT_JOBS=${NUM_FORMAT_JOBS:-$(nproc)}
|
||||||
|
|
||||||
|
echo "Running clang-format with ${NUM_FORMAT_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 --verbose --jobs "$NUM_FORMAT_JOBS" clang-format -i
|
||||||
|
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-format -i {} \;
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user