diff --git a/tools/code-style.sh b/tools/code-style.sh index c02d0ff453f75f9eae7787c5c29a0db069f387f2..7ef93e62172cfde33fe17f13d65f467de03529d1 100755 --- a/tools/code-style.sh +++ b/tools/code-style.sh @@ -37,21 +37,40 @@ fi script_dir="$(dirname "$0")" +formatter_blacklist=( + lib/ff13/ + lib/FreeRTOS/ + lib/FreeRTOS-Plus/ + lib/gfx/ + lib/micropython/ + lib/mx25lba/ + lib/sdk/ + lib/vendor/ + openocd/ + docker/ +) + for source_file in "$@"; do # Check if file is actually one which we want to check rel_path="$(realpath --relative-to="$script_dir/.." "$source_file")" - if [[ ( "$rel_path" == lib/* && "$rel_path" != lib/card10/* ) || - ( "$rel_path" == openocd/* ) ]]; then - echo " - Ignoring $source_file" + format_item=true + for blacklist_item in "${formatter_blacklist[@]}"; do + if [[ "$rel_path" == "$blacklist_item"* ]]; then + format_item=false + break + fi + done + if [[ "$format_item" == false ]]; then + echo -e "\tIGN\t\t$source_file" continue fi if [[ "$source_file" == *.c ]]; then - echo " - Formatting $source_file ..." + echo -e "\tCLANG-FORMAT\t$source_file" clang-format -i "$source_file" python3 "$script_dir/fix-multi-decl.py" "$source_file" elif [[ "$source_file" == *.py ]]; then - echo " - Formatting $source_file ..." + echo -e "\tBLACK\t\t$source_file" black -q "$source_file" else echo " - Ignoring $source_file" >&2