Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/pkg
Path: blob/main/external/curl/scripts/cmakelint.sh
2649 views
1
#!/bin/sh
2
#***************************************************************************
3
# _ _ ____ _
4
# Project ___| | | | _ \| |
5
# / __| | | | |_) | |
6
# | (__| |_| | _ <| |___
7
# \___|\___/|_| \_\_____|
8
#
9
# Copyright (C) Dan Fandrich, <[email protected]>, Viktor Szakats, 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
# https://cmake-format.readthedocs.io/en/latest/cmake-lint.html
27
# https://cmake-format.readthedocs.io/en/latest/lint-usage.html
28
# https://github.com/cheshirekow/cmake_format/blob/master/cmakelang/configuration.py
29
30
# Run cmakelint on the curl source code. It will check all files given on the
31
# command-line, or else all relevant files in git, or if not in a git
32
# repository, all files starting in the tree rooted in the current directory.
33
#
34
# cmake-lint can be installed from PyPi with the command "python3 -m pip
35
# install cmakelang".
36
#
37
# The xargs invocation is portable, but does not preserve spaces in file names.
38
# If such a file is ever added, then this can be portably fixed by switching to
39
# "xargs -I{}" and appending {} to the end of the xargs arguments (which will
40
# call cmakelint once per file) or by using the GNU extension "xargs -d'\n'".
41
42
set -eu
43
44
cd "$(dirname "$0")"/..
45
46
{
47
if [ -n "${1:-}" ]; then
48
for A in "$@"; do printf "%s\n" "$A"; done
49
elif git rev-parse --is-inside-work-tree >/dev/null 2>&1; then
50
git ls-files
51
else
52
# strip off the leading ./ to make the grep regexes work properly
53
find . -type f | sed 's@^\./@@'
54
fi
55
} | grep -E '(^CMake|/CMake|\.cmake$)' | grep -v -E '(\.h\.cmake|\.in|\.c)$' \
56
| xargs \
57
cmake-lint \
58
--suppress-decorations \
59
--disable \
60
--line-width 132 \
61
--tab-size 2 \
62
--use-tabchars false \
63
--disabled-codes C0113 \
64
--function-pattern 'curl_[0-9a-z_]+' \
65
--macro-pattern '(curl_[0-9a-z_]+|check_include_file_concat_curl)' \
66
--global-var-pattern '[A-Z][0-9A-Z_]+' \
67
--internal-var-pattern '_[a-z][0-9a-z_]+' \
68
--local-var-pattern '_[a-z][0-9a-z_]+' \
69
--private-var-pattern '_[0-9a-z_]+' \
70
--public-var-pattern '([A-Z][0-9A-Z_]+|[A-Z][A-Za-z0-9]+_FOUND|[a-z]+_SOURCES|prefix|exec_prefix|includedir|libdir|ssize_t|_FILE_OFFSET_BITS)' \
71
--argument-var-pattern '_[a-z][0-9a-z_]+' \
72
--keyword-pattern '[A-Z][0-9A-Z_]+' \
73
--max-conditionals-custom-parser 2 \
74
--min-statement-spacing 1 \
75
--max-statement-spacing 2 \
76
--max-returns 6 \
77
--max-branches 12 \
78
--max-arguments 5 \
79
--max-localvars 15 \
80
--max-statements 50 \
81
--
82
83