blob: 0f0b657521bb526fdd1b87781d6ffd5e8b81940a [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001#!/bin/bash
2
3set -e
4
Moritz Pflanzerfc95ed22017-07-05 11:07:07 +01005DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./framework ./support"
Anthony Barbier6ff3b192017-09-04 18:44:23 +01006
7grep -HrnP "/\*\*$" $DIRECTORIES | tee bad_style.log
8if (( `cat bad_style.log | wc -l` > 0 ))
9then
10 echo ""
11 echo "ERROR: Doxygen comments should start on the first line: \"/** My comment\""
12 exit -1
13fi
14
15grep -Hnr --exclude=Doxyfile "@brief" $DIRECTORIES | tee bad_style.log
16if (( `cat bad_style.log | wc -l` > 0 ))
17then
18 echo ""
19 echo "ERROR: Doxygen comments shouldn't use '@brief'"
20 exit -1
21fi
22
23grep -HnRE "\buint " --exclude-dir=cl_kernels $DIRECTORIES | tee bad_style.log
24if [[ $(cat bad_style.log | wc -l) > 0 ]]
25then
26 echo ""
27 echo "ERROR: C/C++ don't define 'uint'. Use 'unsigned int' instead."
28 exit -1
29fi
30
31grep -HnR "float32_t" $DIRECTORIES | tee bad_style.log
32if [[ $(cat bad_style.log | wc -l) > 0 ]]
33then
34 echo ""
35 echo "ERROR: C/C++ don't define 'float32_t'. Use 'float' instead."
36 exit -1
37fi
38
39grep -Hnir "arm[_ ]\?cv" $DIRECTORIES | tee bad_style.log
40if [[ $(cat bad_style.log | wc -l) > 0 ]]
41then
42 echo ""
43 echo "ERROR: Reference to arm_cv detected in the files above (Replace with arm_compute)"
44 exit -1
45fi
46
Anthony Barbierac69aa12017-07-03 17:39:37 +010047grep -Hnir "#.*defined[^(]" $DIRECTORIES | tee bad_style.log
48if [[ $(cat bad_style.log | wc -l) > 0 ]]
49then
50 echo ""
51 echo "ERROR: use parenthesis after #if defined(MY_PREPROCESSOR)"
52 exit -1
53fi
54
55grep -Hnir "#else$\|#endif$" $DIRECTORIES | tee bad_style.log
56if [[ $(cat bad_style.log | wc -l) > 0 ]]
57then
58 echo ""
59 echo "ERROR: #else and #endif should be followed by a comment of the guard they refer to (e.g /* ARM_COMPUTE_ENABLE_FP16 */ )"
60 exit -1
61fi
62
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010063grep -Hnir "ARM_COMPUTE_ENABLE_FP16" ./tests/validation_new/CL | tee bad_style.log
64if [[ $(cat bad_style.log | wc -l) > 0 ]]
65then
66 echo ""
67 echo "ERROR: Found ARM_COMPUTE_ENABLE_FP16 in CL tests though F16 is always supported for OpenCL"
68 exit -1
69fi
Anthony Barbierac69aa12017-07-03 17:39:37 +010070
Anthony Barbier6ff3b192017-09-04 18:44:23 +010071spdx_missing=0
72for f in $(find $DIRECTORIES -type f)
73do
74 if [[ $(grep SPDX $f | wc -l) == 0 ]]
75 then
76 # List of exceptions:
77 case `basename $f` in
78 "arm_compute_version.embed");;
79 ".clang-format");;
80 ".clang-tidy");;
81 #It's an error for other files to not contain the MIT header:
82 *)
83 spdx_missing=1
84 echo $f;
85 ;;
86 esac
87 fi;
88done
89
90if [[ $spdx_missing > 0 ]]
91then
92 echo ""
93 echo "ERROR: MIT Copyright header missing from the file(s) above."
94 exit -1
95fi