2
0

cmakelint.sh 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/bin/sh
  2. #***************************************************************************
  3. # _ _ ____ _
  4. # Project ___| | | | _ \| |
  5. # / __| | | | |_) | |
  6. # | (__| |_| | _ <| |___
  7. # \___|\___/|_| \_\_____|
  8. #
  9. # Copyright (C) Dan Fandrich, <dan@coneharvesters.com>, et al.
  10. #
  11. # This software is licensed as described in the file COPYING, which
  12. # you should have received as part of this distribution. The terms
  13. # are also available at https://curl.se/docs/copyright.html.
  14. #
  15. # You may opt to use, copy, modify, merge, publish, distribute and/or sell
  16. # copies of the Software, and permit persons to whom the Software is
  17. # furnished to do so, under the terms of the COPYING file.
  18. #
  19. # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
  20. # KIND, either express or implied.
  21. #
  22. # SPDX-License-Identifier: curl
  23. #
  24. ###########################################################################
  25. # Run cmakelint on the curl source code. It will check all files given on the
  26. # command-line, or else all relevant files in git, or if not in a git
  27. # repository, all files starting in the tree rooted in the current directory.
  28. #
  29. # cmakelint can be installed from PyPi with the command "python3 -m pip install
  30. # cmakelint".
  31. #
  32. # The xargs invocation is portable, but does not preserve spaces in file names.
  33. # If such a file is ever added, then this can be portably fixed by switching to
  34. # "xargs -I{}" and appending {} to the end of the xargs arguments (which will
  35. # call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".
  36. {
  37. if [ -n "$1" ]; then
  38. for A in "$@"; do printf "%s\n" "$A"; done
  39. elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
  40. git ls-files
  41. else
  42. # strip off the leading ./ to make the grep regexes work properly
  43. find . -type f | sed 's@^\./@@'
  44. fi
  45. } | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in)$' \
  46. | xargs \
  47. cmakelint \
  48. --spaces=2 --linelength=132 \
  49. --filter=-whitespace/indent,-convention/filename,-package/stdargs