starpu_check_undocumented.sh 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/bin/bash
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2011-2019 CNRS
  5. # Copyright (C) 2011 Inria
  6. #
  7. # StarPU is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU Lesser General Public License as published by
  9. # the Free Software Foundation; either version 2.1 of the License, or (at
  10. # your option) any later version.
  11. #
  12. # StarPU is distributed in the hope that it will be useful, but
  13. # WITHOUT ANY WARRANTY; without even the implied warranty of
  14. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  15. #
  16. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  17. #
  18. stcolor=$(tput sgr0)
  19. redcolor=$(tput setaf 1)
  20. greencolor=$(tput setaf 2)
  21. dirname=$(dirname $0)
  22. STARPU_H_FILES=$(find $dirname/../../../include $dirname/../../../mpi/include -name '*.h')
  23. SC_H_FILES=$(find $dirname/../../../sc_hypervisor/include -name '*.h')
  24. SRC="$dirname/../../../src $dirname/../../../mpi/src $dirname/../../../sc_hypervisor/src"
  25. if [ "$1" == "--starpu" ]
  26. then
  27. SC_H_FILES="$0"
  28. shift
  29. else
  30. if [ "$1" == "--sc" ]
  31. then
  32. STARPU_H_FILES="$0"
  33. shift
  34. fi
  35. fi
  36. ok()
  37. {
  38. type=$1
  39. name=$2
  40. echo "$type ${greencolor}${name}${stcolor} is (maybe correctly) documented"
  41. }
  42. ko()
  43. {
  44. type=$1
  45. name=$2
  46. echo "$type ${redcolor}${name}${stcolor} is not (or incorrectly) documented"
  47. }
  48. if [ "$1" == "--func" ] || [ "$1" == "" ]
  49. then
  50. for f in $STARPU_H_FILES $SC_H_FILES
  51. do
  52. grep "(" $f | grep ';' | grep starpu | grep '^[a-z]' | grep -v typedef | grep -v '(\*' | while read line
  53. do
  54. x=$(grep -F -B1 "$line" $f | head -1)
  55. fname=$(echo $line | awk -F'(' '{print $1}' | awk '{print $NF}' | tr -d '*')
  56. if test "$x" == '*/'
  57. then
  58. ok function $fname
  59. else
  60. #echo $line
  61. ko function $fname
  62. fi
  63. done
  64. done
  65. fi
  66. if [ "$1" == "--struct" ] || [ "$1" == "" ] ; then
  67. starpu=$(grep "^struct starpu_[a-z_]*$" $STARPU_H_FILES | awk '{print $NF}')
  68. sc=$(grep "^struct sc_[a-z_]*$" $SC_H_FILES | awk '{print $NF}')
  69. for o in $starpu $sc ; do
  70. hfile=$(grep -l "^struct ${o}$" $STARPU_H_FILES $SC_H_FILES)
  71. x=$(grep -B1 "^struct ${o}$" $hfile | head -1)
  72. if test "$x" == '*/'
  73. then
  74. ok "struct" ${o}
  75. else
  76. ko "struct" ${o}
  77. fi
  78. done
  79. echo
  80. fi
  81. if [ "$1" == "--enum" ] || [ "$1" == "" ] ; then
  82. starpu=$(grep "^enum starpu_[a-z_]*$" $STARPU_H_FILES | awk '{print $NF}')
  83. sc=$(grep "^enum sc_[a-z_]*$" $SC_H_FILES | awk '{print $NF}')
  84. for o in $starpu $sc ; do
  85. hfile=$(grep -l "^enum ${o}$" $STARPU_H_FILES $SC_H_FILES)
  86. x=$(grep -B1 "^enum ${o}$" $hfile | head -1)
  87. if test "$x" == '*/'
  88. then
  89. ok "enum" ${o}
  90. else
  91. ko "enum" ${o}
  92. fi
  93. done
  94. echo
  95. fi
  96. if [ "$1" == "--macro" ] || [ "$1" == "" ] ; then
  97. 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}' | grep -i starpu | sort|uniq)
  98. for o in $macros ; do
  99. hfile=$(grep -l "define\b ${o}" $STARPU_H_FILES $SC_H_FILES)
  100. x=$(grep -B1 "define\b ${o}" $hfile | head -1)
  101. if test "$x" == '*/'
  102. then
  103. ok "define" ${o}
  104. else
  105. ko "define" ${o}
  106. fi
  107. done
  108. echo
  109. fi
  110. if [ "$1" == "--var" ] || [ "$1" == "" ] ; then
  111. variables=$(grep -rs -E "(getenv|get_env)" $SRC| tr ' ' '\012'|grep -E "(getenv|get_env)" | grep "\"" | sed 's/.*("//' | sed 's/").*//'|tr -d '",'|sort|uniq)
  112. for variable in $variables ; do
  113. x=$(grep "$variable" $dirname/../chapters/501_environment_variables.doxy | grep "\\anchor")
  114. if test "$x" == "" ; then
  115. ko "variable" $variable
  116. else
  117. ok "variable" $variable
  118. fi
  119. done
  120. fi