#!/bin/sh1#***************************************************************************2# _ _ ____ _3# Project ___| | | | _ \| |4# / __| | | | |_) | |5# | (__| |_| | _ <| |___6# \___|\___/|_| \_\_____|7#8# Copyright (C) Dan Fandrich, <[email protected]>, et al.9#10# This software is licensed as described in the file COPYING, which11# you should have received as part of this distribution. The terms12# are also available at https://curl.se/docs/copyright.html.13#14# You may opt to use, copy, modify, merge, publish, distribute and/or sell15# copies of the Software, and permit persons to whom the Software is16# furnished to do so, under the terms of the COPYING file.17#18# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY19# KIND, either express or implied.20#21# SPDX-License-Identifier: curl22#23###########################################################################2425# Run cmakelint on the curl source code. It will check all files given on the26# command-line, or else all relevant files in git, or if not in a git27# 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 install30# 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 to34# "xargs -I{}" and appending {} to the end of the xargs arguments (which will35# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".36{37if [ -n "$1" ]; then38for A in "$@"; do printf "%s\n" "$A"; done39elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then40git ls-files41else42# strip off the leading ./ to make the grep regexes work properly43find . -type f | sed 's@^\./@@'44fi45} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in)$' \46| xargs \47cmakelint \48--spaces=2 --linelength=132 \49--filter=-whitespace/indent,-convention/filename,-package/stdargs,-readability/wonkycase505152