starpu_check_documented.py 3.2 KB

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