starpu_check_documented.py 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python3
  2. # StarPU --- Runtime system for heterogeneous multicore architectures.
  3. #
  4. # Copyright (C) 2013,2014,2016,2017 CNRS
  5. #
  6. # StarPU is free software; you can redistribute it and/or modify
  7. # it under the terms of the GNU Lesser General Public License as published by
  8. # the Free Software Foundation; either version 2.1 of the License, or (at
  9. # your option) any later version.
  10. #
  11. # StarPU is distributed in the hope that it will be useful, but
  12. # WITHOUT ANY WARRANTY; without even the implied warranty of
  13. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  14. #
  15. # See the GNU Lesser General Public License in COPYING.LGPL for more details.
  16. #
  17. import os
  18. import sys
  19. class bcolors:
  20. FAILURE = '\033[91m'
  21. NORMAL = '\033[0m'
  22. def list_files(directory):
  23. return list(map(lambda a : directory+a, list(filter(lambda a:a.count(".h") and not a.count("starpu_deprecated_api.h"),os.listdir(directory)))))
  24. def loadFunctionsAndDatatypes(flist, dtlist, file_name):
  25. f = open(file_name, 'r')
  26. for line in f:
  27. mline = line[:-1]
  28. if mline.count("\\fn"):
  29. if mline.count("fft") == 0:
  30. func = mline.replace("\\fn ", "")
  31. l = func.split("(")[0].split()
  32. func_name = l[len(l)-1].replace("*", "")
  33. flist.append(list([func, func_name, file_name]))
  34. if mline.count("\\struct ") or mline.count("\\def ") or mline.count("\\typedef ") or mline.count("\\enum "):
  35. datatype = mline.replace("\\struct ", "").replace("\\def ", "").replace("\\typedef ", "").replace("\\enum ","")
  36. l = datatype.split("(")
  37. if len(l) > 1:
  38. datatype_name = l[0]
  39. else:
  40. datatype_name = datatype
  41. dtlist.append(list([datatype, datatype_name, file_name]))
  42. f.close()
  43. functions = []
  44. datatypes = []
  45. dirname=os.path.dirname(sys.argv[0])
  46. docfile_dir=dirname+"/../chapters/api/"
  47. for docfile in os.listdir(docfile_dir):
  48. if docfile.count(".doxy"):
  49. loadFunctionsAndDatatypes(functions, datatypes, docfile_dir+docfile)
  50. list_incfiles = [dirname + "/../../../include/starpu_config.h.in"]
  51. for d in [dirname+"/../../../include/", dirname + "/../../../mpi/include/", dirname + "/../../../starpufft/include/", dirname + "/../../../sc_hypervisor/include/"]:
  52. list_incfiles.extend(list_files(d))
  53. incfiles=" ".join(list_incfiles)
  54. for function in functions:
  55. x = os.system("sed 's/ *STARPU_ATTRIBUTE_UNUSED *//g' " + incfiles + "| sed 's/ STARPU_WARN_UNUSED_RESULT//g' | fgrep \"" + function[0] + "\" > /dev/null")
  56. if x != 0:
  57. print("Function <" + bcolors.FAILURE + function[0] + bcolors.NORMAL + "> documented in <" + function[2] + "> does not exist in StarPU's API")
  58. os.system("grep " + function[1] + " " + dirname+"/../../../include/starpu_deprecated_api.h")
  59. for datatype in datatypes:
  60. x = os.system("fgrep -l \"" + datatype[0] + "\" " + incfiles + " > /dev/null")
  61. if x != 0:
  62. print("Datatype <" + bcolors.FAILURE + datatype[0] + bcolors.NORMAL + "> documented in <" + datatype[2] + "> does not exist in StarPU's API")
  63. os.system("grep " + datatype[1] + " " + dirname+"/../../../include/starpu_deprecated_api.h")