cmake_static_check_clang_array.py 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  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. # Contributor(s): Campbell Barton
  19. #
  20. # ***** END GPL LICENSE BLOCK *****
  21. # <pep8 compliant>
  22. import project_source_info
  23. import subprocess
  24. import sys
  25. import os
  26. USE_QUIET = (os.environ.get("QUIET", None) is not None)
  27. CHECKER_IGNORE_PREFIX = [
  28. "extern",
  29. "intern/moto",
  30. ]
  31. CHECKER_BIN = "python2"
  32. CHECKER_ARGS = [
  33. os.path.join(os.path.dirname(__file__), "clang_array_check.py"),
  34. # not sure why this is needed, but it is.
  35. "-I" + os.path.join(project_source_info.SOURCE_DIR, "extern", "glew", "include"),
  36. # stupid but needed
  37. "-Dbool=char"
  38. ]
  39. def main():
  40. source_info = project_source_info.build_info(ignore_prefix_list=CHECKER_IGNORE_PREFIX)
  41. check_commands = []
  42. for c, inc_dirs, defs in source_info:
  43. #~if "source/blender" not in c:
  44. #~ continue
  45. cmd = ([CHECKER_BIN] +
  46. CHECKER_ARGS +
  47. [c] +
  48. [("-I%s" % i) for i in inc_dirs] +
  49. [("-D%s" % d) for d in defs]
  50. )
  51. check_commands.append((c, cmd))
  52. process_functions = []
  53. def my_process(i, c, cmd):
  54. if not USE_QUIET:
  55. percent = 100.0 * (i / (len(check_commands) - 1))
  56. percent_str = "[" + ("%.2f]" % percent).rjust(7) + " %:"
  57. sys.stdout.flush()
  58. sys.stdout.write("%s %s\n" % (percent_str, c))
  59. return subprocess.Popen(cmd)
  60. for i, (c, cmd) in enumerate(check_commands):
  61. process_functions.append((my_process, (i, c, cmd)))
  62. project_source_info.queue_processes(process_functions)
  63. if __name__ == "__main__":
  64. main()