SCsub 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #!/usr/bin/env python
  2. Import("env")
  3. env.editor_sources = []
  4. import os
  5. import glob
  6. import editor_builders
  7. def _make_doc_data_class_path(to_path):
  8. # NOTE: It is safe to generate this file here, since this is still executed serially
  9. g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8")
  10. g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
  11. g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
  12. g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n")
  13. for c in sorted(env.doc_class_path):
  14. g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n')
  15. g.write("\t{nullptr, nullptr}\n")
  16. g.write("};\n")
  17. g.close()
  18. if env.editor_build:
  19. # Register exporters
  20. reg_exporters_inc = '#include "register_exporters.h"\n\n'
  21. reg_exporters = "void register_exporters() {\n"
  22. for e in env.platform_exporters:
  23. # Add all .cpp files in export folder
  24. env.add_source_files(env.editor_sources, "../platform/" + e + "/export/" + "*.cpp")
  25. reg_exporters += "\tregister_" + e + "_exporter();\n"
  26. reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
  27. reg_exporters += "}\n\n"
  28. reg_exporters += "void register_exporter_types() {\n"
  29. for e in env.platform_exporters:
  30. reg_exporters += "\tregister_" + e + "_exporter_types();\n"
  31. reg_exporters += "}\n"
  32. # NOTE: It is safe to generate this file here, since this is still executed serially
  33. with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f:
  34. f.write(reg_exporters_inc)
  35. f.write(reg_exporters)
  36. # Core API documentation.
  37. docs = []
  38. docs += Glob("#doc/classes/*.xml")
  39. # Module API documentation.
  40. module_dirs = []
  41. for d in env.doc_class_path.values():
  42. if d not in module_dirs:
  43. module_dirs.append(d)
  44. for d in module_dirs:
  45. if not os.path.isabs(d):
  46. docs += Glob("#" + d + "/*.xml") # Built-in.
  47. else:
  48. docs += Glob(d + "/*.xml") # Custom.
  49. _make_doc_data_class_path(env.Dir("#editor").abspath)
  50. docs = sorted(docs)
  51. env.Depends("#editor/doc_data_compressed.gen.h", docs)
  52. env.CommandNoCache(
  53. "#editor/doc_data_compressed.gen.h",
  54. docs,
  55. env.Run(editor_builders.make_doc_header, "Generating documentation header."),
  56. )
  57. # Editor interface and class reference translations incur a significant size
  58. # cost for the editor binary (see godot-proposals#3421).
  59. # To limit it, we only include translations with a high enough completion
  60. # ratio (20% for the editor UI, 10% for the class reference).
  61. # Generated with `make include-list` for each resource.
  62. # Editor translations
  63. tlist = glob.glob(env.Dir("#editor/translations/editor").abspath + "/*.po")
  64. env.Depends("#editor/editor_translations.gen.h", tlist)
  65. env.CommandNoCache(
  66. "#editor/editor_translations.gen.h",
  67. tlist,
  68. env.Run(editor_builders.make_editor_translations_header, "Generating editor translations header."),
  69. )
  70. # Property translations
  71. tlist = glob.glob(env.Dir("#editor/translations/properties").abspath + "/*.po")
  72. env.Depends("#editor/property_translations.gen.h", tlist)
  73. env.CommandNoCache(
  74. "#editor/property_translations.gen.h",
  75. tlist,
  76. env.Run(editor_builders.make_property_translations_header, "Generating property translations header."),
  77. )
  78. # Documentation translations
  79. tlist = glob.glob(env.Dir("#doc/translations").abspath + "/*.po")
  80. env.Depends("#editor/doc_translations.gen.h", tlist)
  81. env.CommandNoCache(
  82. "#editor/doc_translations.gen.h",
  83. tlist,
  84. env.Run(editor_builders.make_doc_translations_header, "Generating translations header."),
  85. )
  86. # Fonts
  87. flist = glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.ttf")
  88. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.otf"))
  89. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff"))
  90. flist.extend(glob.glob(env.Dir("#thirdparty").abspath + "/fonts/*.woff2"))
  91. flist.sort()
  92. env.Depends("#editor/builtin_fonts.gen.h", flist)
  93. env.CommandNoCache(
  94. "#editor/builtin_fonts.gen.h",
  95. flist,
  96. env.Run(editor_builders.make_fonts_header, "Generating builtin fonts header."),
  97. )
  98. env.add_source_files(env.editor_sources, "*.cpp")
  99. env.add_source_files(env.editor_sources, "register_exporters.gen.cpp")
  100. SConscript("debugger/SCsub")
  101. SConscript("export/SCsub")
  102. SConscript("gui/SCsub")
  103. SConscript("icons/SCsub")
  104. SConscript("import/SCsub")
  105. SConscript("plugins/SCsub")
  106. lib = env.add_library("editor", env.editor_sources)
  107. env.Prepend(LIBS=[lib])