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 26# Run cmakelint on the curl source code. It will check all files given on the 27# command-line, or else all relevant files in git, or if not in a git 28# repository, all files starting in the tree rooted in the current directory. 29# 30# cmakelint can be installed from PyPi with the command "python3 -m pip install 31# cmakelint". 32# 33# The xargs invocation is portable, but does not preserve spaces in file names. 34# If such a file is ever added, then this can be portably fixed by switching to 35# "xargs -I{}" and appending {} to the end of the xargs arguments (which will 36# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'". 37{ 38 if [ -n "$1" ]; then 39 for A in "$@"; do printf "%s\n" "$A"; done 40 elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then 41 git ls-files 42 else 43 # strip off the leading ./ to make the grep regexes work properly 44 find . -type f | sed 's@^\./@@' 45 fi 46} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in)$' \ 47 | xargs \ 48 cmakelint \ 49 --spaces=2 --linelength=132 \ 50 --filter=-whitespace/indent,-convention/filename,-package/stdargs 51