Merge pull request 'improvements for auto-formatter script' (#665) from eive/fsfw:mueller/update-afmt-script into development

Reviewed-on: fsfw/fsfw#665
This commit is contained in:
Steffen Gaisser 2022-08-29 15:06:56 +02:00
commit 6c2b5ab39e
1 changed files with 9 additions and 2 deletions

View File

@ -3,6 +3,11 @@ if [[ ! -f README.md ]]; then
cd .. cd ..
fi fi
folder_list=(
"./src"
"./unittests"
)
cmake_fmt="cmake-format" cmake_fmt="cmake-format"
file_selectors="-iname CMakeLists.txt" file_selectors="-iname CMakeLists.txt"
if command -v ${cmake_fmt} &> /dev/null; then if command -v ${cmake_fmt} &> /dev/null; then
@ -15,8 +20,10 @@ 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 ${cpp_format} --style=file -i for dir in ${folder_list[@]}; do
find ./unittests ${file_selectors} | xargs ${cpp_format} --style=file -i echo "Auto-formatting ${dir} recursively"
find ${dir} ${file_selectors} | xargs clang-format --style=file -i
done
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