File indexing completed on 2023-11-26 08:10:46
0001 #!/bin/bash 0002 0003 0004 if [ -f compile_commands.json ]; then 0005 echo "Using the existing compilation db" 0006 else 0007 echo "Generating the compile db" 0008 cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON . 0009 fi 0010 0011 echo "Retrieving the list of files to process..." 0012 git ls-files > file_list 0013 touch to_process 0014 touch headers 0015 0016 echo "Cleaning the list of files to process..." 0017 for file in `cat file_list`; 0018 do 0019 if grep -Fq "${file}" compile_commands.json 0020 then 0021 echo $file >> to_process 0022 fi 0023 if echo $file | grep -q "\.[ih][p]*$" 0024 then 0025 echo $file >> headers 0026 fi 0027 done; 0028 0029 echo "Formatting source files" 0030 parallel -j 8 clang-format -i -style=file {} :::: to_process 0031 echo "Formatting header files" 0032 parallel -j 8 clang-format -i -style=file {} :::: headers 0033 0034 echo "Linting" 0035 parallel -j 8 clang-tidy -fix -config="" {} :::: to_process 0036 0037 echo "Reformatting source files" 0038 parallel -j 8 clang-format -i -style=file {} :::: to_process 0039 echo "Reformatting header files" 0040 parallel -j 8 clang-format -i -style=file {} :::: headers 0041 0042 rm file_list 0043 rm to_process 0044 rm headers