format-source.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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. clang-format -style=file -i *.h
  15. pushd "GCDWebServer/Core"
  16. clang-format -style=file -i *.h *.m
  17. popd
  18. pushd "GCDWebServer/Requests"
  19. clang-format -style=file -i *.h *.m
  20. popd
  21. pushd "GCDWebServer/Responses"
  22. clang-format -style=file -i *.h *.m
  23. popd
  24. pushd "GCDWebUploader"
  25. clang-format -style=file -i *.h *.m
  26. popd
  27. pushd "GCDWebDAVServer"
  28. clang-format -style=file -i *.h *.m
  29. popd
  30. pushd "Frameworks"
  31. clang-format -style=file -i *.h *.m
  32. popd
  33. pushd "Mac"
  34. clang-format -style=file -i *.m
  35. popd
  36. pushd "tvOS"
  37. clang-format -style=file -i *.h *.m
  38. popd
  39. build/swiftformat --indent 2 "iOS"
  40. echo "OK"