Skip to content

Commit

Permalink
Update codeformat.sh
Browse files Browse the repository at this point in the history
使用函数精简了代码,并提高可读性
  • Loading branch information
xiezheng-XD authored Aug 30, 2023
1 parent 9ecf6a6 commit 0f95f5e
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions codeformat.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

# we run clang-format and astyle twice to get stable format output

find src/ tools/ tests/ examples/ benchmark/ python/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' | grep -v python/pybind11 | grep -v stb_image | xargs -i clang-format -i {}
astyle -n -r "benchmark/*.h,*.cpp,*.cc" "tests/*.h,*.cpp,*.cc" "tools/*.h,*.cpp,*.cc" "examples/*.h,*.cpp,*.cc"
astyle -n -r "src/*.h,*.cpp,*.cc" --exclude=src/stb_image.h --exclude=src/stb_image_write.h
astyle -n -r "python/*.h,*.cpp,*.cc" --exclude=python/pybind11
format_code() {
find src/ tools/ tests/ examples/ benchmark/ python/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' | grep -v python/pybind11 | grep -v stb_image | xargs -i clang-format -i {}
astyle -n -r "benchmark/*.h,*.cpp,*.cc" "tests/*.h,*.cpp,*.cc" "tools/*.h,*.cpp,*.cc" "examples/*.h,*.cpp,*.cc"
astyle -n -r "src/*.h,*.cpp,*.cc" --exclude=src/stb_image.h --exclude=src/stb_image_write.h
astyle -n -r "python/*.h,*.cpp,*.cc" --exclude=python/pybind11
}

find src/ tools/ tests/ examples/ benchmark/ python/ -type f -name '*.c' -o -name '*.cpp' -o -name '*.cc' -o -name '*.h' | grep -v python/pybind11 | grep -v stb_image | xargs -i clang-format -i {}
astyle -n -r "benchmark/*.h,*.cpp,*.cc" "tests/*.h,*.cpp,*.cc" "tools/*.h,*.cpp,*.cc" "examples/*.h,*.cpp,*.cc"
astyle -n -r "src/*.h,*.cpp,*.cc" --exclude=src/stb_image.h --exclude=src/stb_image_write.h
astyle -n -r "python/*.h,*.cpp,*.cc" --exclude=python/pybind11
format_code || { echo 'Formatting failed' ; exit 1; }//first time execute
format_code || { echo 'Formatting failed' ; exit 1; }//second time execute

0 comments on commit 0f95f5e

Please sign in to comment.