cmake_static_check_clang_array.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/usr/bin/env python3
  2. # ***** BEGIN GPL LICENSE BLOCK *****
  3. #
  4. # This program is free software; you can redistribute it and/or
  5. # modify it under the terms of the GNU General Public License
  6. # as published by the Free Software Foundation; either version 2
  7. # of the License, or (at your option) any later version.
  8. #
  9. # This program is distributed in the hope that it will be useful,
  10. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. # GNU General Public License for more details.
  13. #
  14. # You should have received a copy of the GNU General Public License
  15. # along with this program; if not, write to the Free Software Foundation,
  16. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  17. #
  18. # ***** END GPL LICENSE BLOCK *****
  19. # <pep8 compliant>
  20. import project_source_info
  21. import subprocess
  22. import sys
  23. import os
  24. USE_QUIET = (os.environ.get("QUIET", None) is not None)
  25. CHECKER_IGNORE_PREFIX = [
  26. "extern",
  27. "intern/moto",
  28. ]
  29. CHECKER_BIN = "python2"
  30. CHECKER_ARGS = [
  31. os.path.join(os.path.dirname(__file__), "clang_array_check.py"),
  32. # not sure why this is needed, but it is.
  33. "-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
  34. # stupid but needed
  35. "-Dbool=char"
  36. ]
  37. def main():
  38. source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
  39. check_commands = []
  40. for c, inc_dirs, defs in source_info:
  41. #~if "source/blender" not in c:
  42. #~ continue
  43. cmd = ([CHECKER_BIN] +
  44. CHECKER_ARGS +
  45. [c] +
  46. [("-I%s" % i) for i in inc_dirs] +
  47. [("-D%s" % d) for d in defs]
  48. )
  49. check_commands.append((c, cmd))
  50. process_functions = []
  51. def my_process(i, c, cmd):
  52. if not USE_QUIET:
  53. percent = 100.0 * (i / (len(check_commands) - 1))
  54. percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
  55. sys.stdout.flush()
  56. sys.stdout.write("%s %s\n" % (percent_str, c))
  57. return subprocess.Popen(cmd)
  58. for i, (c, cmd) in enumerate(check_commands):
  59. process_functions.append((my_process, (i, c, cmd)))
  60. project_source_info.queue_processes(process_functions)
  61. if __name__ == "__main__":
  62. main()