Warning, /sdk/clazy/clazy.cmake is written in an unsupported language. File is not indexed.
0001 #!/usr/bin/env sh
0002
0003 libdir=$("@READLINK_CMD@" -f "$(dirname ${0})/@BIN_RELATIVE_LIBDIR@")
0004 sharedir=$("@READLINK_CMD@" -f "$(dirname ${0})/@BIN_RELATIVE_SHAREDIR@")
0005
0006 HELP() {
0007 echo "Usage: `basename $0` [options] [clang++-options]"
0008 echo
0009 echo "Static analyzer for C++/Qt code (https://invent.kde.org/sdk/clazy)"
0010 echo
0011 echo "Options:"
0012 echo " --help print program help"
0013 echo " --version print the program version"
0014 echo " --standalone run clazy-standalone instead of clang"
0015 echo " --list print a list of all available checkers, arranged by level"
0016 echo " --explain [regexp] print explanations for the checker matching a regexp"
0017 echo "or"
0018 echo " --explain print explanations for all checkers"
0019 echo
0020 echo "Any of the options above will print the requested information and then exit."
0021 echo
0022 echo "Convenience Options:"
0023 echo " --qt4compat Qt4 compatibility mode. useful for source code that can build with Qt4"
0024 echo " (this is the same as passing \"-Xclang -plugin-arg-clazy -Xclang qt4-compat\")"
0025 echo " --qtdeveloper Special option for building Qt5 itself resulting in fewer false positives"
0026 echo " (this is the same as passing \"-Xclang -plugin-arg-clazy -Xclang qt-developer\")"
0027 echo
0028 echo "All other options are passed directly to clang++ and handled from there."
0029 echo
0030 echo "See the clang++ manual for a list of the very large set of options available"
0031 echo
0032 echo "Environment Variables:"
0033 echo " CLANGXX Path to the clang++ executable to use"
0034 echo
0035 }
0036
0037 VERSION() {
0038 echo "clazy version: @CLAZY_PRINT_VERSION@"
0039 ${CLANGXX:-clang++} --version | head -1 | awk '{printf("clang version: %s\n",$3)}'
0040 }
0041
0042 PRLIST() {
0043 echo ""
0044 if ( test -d "$sharedir/doc/clazy/$1" )
0045 then
0046 echo "$2:"
0047 ls -1 $sharedir/doc/clazy/$1/README* | awk -F/ '{printf(" %s\n", $NF)}' | sed s/README-// | sed s/\.md$// | sort
0048 else
0049 echo "There are no checkers available for $1"
0050 fi
0051 }
0052
0053 PRINFO() {
0054 lst=`ls -1 $sharedir/doc/clazy/level*/README*$1* $sharedir/doc/clazy/manuallevel/README*$1* 2>/dev/null`
0055 if ( test ! -z "$lst" )
0056 then
0057 for f in $lst
0058 do
0059 l=`echo $f | awk -F/ '{foo=NF-1; printf(" %s:%s\n", $foo,$NF)}'`
0060 level=`echo $l | cut -d: -f1`
0061 checker=`echo $l | cut -d: -f2 | sed s/README-// | sed s/\.md$//`
0062 echo "== Explanation for checker $checker ($level) =="
0063 cat $f
0064 echo
0065 done
0066 else
0067 echo "There is no explanation available for checker \"$1\""
0068 echo "Run 'clazy --explain' to see the list of all available checkers."
0069 fi
0070 }
0071
0072 if ( test $# -gt 0 -a "$1" = "--help" )
0073 then
0074 HELP
0075 exit
0076 fi
0077
0078 if ( test $# -gt 0 -a "$1" = "--version" )
0079 then
0080 VERSION
0081 exit
0082 fi
0083
0084 if ( test $# -gt 0 -a "$1" = "--list" )
0085 then
0086 echo "List of available clazy checkers:"
0087 PRLIST level0 "Checks from level0. Very stable checks, 100% safe, no false-positives"
0088 PRLIST level1 "Checks from level1. Mostly stable and safe, rare false-positives"
0089 PRLIST level2 "Checks form level2. Sometimes has false-positives (20-30%)"
0090 #PRLIST level3 "Checks from level3. Not always correct, high rate of false-positives"
0091 PRLIST manuallevel "Manual checks. Stability varies. must be explicitly enabled"
0092 exit
0093 fi
0094
0095 if ( test $# -gt 0 -a "$1" = "--explain" )
0096 then
0097 shift
0098 PRINFO $@
0099 exit
0100 fi
0101
0102 ExtraClangOptions=""
0103 if ( test $# -gt 0 -a "$1" = "--qt4compat" )
0104 then
0105 shift
0106 ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang qt4-compat"
0107 fi
0108 if ( test $# -gt 0 -a "$1" = "--qtdeveloper" )
0109 then
0110 shift
0111 ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang qt-developer"
0112 fi
0113 if ( test $# -gt 0 -a "$1" = "--visit-implicit-code" )
0114 then
0115 shift
0116 ExtraClangOptions="-Xclang -plugin-arg-clazy -Xclang visit-implicit-code"
0117 fi
0118
0119 case "$CLAZY_CHECKS" in
0120 *jni-signatures*)
0121 if [ -z "$ANDROID_NDK" ]
0122 then
0123 echo "To test JNI signatures you need to set ANDROID_NDK to your Android NDK installation."
0124 exit
0125 fi
0126
0127 ExtraClangOptions=$ExtraClangOptions" -idirafter"$ANDROID_NDK"/sysroot/usr/include"
0128 ;;
0129 esac
0130
0131 ClazyPluginLib=ClazyPlugin@CMAKE_SHARED_LIBRARY_SUFFIX@
0132
0133 if ( test -f "$libdir/$ClazyPluginLib" )
0134 then
0135 # find plugin libraries in install dir
0136 export LD_LIBRARY_PATH=$libdir:$LD_LIBRARY_PATH
0137 export DYLD_LIBRARY_PATH=$libdir:$DYLD_LIBRARY_PATH
0138 elif ( test -f "$(dirname $0)/lib/$ClazyPluginLib" )
0139 then
0140 # find plugin libraries in build dir
0141 export LD_LIBRARY_PATH=$(dirname $0)/lib:$LD_LIBRARY_PATH
0142 export DYLD_LIBRARY_PATH=$(dirname $0)/lib:$DYLD_LIBRARY_PATH
0143 fi
0144
0145 if ( test $# -gt 0 -a "$1" = "--standalone" )
0146 then
0147 shift
0148 if ( test -f "$(dirname $0)/clazy-standalone" )
0149 then
0150 # find binary in install dir
0151 $(dirname $0)/clazy-standalone "$@"
0152 else
0153 # hope binary is in the expected build dir
0154 $(dirname $0)/bin/clazy-standalone "$@"
0155 fi
0156 else
0157 ${CLANGXX:-clang++} -Qunused-arguments -Xclang -load -Xclang $ClazyPluginLib -Xclang -add-plugin -Xclang clazy $ExtraClangOptions "$@"
0158 fi