format.sh 905 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. clang_format_version=$(clang-format --version 2>&1)
  3. if [[ $clang_format_version == *"version 15"* ]]; then
  4. echo "use clang-format-15"
  5. else
  6. echo "error, can not find clang-format-15"
  7. exit 1
  8. fi
  9. # clang-format, version v15 is required
  10. find ./src -regex '.*\.cc\|.*\.h\|.*\.proto' -and -not -regex '.*\.pb\.cc\|.*\.pb\.h' | xargs clang-format -i --style=file
  11. echo "clang-format done"
  12. # cmake-format, apt install cmake-format
  13. { find . -maxdepth 1 -name "CMakeLists.txt"; find ./src -name "CMakeLists.txt"; } | xargs cmake-format -c ./.cmake-format.py -i
  14. { find ./cmake -name "*.cmake"; find ./src -name "*.cmake"; } | xargs cmake-format -c ./.cmake-format.py -i
  15. echo "cmake-format done"
  16. # autopep8, apt install python3-autopep8
  17. { find . -maxdepth 1 -name "*.py" -print; find ./src -name "*.py" -print; } | xargs autopep8 -i --global-config ./.pycodestyle
  18. echo "python format done"