Skip to content
Snippets Groups Projects
run-clang-tidy 723 B
Newer Older
  • Learn to ignore specific revisions
  • #!/usr/bin/env bash
    
    SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"
    ROOTDIR="$(realpath "${SCRIPTDIR}/..")"
    
    while getopts dv OPT; do
    	case $OPT in
    		d)
    			set -x
    			;;
    
    		*)
    			echo "usage: ${0##*/} [-d]"
    			exit 2
    	esac
    done
    shift $(( OPTIND - 1 ))
    OPTIND=1
    
    RUN_CLANG_TIDY_CANDIDATES=(
    	run-clang-tidy
    	run-clang-tidy.py
    	/usr/share/clang/run-clang-tidy.py
    )
    
    RUN_CLANG_TIDY=""
    
    for candidate in ${RUN_CLANG_TIDY_CANDIDATES[@]}; do
    	if ! command -v "${candidate}"; then
    		continue;
    	fi
    
    	RUN_CLANG_TIDY="${candidate}"
    	break;
    done
    
    if [[ -z "${RUN_CLANG_TIDY}" ]]; then
    	echo "No run-clang-tidy executable found"
    	exit 1
    fi
    
    ${RUN_CLANG_TIDY} -p "${ROOTDIR}/compile_commands_wo_subprojects/"