7 echo "Usage: Lint [FILE=file|ALL] BUILD_PATH=path [-v] [w0|w1|w2|w3|w4] [MISRA=ON|MISRA=OFF]"
9 echo "\"FILE=file|ALL\" Sets the scope of linting"
10 echo -e '\t' "FILE sets the scope to single \"file\""
11 echo -e '\t' "ALL sets the scope to all project modules"
12 echo -e '\t' "If none is set then localy changes files will be linted"
14 echo "\"BUILD_PATH=path\" is the only mandatory parameter which sets"
15 echo -e '\t' "the path to the build product directory"
17 echo "\"-v\" Turns verbose mode on (off by default)"
19 echo "\"w0|w1|w2|w3|w4\" sets the Warning level"
20 echo -e '\t' "w0 - No messages (except for fatal errors)"
21 echo -e '\t' "w1 - Error messages only -- no Warnings or"
22 echo -e '\t' "Informationals."
23 echo -e '\t' "w2 - Error and Warning messages only"
24 echo -e '\t' "w3 - Error, Warning and Informational messages (this"
25 echo -e '\t' "is the default)"
26 echo -e '\t' "w4 - All messages."
28 echo "\"MISRA=ON|MISRA=OFF\" Turns custom MISRA configuration ON"
29 echo -e '\t' "and OFF respectively (OFF by defaul)"
36 echo "=========== Lint SMART DEVICE LINK project ==========="
39 ########################################################################
40 ##### Process input arguments ##########################################
41 ########################################################################
49 if [ $# == 0 ] || [ ${1} == '-h' ] || [ ${1} == '--help' ]; then
54 while test $# -gt 0; do
69 if [ "$SCOPE" != "LOCAL_CHANGES" ]; then
70 echo "Wrong input. It is not allowed to use FILE and ALL at the same time"
82 LHS=$(echo $1 | awk 'BEGIN { FS = "=" } ; { print $1 }')
83 RHS=$(echo $1 | awk 'BEGIN { FS = "=" } ; { print $2 }')
85 if [ ${LHS} == 'FILE' ]; then
86 if [ "$SCOPE" != "LOCAL_CHANGES" ]; then
87 echo "Wrong input. It is not allowed to use FILE and ALL at the same time"
92 if [ "${RHS}" == "" ]; then
93 echo "Wrong input. Provide valid FILE value"
99 elif [ ${LHS} == 'BUILD_PATH' ]; then
100 if [ "${RHS}" == "" ]; then
101 echo "Wrong input. Provide valid BUILD_PATH value"
116 if [ "${BUILD_PATH}" == "" ]; then
117 echo "Mandatory parameter BUILD_PATH is missing"
123 if [ "$SCOPE" == "LOCAL_CHANGES" ]; then
124 echo -e '\t' "Lining scope is limitted to localy changed files"
125 elif [ "$SCOPE" == "FILE" ]; then
126 echo -e '\t' "Lining scope is limitted to file " $FILE_PATH
127 elif [ "$SCOPE" == "ALL" ]; then
129 # echo "You a going to Lint the whole project. It takes a lot of time."
130 # echo -n "Are you sure? [Y/n] "
144 echo -e '\t' "Lining scope is set to all project files"
147 if $MISRA_ENABLED; then
148 echo -e '\t' "MISRA is enabled"
150 echo -e '\t' "MISRA is disabled"
153 case "$WARNING_LEVEL" in
155 echo -e '\t' "Warning is set to " $WARNING_LEVEL " --- No messages (except for fatal errors)"
158 echo -e '\t' "Warning is set to " $WARNING_LEVEL " --- Error messages only -- no Warnings or Informationals."
161 echo -e '\t' "Warning is set to " $WARNING_LEVEL " --- Error and Warning messages only"
164 echo -e '\t' "Warning is set to " $WARNING_LEVEL " --- Error, Warning and Informational messages (this is the default)"
167 echo -e '\t' "Warning is set to " $WARNING_LEVEL " --- All messages."
172 echo -e '\t' "Verbose mode is on"
175 ########################################################################
176 ##### Configuring ######################################################
177 ########################################################################
179 # +e900 Turns on Successful completion, 'Integer' messages produced, which is not by defaulf available in level w0-w3
180 # -e830 Turns off Info 831: Reference cited in prior message
181 # -e830 Turns off Info 830: Location cited in prior message
182 SUPPRESS="-e830 -e831 +e900"
184 OTHER_PARAMS="-dOS_POSIX"
185 MISRA_CONFIGURATION=""
186 SOURCE_CODE_PATH="./src/components/ ./src/appMain/"
187 EXLUDE_FROM_SOURCE_CODE_PATH="./src/components/qt_hmi/ ./src/components/dbus/ ./src/components/transport_manager/src/usb/qnx"
191 echo =====================================
194 rm -Rf ./tools/FlexeLint/tmp
195 rm -Rf ./tools/FlexeLint/results
196 mkdir ./tools/FlexeLint/tmp
197 mkdir ./tools/FlexeLint/results
199 if $MISRA_ENABLED; then
200 MISRA_CONFIGURATION="au-misra-cpp.lnt"
203 if [ "$SCOPE" == "ALL" ]; then
204 EXLUDE_FROM_SOURCE_CODE_PATH=$(echo $EXLUDE_FROM_SOURCE_CODE_PATH | awk '{gsub(/ /,"\\|")}; 1')
205 find $SOURCE_CODE_PATH \( -name "*.cc" -o -name "*.cpp" \) | awk '{print "../../../" $0}' | grep -v "./src/components/qt_hmi/" | grep -v $EXLUDE_FROM_SOURCE_CODE_PATH > ./tools/FlexeLint/tmp/sdl-modules.lnt
206 elif [ "$SCOPE" == "FILE" ]; then
207 echo "$FILE_PATH" | awk '{print "../../../" $0}' > ./tools/FlexeLint/tmp/sdl-modules.lnt
208 elif [ "$SCOPE" == "LOCAL_CHANGES" ]; then
209 (git diff --name-only HEAD ; git ls-files --other --exclude-standard) | grep '.cc\|.cpp' | grep 'src/components\|src/appMain' | awk '{print "../../../" $0}' > ./tools/FlexeLint/tmp/sdl-modules.lnt
210 fi # if [ $CHECKSCOPE == "ALL" ]
212 (cd tools/FlexeLint/config && make -f co-gcc.mak > /dev/null)
214 find ./src/ -type d -name "*include*" | awk '{print "--i../../." $0}' > ./tools/FlexeLint/tmp/sdl-include-path.lnt
216 echo "--i\"/usr/include/gstreamer-1.0\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
217 echo "--i\"/usr/include/glib-2.0\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
218 echo "--i\"/usr/lib/i386-linux-gnu/glib-2.0/include\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
219 echo "--i\"/usr/lib/x86_64-linux-gnu/glib-2.0/include\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
220 echo "--i\"/usr/include/dbus-1.0\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
221 echo "--i\"/usr/include/dbus-1.0\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
222 echo "--i\"/usr/lib/i386-linux-gnu/dbus-1.0/include\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
223 echo "--i\"/usr/lib/x86_64-linux-gnu/dbus-1.0/include\"" >> ./tools/FlexeLint/config/gcc-include-path.lnt
225 ########################################################################
226 ##### Linting ##########################################################
227 ########################################################################
232 echo =====================================
235 cd ./tools/FlexeLint/bin
238 ./${FLINT_BINARY} -$WARNING_LEVEL $SUPPRESS -zero -u --i../../../$BUILD_PATH/src/components/ $OTHER_PARAMS $WORDSIZE ../config/smartdevicelink.lnt | tee ../results/raw_flexelint_report.txt
240 ./${FLINT_BINARY} -$WARNING_LEVEL $SUPPRESS -zero -u --i../../../$BUILD_PATH/src/components/ -os ../results/raw_flexelint_report.txt $OTHER_PARAMS $WORDSIZE ../config/smartdevicelink.lnt
244 ########################################################################
245 ##### Preparing detailed report ########################################
246 ########################################################################
247 if [ "$SCOPE" != "LOCAL_CHANGES" ]; then
249 mkdir ../results/developers
252 echo Preparing detailed report. Be patient
253 echo =====================================
256 ./make_detailed_report
259 echo "Detailed report for each developer won't be generated since"
260 echo "only local changes are present in report"
261 echo =====================================
265 ########################################################################
266 ##### Cleaning-up ######################################################
267 ########################################################################
272 echo =====================================
277 make -f co-gcc.mak clean > /dev/null