]> git.tdb.fi Git - libs/gl.git/commitdiff
Use mspdatatool to generate the builtin resources file
authorMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2019 17:08:38 +0000 (20:08 +0300)
committerMikko Rasa <tdb@tdb.fi>
Wed, 12 Jun 2019 17:08:38 +0000 (20:08 +0300)
Build
scripts/resgen.py [deleted file]

diff --git a/Build b/Build
index 7a65ca9c7d6af7ae3b39c8a0cfbbfebcf6032625..1a4a262f3a1b6387683a4636af1beb222cae62ee 100644 (file)
--- a/Build
+++ b/Build
@@ -33,7 +33,9 @@ package "mspgl"
        {
                in_suffix ".glsl";
                out_suffix ".cpp";
-               command "scripts/resgen.py";
+               command "mspdatatool";
+               arguments "-i" "-n" "Msp::GL";
+               out_argument "-o";
                processing_unit DIRECTORY;
        };
 
diff --git a/scripts/resgen.py b/scripts/resgen.py
deleted file mode 100755 (executable)
index 110055c..0000000
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python
-
-import sys
-import os
-
-def makename(text):
-       result = ""
-       for c in text:
-               if c.isalnum():
-                       result += c
-               else:
-                       result += '_'
-       return result
-
-def escape_char(c):
-       if c=='\t':
-               return "\\t"
-       elif c=='\n':
-               return "\\n"
-       elif c=='"':
-               return "\\\""
-       else:
-               return c
-
-out = open(sys.argv[-1], "w")
-
-out.write("""#include <msp/datafile/builtinsource.h>
-
-namespace Msp {
-namespace GL {
-
-""")
-
-objects = {}
-for fn in sys.argv[1:-1]:
-       in_base = os.path.split(fn)[1]
-       name = makename(in_base)+"_data"
-       objects[in_base] = name
-       out.write("const char {}[] =\n".format(name))
-       data = open(fn).read()
-       line = ""
-       for c in data:
-               line += escape_char(c)
-               if len(line)>=68:
-                       out.write("\t\"{}\"\n".format(line))
-                       line = ""
-       out.write("\t\"{}\";\n\n".format(line))
-
-out_base = os.path.splitext(os.path.split(sys.argv[-1])[1])[0]
-out.write("void init_{}(DataFile::BuiltinSource &source)\n{{\n".format(makename(out_base)))
-for n, d in objects.items():
-       out.write("\tsource.add_object(\"{}\", {});\n".format(n, d))
-out.write("}\n")
-
-out.write("""
-} // namespace GL
-} // namespace Msp
-""")