SCsub 4.6 KB

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