SCsub 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. #!/usr/bin/env python
  2. Import("env")
  3. env.editor_sources = []
  4. import os
  5. import glob
  6. from platform_methods import run_in_subprocess
  7. from compat import open_utf8
  8. import editor_builders
  9. def _make_doc_data_class_path(to_path):
  10. # NOTE: It is safe to generate this file here, since this is still executed serially
  11. g = open_utf8(os.path.join(to_path, "doc_data_class_path.gen.h"), "w")
  12. g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
  13. g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
  14. g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n")
  15. for c in sorted(env.doc_class_path):
  16. g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n')
  17. g.write("\t{NULL, NULL}\n")
  18. g.write("};\n")
  19. g.close()
  20. if env["tools"]:
  21. # Register exporters
  22. reg_exporters_inc = '#include "register_exporters.h"\n'
  23. reg_exporters = "void register_exporters() {\n"
  24. for e in env.platform_exporters:
  25. # Glob all .cpp files in export folder
  26. if not env["scu_build"]:
  27. files = Glob("#platform/" + e + "/export/" + "*.cpp")
  28. env.add_source_files(env.editor_sources, files)
  29. reg_exporters += "\tregister_" + e + "_exporter();\n"
  30. reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
  31. reg_exporters += "}\n"
  32. # If we are in a SCU build, we add all the platform exporters in one SCU file.
  33. if env["scu_build"]:
  34. env.add_source_files(env.editor_sources, "../platform/*.cpp")
  35. # NOTE: It is safe to generate this file here, since this is still executed serially
  36. with open_utf8("register_exporters.gen.cpp", "w") as f:
  37. f.write(reg_exporters_inc)
  38. f.write(reg_exporters)
  39. # Core API documentation.
  40. docs = []
  41. docs += Glob("#doc/classes/*.xml")
  42. # Module API documentation.
  43. module_dirs = []
  44. for d in env.doc_class_path.values():
  45. if d not in module_dirs:
  46. module_dirs.append(d)
  47. for d in module_dirs:
  48. if not os.path.isabs(d):
  49. docs += Glob("#" + d + "/*.xml") # Built-in.
  50. else:
  51. docs += Glob(d + "/*.xml") # Custom.
  52. _make_doc_data_class_path(env.Dir("#editor/doc").abspath)
  53. docs = sorted(docs)
  54. env.Depends("#editor/doc_data_compressed.gen.h", docs)
  55. env.CommandNoCache("#editor/doc_data_compressed.gen.h", docs, run_in_subprocess(editor_builders.make_doc_header))
  56. # Editor interface and class reference translations incur a significant size
  57. # cost for the editor binary (see godot-proposals#3421).
  58. # To limit it, we only include translations with a high enough completion
  59. # ratio (20% for the editor UI, 10% for the class reference).
  60. # Generated with `make include-list` for each resource.
  61. # Note: In 3.x, we also exclude languages that depend on complex text
  62. # layouts to be displayed properly: ar,bn,fa,he,hi,ml,si,ta,te,ur.
  63. # Editor translations
  64. to_include = (
  65. "bg,ca,cs,de,el,eo,es_AR,es,fi,fr,gl,hu,id,it,ja,ko,lv,ms,nb,nl,pl,pt_BR,pt,ro,ru,sk,sv,th,tr,uk,vi,zh_CN,zh_TW"
  66. ).split(",")
  67. tlist = [env.Dir("#editor/translations").abspath + "/" + f + ".po" for f in to_include]
  68. env.Depends("#editor/editor_translations.gen.h", tlist)
  69. env.CommandNoCache(
  70. "#editor/editor_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_editor_translations_header)
  71. )
  72. # Documentation translations
  73. to_include = "de,es,fr,ja,zh_CN".split(",")
  74. tlist = [env.Dir("#doc/translations").abspath + "/" + f + ".po" for f in to_include]
  75. env.Depends("#editor/doc_translations.gen.h", tlist)
  76. env.CommandNoCache(
  77. "#editor/doc_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_doc_translations_header)
  78. )
  79. # Fonts
  80. flist = glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.ttf")
  81. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.otf"))
  82. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff"))
  83. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff2"))
  84. flist.sort()
  85. env.Depends("#editor/builtin_fonts.gen.h", flist)
  86. env.CommandNoCache("#editor/builtin_fonts.gen.h", flist, run_in_subprocess(editor_builders.make_fonts_header))
  87. env.add_source_files(env.editor_sources, "*.cpp")
  88. env.add_source_files(env.editor_sources, "register_exporters.gen.cpp")
  89. SConscript("collada/SCsub")
  90. SConscript("doc/SCsub")
  91. SConscript("fileserver/SCsub")
  92. SConscript("icons/SCsub")
  93. SConscript("import/SCsub")
  94. SConscript("plugins/SCsub")
  95. lib = env.add_library("editor", env.editor_sources)
  96. env.Prepend(LIBS=[lib])