starpu_check_undocumented.sh 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. #!/bin/bash
  2. # Note: expects Coccinelle's spatch command n the PATH
  3. # See: http://coccinelle.lip6.fr/
  4. # StarPU --- Runtime system for heterogeneous multicore architectures.
  5. #
  6. # Copyright (C) 2011, 2012, 2013, 2014, 2016 CNRS
  7. # Copyright (C) 2011 INRIA
  8. #
  9. # StarPU is free software; you can redistribute it and/or modify
  10. # it under the terms of the GNU Lesser General Public License as published by
  11. # the Free Software Foundation; either version 2.1 of the License, or (at
  12. # your option) any later version.
  13. #
  14. # StarPU is distributed in the hope that it will be useful, but
  15. # WITHOUT ANY WARRANTY; without even the implied warranty of
  16. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. #
  18. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  19. stcolor=$(tput sgr0)
  20. redcolor=$(tput setaf 1)
  21. greencolor=$(tput setaf 2)
  22. dirname=$(dirname $0)
  23. STARPU_H_FILES=$(find $dirname/../../../include $dirname/../../../mpi/include -name '*.h')
  24. SC_H_FILES=$(find $dirname/../../../sc_hypervisor/include -name '*.h')
  25. SRC="$dirname/../../../src $dirname/../../../mpi/src $dirname/../../../sc_hypervisor/src"
  26. if [ "$1" == "--starpu" ]
  27. then
  28. SC_H_FILES="$0"
  29. shift
  30. else
  31. if [ "$1" == "--sc" ]
  32. then
  33. STARPU_H_FILES="$0"
  34. shift
  35. fi
  36. fi
  37. if [ "$1" == "--func" ] || [ "$1" == "" ] ; then
  38. starpu_functions=$(spatch -very_quiet -sp_file $dirname/starpu_funcs.cocci $STARPU_H_FILES)
  39. sc_functions=$(spatch -very_quiet -sp_file $dirname/sc_funcs.cocci $SC_H_FILES)
  40. for func in $starpu_functions $sc_functions ; do
  41. fname=$(echo $func|awk -F ',' '{print $1}')
  42. location=$(echo $func|awk -F ',' '{print $2}')
  43. x=$(grep "$fname(" $dirname/../chapters/api/*.doxy | grep "\\fn")
  44. if test "$x" == "" ; then
  45. echo "function ${redcolor}${fname}${stcolor} at location ${redcolor}$location${stcolor} is not (or incorrectly) documented"
  46. # else
  47. # echo "function ${greencolor}${fname}${stcolor} at location $location is correctly documented"
  48. fi
  49. done
  50. echo
  51. fi
  52. if [ "$1" == "--struct" ] || [ "$1" == "" ] ; then
  53. starpu_structs=$(grep "struct starpu" $STARPU_H_FILES | grep -v "[;|,|(|)]" | awk '{print $2}')
  54. sc_structs=$(grep "struct sc" $SC_H_FILES | grep -v "[;|,|(|)]" | awk '{print $2}')
  55. for struct in $starpu_structs $sc_structs ; do
  56. x=$(grep -F "\\struct $struct" $dirname/../chapters/api/*.doxy)
  57. if test "$x" == "" ; then
  58. echo "struct ${redcolor}${struct}${stcolor} is not (or incorrectly) documented"
  59. fi
  60. done
  61. echo
  62. fi
  63. if [ "$1" == "--enum" ] || [ "$1" == "" ] ; then
  64. starpu_enums=$(grep "enum starpu" $STARPU_H_FILES | grep -v "[;|,|(|)]" | awk '{print $2}')
  65. sc_enums=$(grep "enum starpu" $SC_H_FILES | grep -v "[;|,|(|)]" | awk '{print $2}')
  66. for enum in $starpu_enums $sc_enums ; do
  67. x=$(grep -F "\\enum $enum" $dirname/../chapters/api/*.doxy)
  68. if test "$x" == "" ; then
  69. echo "enum ${redcolor}${enum}${stcolor} is not (or incorrectly) documented"
  70. fi
  71. done
  72. echo
  73. fi
  74. if [ "$1" == "--macro" ] || [ "$1" == "" ] ; then
  75. macros=$(grep "define\b" $STARPU_H_FILES $SC_H_FILES |grep -v deprecated|grep "#" | grep -v "__" | sed 's/#[ ]*/#/g' | awk '{print $2}' | awk -F'(' '{print $1}' | sort|uniq)
  76. for macro in $macros ; do
  77. x=$(grep -F "\\def $macro" $dirname/../chapters/api/*.doxy)
  78. if test "$x" == "" ; then
  79. echo "macro ${redcolor}${macro}${stcolor} is not (or incorrectly) documented"
  80. fi
  81. done
  82. echo
  83. fi
  84. if [ "$1" == "--var" ] || [ "$1" == "" ] ; then
  85. variables=$(grep --exclude-dir=.svn -rs -E "(getenv|get_env)" $SRC| tr ' ' '\012'|grep -E "(getenv|get_env)" | grep "\"" | sed 's/.*("//' | sed 's/").*//'|tr -d '",'|sort|uniq)
  86. for variable in $variables ; do
  87. x=$(grep "$variable" $dirname/../chapters/501_environment_variables.doxy | grep "\\anchor")
  88. if test "$x" == "" ; then
  89. echo "variable ${redcolor}${variable}${stcolor} is not (or incorrectly) documented"
  90. fi
  91. done
  92. fi