format-source.sh 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh -exuo pipefail
  2. # brew install clang-format
  3. CLANG_FORMAT_VERSION=`clang-format -version | awk '{ print $3 }'`
  4. if [[ "$CLANG_FORMAT_VERSION" != "7.0.0" ]]; then
  5. echo "Unsupported clang-format version"
  6. exit 1
  7. fi
  8. if [[ ! -f "build/swiftformat" ]]; then
  9. mkdir -p "build"
  10. curl -sfL -o "build/SwiftFormat.zip" "https://github.com/nicklockwood/SwiftFormat/archive/0.37.2.zip"
  11. unzip "build/SwiftFormat.zip" "SwiftFormat-0.37.2/CommandLineTool/swiftformat" -d "build"
  12. mv "build/SwiftFormat-0.37.2/CommandLineTool/swiftformat" "build/swiftformat"
  13. fi
  14. pushd "GCDWebServer/Core"
  15. clang-format -style=file -i *.h *.m
  16. popd
  17. pushd "GCDWebServer/Requests"
  18. clang-format -style=file -i *.h *.m
  19. popd
  20. pushd "GCDWebServer/Responses"
  21. clang-format -style=file -i *.h *.m
  22. popd
  23. pushd "GCDWebUploader"
  24. clang-format -style=file -i *.h *.m
  25. popd
  26. pushd "GCDWebDAVServer"
  27. clang-format -style=file -i *.h *.m
  28. popd
  29. pushd "Frameworks"
  30. clang-format -style=file -i *.h *.m
  31. popd
  32. pushd "Mac"
  33. clang-format -style=file -i *.m
  34. popd
  35. build/swiftformat --indent 2 "iOS" "tvOS"
  36. echo "OK"