summaryrefslogtreecommitdiff
path: root/gles_builders.py
diff options
context:
space:
mode:
Diffstat (limited to 'gles_builders.py')
-rw-r--r--gles_builders.py64
1 files changed, 64 insertions, 0 deletions
diff --git a/gles_builders.py b/gles_builders.py
index 6ff2f4248b..85a8d7aa15 100644
--- a/gles_builders.py
+++ b/gles_builders.py
@@ -740,5 +740,69 @@ def build_rd_headers(target, source, env):
build_rd_header(str(x))
+class RAWHeaderStruct:
+ def __init__(self):
+ self.code = ""
+
+
+def include_file_in_raw_header(filename, header_data, depth):
+ fs = open(filename, "r")
+ line = fs.readline()
+ text = ""
+
+ while line:
+
+ while line.find("#include ") != -1:
+ includeline = line.replace("#include ", "").strip()[1:-1]
+
+ import os.path
+
+ included_file = os.path.relpath(os.path.dirname(filename) + "/" + includeline)
+ include_file_in_raw_header(included_file, header_data, depth + 1)
+
+ line = fs.readline()
+
+ header_data.code += line
+ line = fs.readline()
+
+ fs.close()
+
+
+def build_raw_header(filename):
+ header_data = RAWHeaderStruct()
+ include_file_in_raw_header(filename, header_data, 0)
+
+ out_file = filename + ".gen.h"
+ fd = open(out_file, "w")
+
+ enum_constants = []
+
+ fd.write("/* WARNING, THIS FILE WAS GENERATED, DO NOT EDIT */\n")
+
+ out_file_base = out_file.replace(".glsl.gen.h", "_shader_glsl")
+ out_file_base = out_file_base[out_file_base.rfind("/") + 1 :]
+ out_file_base = out_file_base[out_file_base.rfind("\\") + 1 :]
+ out_file_ifdef = out_file_base.replace(".", "_").upper()
+ fd.write("#ifndef " + out_file_ifdef + "_RAW_H\n")
+ fd.write("#define " + out_file_ifdef + "_RAW_H\n")
+ fd.write("\n")
+ fd.write("static const char " + out_file_base + "[] = {\n")
+ for c in header_data.code:
+ fd.write(str(ord(c)) + ",")
+ fd.write("\t\t0};\n\n")
+ fd.write("#endif\n")
+ fd.close()
+
+
+def build_rd_headers(target, source, env):
+ for x in source:
+ build_rd_header(str(x))
+
+
+def build_raw_headers(target, source, env):
+ for x in source:
+ build_raw_header(str(x))
+
+
if __name__ == "__main__":
subprocess_main(globals())