conjure-engine/Demo1/CompileShaders.py

43 lines
1.2 KiB
Python

import os
import sys
import subprocess
import logging
os.chdir(sys.argv[1])
# Configure logging
logging.basicConfig(
filename=os.path.join("D:/Dev/ETS/CONJURE/conjure-engine/Demo1", "CompileShaders.log"), # Log file name
filemode="w", # Append mode (use "w" for overwrite)
format="%(asctime)s - %(levelname)s - %(message)s", # Log format
level=logging.INFO # Logging level
)
SHADERS_PATH = os.path.join(os.getcwd())
GLSLC_PATH = os.path.join(os.environ.get("VULKAN_SDK"), "bin", "glslc")
def filterFunc(fileName):
logging.info(fileName)
name, ext = fileName.split(".")
return ext != "spv"
def __main__():
logging.info("SHADER PATH: " + SHADERS_PATH)
logging.info("GLSLC PATH:" + GLSLC_PATH)
shaders = filter(filterFunc, os.listdir(SHADERS_PATH))
for shader in shaders:
name, ext = shader.split(".")
command = GLSLC_PATH
args = [
os.path.join(SHADERS_PATH, shader),
"-o",
os.path.join(SHADERS_PATH, name + "." + ext + ".spv")
]
logging.info(command + " " + str.join(" ", args))
subprocess.run(command + " " + str.join(" ", args))
if __name__ == "__main__":
__main__()