No Description

compileshaders.py 897B

12345678910111213141516171819202122232425262728293031
  1. import sys
  2. import os
  3. import glob
  4. import subprocess
  5. if len(sys.argv) < 2:
  6. sys.exit("Please provide a target directory")
  7. if not os.path.exists(sys.argv[1]):
  8. sys.exit("%s is not a valid directory" % sys.argv[1])
  9. path = sys.argv[1]
  10. shaderfiles = []
  11. for exts in ('*.vert', '*.frag', '*.comp', '*.geom', '*.tesc', '*.tese'):
  12. shaderfiles.extend(glob.glob(os.path.join(path, exts)))
  13. failedshaders = []
  14. for shaderfile in shaderfiles:
  15. print("\n-------- %s --------\n" % shaderfile)
  16. if subprocess.call("glslangValidator -V %s -o %s.spv" % (shaderfile, shaderfile), shell=True) != 0:
  17. failedshaders.append(shaderfile)
  18. print("\n-------- Compilation result --------\n")
  19. if len(failedshaders) == 0:
  20. print("SUCCESS: All shaders compiled to SPIR-V")
  21. else:
  22. print("ERROR: %d shader(s) could not be compiled:\n" % len(failedshaders))
  23. for failedshader in failedshaders:
  24. print("\t" + failedshader)