minor improvements for auto-formatter

This commit is contained in:
Robin Müller 2022-05-16 14:54:43 +02:00
parent f0debecbbc
commit 1e7032f89c
No known key found for this signature in database
GPG Key ID: 71B58F8A3CDFA9AC

View File

@ -4,9 +4,10 @@ if [[ ! -f README.md ]]; then
fi fi
cmake_fmt="cmake-format" cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then if command -v ${cmake_fmt} &> /dev/null; then
cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt" ${cmake_fmt} -i CMakeLists.txt
eval ${cmake_fmt_cmd} find ./src ${file_selectors} | xargs ${cmake_fmt} -i
else else
echo "No ${cmake_fmt} tool found, not formatting CMake files" echo "No ${cmake_fmt} tool found, not formatting CMake files"
fi fi
@ -14,9 +15,9 @@ fi
cpp_format="clang-format" cpp_format="clang-format"
file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp" file_selectors="-iname *.h -o -iname *.cpp -o -iname *.c -o -iname *.tpp"
if command -v ${cpp_format} &> /dev/null; then if command -v ${cpp_format} &> /dev/null; then
find ./src ${file_selectors} | xargs clang-format --style=file -i find ./src ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./hal ${file_selectors} | xargs clang-format --style=file -i find ./hal ${file_selectors} | xargs ${cpp_format} --style=file -i
find ./tests ${file_selectors} | xargs clang-format --style=file -i find ./tests ${file_selectors} | xargs ${cpp_format} --style=file -i
else else
echo "No ${cpp_format} tool found, not formatting C++/C files" echo "No ${cpp_format} tool found, not formatting C++/C files"
fi fi