From 951f97f559e6f3f58a67845dee4757dbb5d5a7a1 Mon Sep 17 00:00:00 2001 From: tx_haggis <13982343+adbancroft@users.noreply.github.com> Date: Tue, 28 May 2024 22:44:12 -0500 Subject: [PATCH] cppcheck: have to use absolute paths. (#1216) --- misra/check_misra.sh | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/misra/check_misra.sh b/misra/check_misra.sh index 3207fc44..da74c561 100755 --- a/misra/check_misra.sh +++ b/misra/check_misra.sh @@ -1,6 +1,14 @@ #!/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 source_folder="$script_folder/../speeduino" # -s, --source @@ -28,6 +36,12 @@ function 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_misra="${cppcheck_path}/addons/misra.py"