Skip to content

Commit 63a4928

Browse files
committed
feat(scripts): Pick the right clang-format if available
Signed-off-by: Diogo Behrens <[email protected]>
1 parent 7598e0b commit 63a4928

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

scripts/clang-format.sh

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,22 @@ fi
1919
if [ "${STYLE}" != "" ]; then
2020
STYLE=":${STYLE}"
2121
fi
22+
if clang-format --version | grep -q "version 14\."; then
23+
CLANG_FORMAT=clang-format
24+
elif which clang-format-14 > /dev/null; then
25+
# clang-format-14 is installed, use it instead!
26+
CLANG_FORMAT=clang-format-14
27+
else
28+
echo "Warning: clang-format 14 not found!"
29+
echo " The formatted code is likely to fail vatomic CICD pipeline"
30+
fi
2231

2332
# Apply clang-format to all *.h and *.c files in src folder.
2433
find "$@" \( -name '*.h' -o -name '*.c' -o -name '*.cpp' -o -name '*.hpp' -o -name '*.cxx' \) \
2534
-not -path '*/build/*' \
2635
-not -path '*/deps/*' \
2736
-type f \
28-
-exec clang-format -style=file${STYLE} -i {} +
37+
-exec ${CLANG_FORMAT} -style=file${STYLE} -i {} +
2938

3039
if [ "${SILENT}" != "true" ]; then
3140
# Display changed files and exit with 1 if there were differences.

0 commit comments

Comments
 (0)