blob: 91849266f492eb0b36abb46c39b8638d43e062e1 [file] [log] [blame]
Anthony Barbier6ff3b192017-09-04 18:44:23 +01001#!/bin/bash
2
3set -e
4
Anthony Barbier5a65cfd2018-08-10 14:10:08 +01005ALL_DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support"
Anthony Barbier6ff3b192017-09-04 18:44:23 +01006
Anthony Barbier5a65cfd2018-08-10 14:10:08 +01007#If no arguments were passed: default to check all the folders:
8if [ ! -n "$1" ]
9then
10 FILES=$ALL_DIRECTORIES
11else
12 #else only check the files that were passed on the command line:
13 FILES=$@
14fi
15
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000016grep -HrnP --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "/\*\*$" $FILES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010017if (( `cat bad_style.log | wc -l` > 0 ))
18then
19 echo ""
20 echo "ERROR: Doxygen comments should start on the first line: \"/** My comment\""
21 exit -1
22fi
23
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000024grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv --exclude=Doxyfile "@brief" $FILES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010025if (( `cat bad_style.log | wc -l` > 0 ))
26then
27 echo ""
28 echo "ERROR: Doxygen comments shouldn't use '@brief'"
29 exit -1
30fi
31
Giorgio Arena232c4522022-03-03 10:09:01 +000032grep -HnRE --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=dynamic_fusion --exclude-dir=arm_conv "\buint " --exclude-dir=cl_kernels --exclude-dir=cs_shaders $FILES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010033if [[ $(cat bad_style.log | wc -l) > 0 ]]
34then
35 echo ""
36 echo "ERROR: C/C++ don't define 'uint'. Use 'unsigned int' instead."
37 exit -1
38fi
39
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000040grep -HnR --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "/^float32_t/" $FILES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010041if [[ $(cat bad_style.log | wc -l) > 0 ]]
42then
43 echo ""
44 echo "ERROR: C/C++ don't define 'float32_t'. Use 'float' instead."
45 exit -1
46fi
47
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000048grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "arm[_ ]\?cv" $FILES | tee bad_style.log
Anthony Barbier6ff3b192017-09-04 18:44:23 +010049if [[ $(cat bad_style.log | wc -l) > 0 ]]
50then
51 echo ""
52 echo "ERROR: Reference to arm_cv detected in the files above (Replace with arm_compute)"
53 exit -1
54fi
55
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000056grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "#.*if.*defined[^(]" $FILES | tee bad_style.log
Anthony Barbierac69aa12017-07-03 17:39:37 +010057if [[ $(cat bad_style.log | wc -l) > 0 ]]
58then
59 echo ""
60 echo "ERROR: use parenthesis after #if defined(MY_PREPROCESSOR)"
61 exit -1
62fi
63
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000064grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "#else$\|#endif$" $FILES | tee bad_style.log
Anthony Barbierac69aa12017-07-03 17:39:37 +010065if [[ $(cat bad_style.log | wc -l) > 0 ]]
66then
67 echo ""
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010068 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 +010069 exit -1
70fi
71
Michele Di Giorgiod556d7b2020-10-27 10:56:31 +000072grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "ARM_COMPUTE_AARCH64_V8_2" ./tests/validation/CL | tee bad_style.log
Moritz Pflanzer4dfc2352017-08-02 14:51:36 +010073if [[ $(cat bad_style.log | wc -l) > 0 ]]
74then
75 echo ""
Ioan-Cristian Szabo33fd07b2017-10-26 15:42:24 +010076 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 +010077 exit -1
78fi
Anthony Barbierac69aa12017-07-03 17:39:37 +010079
Anthony Barbier6ff3b192017-09-04 18:44:23 +010080spdx_missing=0
Anthony Barbier5a65cfd2018-08-10 14:10:08 +010081for f in $(find $FILES -type f)
Anthony Barbier6ff3b192017-09-04 18:44:23 +010082do
83 if [[ $(grep SPDX $f | wc -l) == 0 ]]
84 then
85 # List of exceptions:
86 case `basename $f` in
87 "arm_compute_version.embed");;
88 ".clang-format");;
89 ".clang-tidy");;
SiCong Li8b4c7302019-09-19 12:18:15 +010090 "README.md");;
Anthony Barbier6ff3b192017-09-04 18:44:23 +010091 #It's an error for other files to not contain the MIT header:
92 *)
93 spdx_missing=1
94 echo $f;
95 ;;
96 esac
97 fi;
98done
99
100if [[ $spdx_missing > 0 ]]
101then
102 echo ""
103 echo "ERROR: MIT Copyright header missing from the file(s) above."
104 exit -1
105fi