blob: e5dc15c218a2bd971ec027ea04ba7ce1e64baacc [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001#!/bin/bash
2
3set -e
4
Moritz Pflanzera09de0c2017-09-01 20:41:12 +01005DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support"
Anthony Barbier6ff3b192017-09-04 18:44:23 +01006
Georgios Pinitas4074c992018-01-30 18:13:46 +00007grep -HrnP --exclude-dir=assembly --exclude-dir=convolution "/\*\*$" $DIRECTORIES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +01008if (( `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
Georgios Pinitas4074c992018-01-30 18:13:46 +000015grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude=Doxyfile "@brief" $DIRECTORIES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010016if (( `cat bad_style.log | wc -l` > 0 ))
17then
18 echo ""
19 echo "ERROR: Doxygen comments shouldn't use '@brief'"
20 exit -1
21fi
22
Georgios Pinitas4074c992018-01-30 18:13:46 +000023grep -HnRE --exclude-dir=assembly --exclude-dir=convolution "\buint " --exclude-dir=cl_kernels --exclude-dir=cs_shaders $DIRECTORIES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010024if [[ $(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
Georgios Pinitas4074c992018-01-30 18:13:46 +000031grep -HnR --exclude-dir=assembly --exclude-dir=convolution "float32_t" $DIRECTORIES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010032if [[ $(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
Georgios Pinitas4074c992018-01-30 18:13:46 +000039grep -Hnir --exclude-dir=assembly --exclude-dir=convolution "arm[_ ]\?cv" $DIRECTORIES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010040if [[ $(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
Georgios Pinitas4074c992018-01-30 18:13:46 +000047grep -Hnir --exclude-dir=assembly --exclude-dir=convolution "#.*if.*defined[^(]" $DIRECTORIES | tee bad_style.log
Anthony Barbierac69aa12017-07-03 17:39:37 +010048if [[ $(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
Georgios Pinitas4074c992018-01-30 18:13:46 +000055grep -Hnir --exclude-dir=assembly --exclude-dir=convolution "#else$\|#endif$" $DIRECTORIES | tee bad_style.log
Anthony Barbierac69aa12017-07-03 17:39:37 +010056if [[ $(cat bad_style.log | wc -l) > 0 ]]
57then
58 echo ""
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010059 echo "ERROR: #else and #endif should be followed by a comment of the guard they refer to (e.g /* ARM_COMPUTE_AARCH64_V8_2 */ )"
Anthony Barbierac69aa12017-07-03 17:39:37 +010060 exit -1
61fi
62
Georgios Pinitas4074c992018-01-30 18:13:46 +000063grep -Hnir --exclude-dir=assembly --exclude-dir=convolution "ARM_COMPUTE_AARCH64_V8_2" ./tests/validation/CL | tee bad_style.log
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010064if [[ $(cat bad_style.log | wc -l) > 0 ]]
65then
66 echo ""
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010067 echo "ERROR: Found ARM_COMPUTE_AARCH64_V8_2 in CL tests though armv8.2 features (FP16) are always supported for OpenCL"
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010068 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