blob: acc496b00afe8f82815ba849715419cadea26d6e [file] [log] [blame]
Jenkins6a7771e2020-05-28 11:28:36 +01001#!/bin/bash
2
3set -e
4
5ALL_DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support"
6
7#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
16grep -HrnP --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "/\*\*$" $FILES | tee bad_style.log
17if (( `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
24grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude=Doxyfile "@brief" $FILES | tee bad_style.log
25if (( `cat bad_style.log | wc -l` > 0 ))
26then
27 echo ""
28 echo "ERROR: Doxygen comments shouldn't use '@brief'"
29 exit -1
30fi
31
32grep -HnRE --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "\buint " --exclude-dir=cl_kernels --exclude-dir=cs_shaders $FILES | tee bad_style.log
33if [[ $(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
40grep -HnR --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "float32_t" $FILES | tee bad_style.log
41if [[ $(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
48grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "arm[_ ]\?cv" $FILES | tee bad_style.log
49if [[ $(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
56grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "#.*if.*defined[^(]" $FILES | tee bad_style.log
57if [[ $(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
64grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "#else$\|#endif$" $FILES | tee bad_style.log
65if [[ $(cat bad_style.log | wc -l) > 0 ]]
66then
67 echo ""
68 echo "ERROR: #else and #endif should be followed by a comment of the guard they refer to (e.g /* ARM_COMPUTE_AARCH64_V8_2 */ )"
69 exit -1
70fi
71
72grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm "ARM_COMPUTE_AARCH64_V8_2" ./tests/validation/CL | tee bad_style.log
73if [[ $(cat bad_style.log | wc -l) > 0 ]]
74then
75 echo ""
76 echo "ERROR: Found ARM_COMPUTE_AARCH64_V8_2 in CL tests though armv8.2 features (FP16) are always supported for OpenCL"
77 exit -1
78fi
79
80spdx_missing=0
81for f in $(find $FILES -type f)
82do
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");;
90 "README.md");;
91 #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