cppcheck: have to use absolute paths. (#1216)

This commit is contained in:
tx_haggis 2024-05-28 22:44:12 -05:00 committed by GitHub
parent 0258f641ee
commit 951f97f559
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 1 deletions

View File

@ -1,6 +1,14 @@
#!/bin/bash #!/bin/bash
# uncomment to echo *fully* expanded script commands to terminal
# set -x
script_folder="$(dirname $(readlink -f $0))"
get_abs_filename() {
# $1 : relative filename
echo "$(cd "$(dirname "$1")" && pwd)/$(basename "$1")"
}
script_folder=$(get_abs_filename "$(dirname $(readlink -f $0))")
# Initialize variables with defaults # Initialize variables with defaults
source_folder="$script_folder/../speeduino" # -s, --source source_folder="$script_folder/../speeduino" # -s, --source
@ -28,6 +36,12 @@ function parse_command_line() {
parse_command_line "$@" parse_command_line "$@"
# Have to use absolute paths for source:
# 1. CPPCheck (or the shell) expands globs to absolute paths.
# 2. CPPCheck matches paths from the command line using simple string comparisons
# 2.1. E.g. exclusion folders
source_folder=$(get_abs_filename "$source_folder")
cppcheck_bin="${cppcheck_path}/cppcheck" cppcheck_bin="${cppcheck_path}/cppcheck"
cppcheck_misra="${cppcheck_path}/addons/misra.py" cppcheck_misra="${cppcheck_path}/addons/misra.py"