-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompileAll.py
More file actions
32 lines (28 loc) · 1.42 KB
/
CompileAll.py
File metadata and controls
32 lines (28 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import sys, os, subprocess, math
IN_DIR = "./source/"
OUT_DIR = "./compiled/"
files = os.listdir(IN_DIR)
compiled_shaders = 0
total_shaders = 0
for i in range(len(files)):
file = files[i]
percent_complete = int(math.floor(i / len(files) * 100))
if file.endswith(".hlsl"):
total_shaders += 1
vsh_file = OUT_DIR + file.replace(".hlsl", ".vsh")
psh_file = OUT_DIR + file .replace(".hlsl", ".psh")
compiler = "fxc-xbox-8276"
vertex_result = subprocess.run(compiler + " /XOautoz /Tvs_3_0 /Evs_main /Fo" + vsh_file + " " + IN_DIR + file, shell=True, capture_output=True)
pixel_result = subprocess.run(compiler + " /Tps_3_0 /Eps_main /Fo" + psh_file + " " + IN_DIR + file, shell=True, capture_output=True)
if vertex_result.returncode != 0 and pixel_result.returncode != 0:
print("Failed to compile shader: " + file)
elif vertex_result.returncode == 0 and pixel_result.returncode == 0:
print("Successfully compiled shader: " + file + " (" + str(percent_complete) + "%)")
compiled_shaders += 1
else:
if vertex_result.returncode != 0:
print("Failed to compile vertex shader: " + file)
if pixel_result.returncode != 0:
print("Failed to compile pixel shader: " + file)
if total_shaders == compiled_shaders:
print("Compiled all shaders! ^w^")