diff options
Diffstat (limited to 'editor/SCsub')
| -rw-r--r-- | editor/SCsub | 114 |
1 files changed, 85 insertions, 29 deletions
diff --git a/editor/SCsub b/editor/SCsub index 172447147c..2b6494608b 100644 --- a/editor/SCsub +++ b/editor/SCsub @@ -4,7 +4,7 @@ Import('env') env.editor_sources = [] import os -from compat import encode_utf8, byte_to_str, open_utf8 +from compat import encode_utf8, byte_to_str, open_utf8, escape_string def make_certs_header(target, source, env): @@ -41,11 +41,8 @@ def make_doc_header(target, source, env): src = s.srcnode().abspath f = open_utf8(src, "r") content = f.read() - buf += content[content.find("<class"): content.rfind("</doc>")] - if len(docbegin) == 0: - docbegin = content[0: content.find("<class")] - if len(docend) == 0: - docend = content[content.rfind("</doc>"): len(buf)] + buf+=content + buf = encode_utf8(docbegin + buf + docend) decomp_size = len(buf) import zlib @@ -60,6 +57,7 @@ def make_doc_header(target, source, env): for i in range(len(buf)): g.write(byte_to_str(buf[i]) + ",\n") g.write("};\n") + g.write("#endif") @@ -155,31 +153,71 @@ def make_authors_header(target, source, env): g.write("#define _EDITOR_AUTHORS_H\n") current_section = "" - name_count = -1 + reading = False + + def close_section(): + g.write("\t0\n") + g.write("};\n") + + for line in f: + if reading: + if line.startswith(" "): + g.write("\t\"" + escape_string(line.strip()) + "\",\n") + continue + if line.startswith("## "): + if reading: + close_section() + reading = False + for i in range(len(sections)): + if line.strip().endswith(sections[i]): + current_section = escape_string(sections_id[i]) + reading = True + g.write("static const char *" + current_section + "[] = {\n") + break + + if reading: + close_section() + + g.write("#endif\n") + +def make_donors_header(target, source, env): + + sections = ["Platinum sponsors", "Gold sponsors", "Mini sponsors", "Gold donors", "Silver donors", "Bronze donors"] + sections_id = ["donor_s_plat", "donor_s_gold", "donor_s_mini", "donor_gold", "donor_silver", "donor_bronze"] + + src = source[0].srcnode().abspath + dst = target[0].srcnode().abspath + f = open_utf8(src, "r") + g = open_utf8(dst, "w") + + g.write("/* THIS FILE IS GENERATED DO NOT EDIT */\n") + g.write("#ifndef _EDITOR_DONORS_H\n") + g.write("#define _EDITOR_DONORS_H\n") + + current_section = "" + reading = False def close_section(): g.write("\t0\n") g.write("};\n") - g.write("#define " + current_section.upper() + "_COUNT " + str(name_count) + "\n") for line in f: - if name_count >= 0: + if reading >= 0: if line.startswith(" "): - g.write("\t\"" + line.strip() + "\",\n") - name_count += 1 + g.write("\t\"" + escape_string(line.strip()) + "\",\n") continue if line.startswith("## "): - if name_count >= 0: + if reading: close_section() - name_count = -1 + reading = False for i in range(len(sections)): if line.strip().endswith(sections[i]): - current_section = sections_id[i] - name_count = 0 + current_section = escape_string(sections_id[i]) + reading = True g.write("static const char *" + current_section + "[] = {\n") break - if name_count >= 0: + if reading: close_section() g.write("#endif\n") @@ -199,7 +237,8 @@ def make_license_header(target, source, env): g.write("static const char *about_license =") for line in f: - g.write("\n\t\"" + line.strip().replace("\"", "\\\"") + "\\n\"") + escaped_string = escape_string(line.strip()) + g.write("\n\t\"" + escaped_string + "\\n\"") g.write(";\n") @@ -284,11 +323,13 @@ def make_license_header(target, source, env): for k in j[0].split("\n"): if file_body != "": file_body += "\\n\"\n" - file_body += "\t\"" + k.strip().replace("\"", "\\\"") + escaped_string = escape_string(k.strip()) + file_body += "\t\"" + escaped_string for k in j[1].split("\n"): if copyright_body != "": copyright_body += "\\n\"\n" - copyright_body += "\t\"" + k.strip().replace("\"", "\\\"") + escaped_string = escape_string(k.strip()) + copyright_body += "\t\"" + escaped_string about_tp_file += "\t" + file_body + "\",\n" about_tp_copyright += "\t" + copyright_body + "\",\n" @@ -302,7 +343,8 @@ def make_license_header(target, source, env): for j in i[1].split("\n"): if body != "": body += "\\n\"\n" - body += "\t\"" + j.strip().replace("\"", "\\\"") + escaped_string = escape_string(j.strip()) + body += "\t\"" + escaped_string about_license_name += "\t\"" + i[0] + "\",\n" about_license_body += "\t" + body + "\",\n" @@ -345,8 +387,20 @@ def make_license_header(target, source, env): g.write("#endif\n") -if (env["tools"] == "yes"): +def _make_doc_data_class_path(to_path): + g = open_utf8(os.path.join(to_path,"doc_data_class_path.gen.h"), "w") + g.write("static const int _doc_data_class_path_count="+str(len(env.doc_class_path))+";\n") + g.write("struct _DocDataClassPath { const char* name; const char* path; };\n") + + g.write("static const _DocDataClassPath _doc_data_class_paths["+str(len(env.doc_class_path)+1)+"]={\n"); + for c in env.doc_class_path: + g.write("{\""+c+"\",\""+env.doc_class_path[c]+"\"},\n") + g.write("{NULL,NULL}\n") + g.write("};\n") + + +if env['tools']: # Register exporters reg_exporters_inc = '#include "register_exporters.h"\n' reg_exporters = 'void register_exporters() {\n' @@ -361,16 +415,14 @@ if (env["tools"] == "yes"): f.close() # API documentation - docs = ["#doc/base/classes.xml"] - moduledir = os.path.join(os.getcwd(), "..", "modules") - for m in os.listdir(moduledir): - curmodle = os.path.join(moduledir, m) - docfile = os.path.join(curmodle, "classes.xml") - if os.path.isdir(curmodle) and os.path.isfile(docfile): - docs.append(docfile) + docs = [] + for f in os.listdir(os.path.join(env.Dir('#').abspath, "doc/classes")): + docs.append("#doc/classes/" + f) + + _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc")) + env.Depends("#editor/doc_data_compressed.gen.h", docs) env.Command("#editor/doc_data_compressed.gen.h", docs, make_doc_header) - # Certificates env.Depends("#editor/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt") env.Command("#editor/certs_compressed.gen.h", "#thirdparty/certs/ca-certificates.crt", make_certs_header) @@ -393,6 +445,10 @@ if (env["tools"] == "yes"): env.Depends('#editor/authors.gen.h', "../AUTHORS.md") env.Command('#editor/authors.gen.h', "../AUTHORS.md", make_authors_header) + # Donors + env.Depends('#editor/donors.gen.h', "../DONORS.md") + env.Command('#editor/donors.gen.h', "../DONORS.md", make_donors_header) + # License env.Depends('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"]) env.Command('#editor/license.gen.h', ["../COPYRIGHT.txt", "../LICENSE.txt"], make_license_header) |