Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | set -e |
| 4 | |
Anthony Barbier | 5a65cfd | 2018-08-10 14:10:08 +0100 | [diff] [blame] | 5 | ALL_DIRECTORIES="./arm_compute ./src ./examples ./tests ./utils ./support" |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 6 | |
Anthony Barbier | 5a65cfd | 2018-08-10 14:10:08 +0100 | [diff] [blame] | 7 | #If no arguments were passed: default to check all the folders: |
| 8 | if [ ! -n "$1" ] |
| 9 | then |
| 10 | FILES=$ALL_DIRECTORIES |
| 11 | else |
| 12 | #else only check the files that were passed on the command line: |
| 13 | FILES=$@ |
| 14 | fi |
| 15 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 16 | grep -HrnP --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "/\*\*$" $FILES | tee bad_style.log |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 17 | if (( `cat bad_style.log | wc -l` > 0 )) |
| 18 | then |
| 19 | echo "" |
| 20 | echo "ERROR: Doxygen comments should start on the first line: \"/** My comment\"" |
| 21 | exit -1 |
| 22 | fi |
| 23 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 24 | grep -Hnr --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv --exclude=Doxyfile "@brief" $FILES | tee bad_style.log |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 25 | if (( `cat bad_style.log | wc -l` > 0 )) |
| 26 | then |
| 27 | echo "" |
| 28 | echo "ERROR: Doxygen comments shouldn't use '@brief'" |
| 29 | exit -1 |
| 30 | fi |
| 31 | |
Giorgio Arena | 232c452 | 2022-03-03 10:09:01 +0000 | [diff] [blame] | 32 | grep -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 Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 33 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 34 | then |
| 35 | echo "" |
| 36 | echo "ERROR: C/C++ don't define 'uint'. Use 'unsigned int' instead." |
| 37 | exit -1 |
| 38 | fi |
| 39 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 40 | grep -HnR --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "/^float32_t/" $FILES | tee bad_style.log |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 41 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 42 | then |
| 43 | echo "" |
| 44 | echo "ERROR: C/C++ don't define 'float32_t'. Use 'float' instead." |
| 45 | exit -1 |
| 46 | fi |
| 47 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 48 | grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "arm[_ ]\?cv" $FILES | tee bad_style.log |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 49 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 50 | then |
| 51 | echo "" |
| 52 | echo "ERROR: Reference to arm_cv detected in the files above (Replace with arm_compute)" |
| 53 | exit -1 |
| 54 | fi |
| 55 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 56 | grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "#.*if.*defined[^(]" $FILES | tee bad_style.log |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 57 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 58 | then |
| 59 | echo "" |
| 60 | echo "ERROR: use parenthesis after #if defined(MY_PREPROCESSOR)" |
| 61 | exit -1 |
| 62 | fi |
| 63 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 64 | grep -Hnir --exclude-dir=assembly --exclude-dir=convolution --exclude-dir=arm_gemm --exclude-dir=arm_conv "#else$\|#endif$" $FILES | tee bad_style.log |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 65 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 66 | then |
| 67 | echo "" |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 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 */ )" |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 69 | exit -1 |
| 70 | fi |
| 71 | |
Michele Di Giorgio | d556d7b | 2020-10-27 10:56:31 +0000 | [diff] [blame] | 72 | grep -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 Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 73 | if [[ $(cat bad_style.log | wc -l) > 0 ]] |
| 74 | then |
| 75 | echo "" |
Ioan-Cristian Szabo | 33fd07b | 2017-10-26 15:42:24 +0100 | [diff] [blame] | 76 | echo "ERROR: Found ARM_COMPUTE_AARCH64_V8_2 in CL tests though armv8.2 features (FP16) are always supported for OpenCL" |
Moritz Pflanzer | 4dfc235 | 2017-08-02 14:51:36 +0100 | [diff] [blame] | 77 | exit -1 |
| 78 | fi |
Anthony Barbier | ac69aa1 | 2017-07-03 17:39:37 +0100 | [diff] [blame] | 79 | |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 80 | spdx_missing=0 |
Anthony Barbier | 5a65cfd | 2018-08-10 14:10:08 +0100 | [diff] [blame] | 81 | for f in $(find $FILES -type f) |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 82 | do |
| 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 Li | 8b4c730 | 2019-09-19 12:18:15 +0100 | [diff] [blame] | 90 | "README.md");; |
Anthony Barbier | 6ff3b19 | 2017-09-04 18:44:23 +0100 | [diff] [blame] | 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; |
| 98 | done |
| 99 | |
| 100 | if [[ $spdx_missing > 0 ]] |
| 101 | then |
| 102 | echo "" |
| 103 | echo "ERROR: MIT Copyright header missing from the file(s) above." |
| 104 | exit -1 |
| 105 | fi |