mirror of
https://gitea.windcorp.ru/Wind-Corporation/Progressia.git
synced 2025-07-06 21:50:52 +03:00
Initial commit
This commit is contained in:
28
tools/cppcheck/options.txt
Normal file
28
tools/cppcheck/options.txt
Normal file
@ -0,0 +1,28 @@
|
||||
# CppCheck command line arguments
|
||||
# Each line is treated as one argument, unless it is empty or it starts with #.
|
||||
#
|
||||
# Available variables:
|
||||
# ${CMAKE_SOURCE_DIR} project root
|
||||
# ${CMAKE_BINARY_DIR} CMake build directory
|
||||
|
||||
--enable=warning,style,information
|
||||
#--enable=unusedFunction # Unused functions are often OK since they are intended
|
||||
# # to be used later
|
||||
#--enable=missingInclude # Very prone to false positives; system-dependent
|
||||
--inconclusive
|
||||
|
||||
# SUPPRESSIONS
|
||||
# Warnings that are suppressed on a case-by-case basis should be suppressed
|
||||
# using inline suppressions.
|
||||
# Warnings that were decided to be generally inapplicable should be suppressed
|
||||
# using suppressions.txt.
|
||||
# Warnings that result from the way cppcheck is invoked should be suppressed
|
||||
# using this file.
|
||||
|
||||
--inline-suppr
|
||||
--suppressions-list=${CMAKE_SOURCE_DIR}/tools/cppcheck/suppressions.txt
|
||||
|
||||
# N.B.: this path is also mentioned in use scripts
|
||||
--cppcheck-build-dir=${CMAKE_BINARY_DIR}/cppcheck
|
||||
|
||||
--error-exitcode=2
|
15
tools/cppcheck/suppressions.txt
Normal file
15
tools/cppcheck/suppressions.txt
Normal file
@ -0,0 +1,15 @@
|
||||
# CppCheck global suppressions
|
||||
# Do not use this file for suppressions that could easily be declared inline.
|
||||
|
||||
# Allow the use of implicit constructors.
|
||||
noExplicitConstructor:*
|
||||
|
||||
# In most cases using STL algorithm functions causes unnecessary code bloat.
|
||||
useStlAlgorithm:*
|
||||
|
||||
# cppcheck trips on #include <embedded_resources.h> and there's no way to
|
||||
# suppress that exlusively
|
||||
missingInclude:*
|
||||
|
||||
# Shut up. Just shut up.
|
||||
unmatchedSuppression:*
|
65
tools/cppcheck/use-cppcheck.sh
Executable file
65
tools/cppcheck/use-cppcheck.sh
Executable file
@ -0,0 +1,65 @@
|
||||
#!/bin/bash
|
||||
|
||||
usage=\
|
||||
"Usage: use-cppcheck.sh
|
||||
Run cppcheck with correct options.
|
||||
|
||||
Environment variables:
|
||||
PARALLELISM threads to use, default is 1
|
||||
|
||||
CPPCHECK cppcheck executable
|
||||
CMAKE cmake executable"
|
||||
|
||||
rsrc="$(dirname "$(realpath "${BASH_SOURCE[0]}")")"
|
||||
source "$rsrc/../bashlib.sh"
|
||||
|
||||
find_cmd CPPCHECK cppcheck
|
||||
find_cmd CMAKE cmake
|
||||
|
||||
case "$1" in
|
||||
-h | --help )
|
||||
echo "$usage"
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
|
||||
# Generate compile database for CppCheck
|
||||
command "$CMAKE" \
|
||||
-B "$build_dir" \
|
||||
-S "$source_dir" \
|
||||
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON
|
||||
|
||||
compile_database="$build_dir/compile_commands.json"
|
||||
|
||||
mkdir -p "$build_dir/cppcheck"
|
||||
|
||||
options=()
|
||||
|
||||
while IFS='' read -r line; do
|
||||
[ -z "$line" ] && continue
|
||||
[ "${line:0:1}" = '#' ] && continue
|
||||
|
||||
option="$(
|
||||
CMAKE_SOURCE_DIR="$source_dir" \
|
||||
CMAKE_BINARY_DIR="$build_dir" \
|
||||
envsubst <<<"$line"
|
||||
)"
|
||||
|
||||
options+=("$option")
|
||||
done < "$tools_dir/cppcheck/options.txt"
|
||||
|
||||
[ -n "${PARALLELISM+x}" ] && options+=(-j "$PARALLELISM")
|
||||
|
||||
errors="`
|
||||
echo_and_run "$CPPCHECK" \
|
||||
--project="$compile_database" \
|
||||
-D__CPPCHECK__ \
|
||||
"${options[@]}" \
|
||||
2>&1 >/dev/fd/0 # Store stderr into variable, pass stdout to our stdout
|
||||
`"
|
||||
|
||||
exit_code="$?"
|
||||
if [ "$exit_code" -eq 2 ]; then
|
||||
less - <<<"$errors"
|
||||
exit "$exit_code"
|
||||
fi
|
Reference in New Issue
Block a user