33 lines
No EOL
1.2 KiB
Python
Executable file
33 lines
No EOL
1.2 KiB
Python
Executable file
#!/usr/bin/python3
|
|
import os
|
|
import os.path as path
|
|
import sys
|
|
from glob import glob
|
|
import json
|
|
olddir = os.curdir
|
|
scriptdir = path.realpath(path.dirname(__file__))
|
|
os.chdir(scriptdir)
|
|
outpath = path.join(scriptdir, "backend_glue.cpp")
|
|
ui_backend_dir = path.join(scriptdir, "backends", "ui")
|
|
ui_backend_metafiles = []
|
|
for backend in sys.argv[1:]:
|
|
ui_backend_metafiles += [ui_backend_dir + "/" + backend + "/ui.json"]
|
|
ui_backends = []
|
|
for metafile_path in ui_backend_metafiles:
|
|
with open(metafile_path, "rt") as metafile:
|
|
metajson = json.load(metafile)
|
|
incpath = path.join(path.dirname(metafile_path), metajson["include_path"])
|
|
incpath = path.relpath(incpath, scriptdir)
|
|
ui_backend = {"class_name": metajson["class_name"], "include_path": incpath}
|
|
ui_backends.append(ui_backend)
|
|
with open(outpath, "wt+") as of:
|
|
of.write("#include \"backend.hpp\"\n")
|
|
for ui_backend in ui_backends:
|
|
of.write("#include \"%s\"\n" % ui_backend["include_path"])
|
|
of.write("""
|
|
void init_backends() {
|
|
""")
|
|
for ui_backend in ui_backends:
|
|
of.write("\tUIBackend::register_backend<%s>();\n" % ui_backend["class_name"])
|
|
of.write("}\n")
|
|
os.chdir(olddir) |