2021-12-01 16:08:28 +01:00
|
|
|
#!/bin/bash
|
|
|
|
if [[ ! -f README.md ]]; then
|
2022-05-13 11:49:01 +02:00
|
|
|
cd ..
|
2021-12-01 16:08:28 +01:00
|
|
|
fi
|
|
|
|
|
2022-05-13 11:37:58 +02:00
|
|
|
cmake_fmt="cmake-format"
|
2022-05-13 11:35:59 +02:00
|
|
|
if command -v ${cmake_fmt} &> /dev/null; then
|
2022-05-13 11:49:01 +02:00
|
|
|
cmake_fmt_cmd="${cmake_fmt} -i CMakeLists.txt"
|
|
|
|
eval ${cmake_fmt_cmd}
|
2022-05-13 11:46:04 +02:00
|
|
|
else
|
2022-05-13 11:49:01 +02:00
|
|
|
echo "No ${cmake_fmt} tool found, not formatting CMake files"
|
2022-05-13 11:35:59 +02:00
|
|
|
fi
|
2022-05-13 11:34:44 +02:00
|
|
|
|
2022-05-13 11:46:04 +02:00
|
|
|
cpp_format="clang-format"
|
2022-05-13 11:46:59 +02:00
|
|
|
if command -v ${cpp_format} &> /dev/null; then
|
2022-05-13 11:49:01 +02:00
|
|
|
find ./src -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
|
|
|
find ./hal -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
|
|
|
find ./tests -iname *.h -o -iname *.cpp -o -iname *.c | xargs clang-format --style=file -i
|
2022-05-13 11:46:04 +02:00
|
|
|
else
|
2022-05-13 11:49:01 +02:00
|
|
|
echo "No ${cpp_format} tool found, not formatting C++/C files"
|
2022-05-13 11:46:04 +02:00
|
|
|
fi
|