calamaresstyle 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #!/bin/sh
  2. #
  3. # Calls astyle with settings matching Calamares coding style
  4. # Requires astyle >= 2.04 and clang-format-7
  5. #
  6. # You can pass in directory names, in which case the files
  7. # in that directory (NOT below it) are processed.
  8. #
  9. set -e
  10. AS=$( which astyle )
  11. CF=$( which clang-format-7 )
  12. test -n "$AS" || { echo "! No astyle found in PATH"; exit 1 ; }
  13. test -n "$CF" || { echo "! No clang-format-7 found in PATH"; exit 1 ; }
  14. test -x "$AS" || { echo "! $AS is not executable."; exit 1 ; }
  15. test -x "$CF" || { echo "! $CF is not executable."; exit 1 ; }
  16. any_dirs=no
  17. for d in "$@"
  18. do
  19. test -d "$d" && any_dirs=yes
  20. done
  21. style_some()
  22. {
  23. $AS --options=$(dirname $0)/astylerc --quiet "$@"
  24. $CF -i -style=file "$@"
  25. }
  26. if test "x$any_dirs" = "xyes" ; then
  27. for d in "$@"
  28. do
  29. if test -d "$@" ; then
  30. style_some $( find "$d" -maxdepth 1 -type f -name '*.cpp' -o -name '*.h' )
  31. else
  32. style_some "$d"
  33. fi
  34. done
  35. else
  36. style_some "$@"
  37. fi