SCsub 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  1. #!/usr/bin/env python
  2. Import("env")
  3. env.editor_sources = []
  4. import os
  5. import os.path
  6. import glob
  7. import editor_builders
  8. def _make_doc_data_class_path(to_path):
  9. # NOTE: It is safe to generate this file here, since this is still executed serially
  10. g = open(os.path.join(to_path, "doc_data_class_path.gen.h"), "w", encoding="utf-8")
  11. g.write("static const int _doc_data_class_path_count = " + str(len(env.doc_class_path)) + ";\n")
  12. g.write("struct _DocDataClassPath { const char* name; const char* path; };\n")
  13. g.write("static const _DocDataClassPath _doc_data_class_paths[" + str(len(env.doc_class_path) + 1) + "] = {\n")
  14. for c in sorted(env.doc_class_path):
  15. g.write('\t{"' + c + '", "' + env.doc_class_path[c] + '"},\n')
  16. g.write("\t{nullptr, nullptr}\n")
  17. g.write("};\n")
  18. g.close()
  19. if env["tools"]:
  20. # Register exporters
  21. reg_exporters_inc = '#include "register_exporters.h"\n'
  22. reg_exporters = "void register_exporters() {\n"
  23. for e in env.platform_exporters:
  24. env.add_source_files(env.editor_sources, "#platform/" + e + "/export/export.cpp")
  25. reg_exporters += "\tregister_" + e + "_exporter();\n"
  26. reg_exporters_inc += '#include "platform/' + e + '/export/export.h"\n'
  27. reg_exporters += "}\n"
  28. # NOTE: It is safe to generate this file here, since this is still executed serially
  29. with open("register_exporters.gen.cpp", "w", encoding="utf-8") as f:
  30. f.write(reg_exporters_inc)
  31. f.write(reg_exporters)
  32. # Core API documentation.
  33. docs = []
  34. docs += Glob("#doc/classes/*.xml")
  35. # Module API documentation.
  36. module_dirs = []
  37. for d in env.doc_class_path.values():
  38. if d not in module_dirs:
  39. module_dirs.append(d)
  40. for d in module_dirs:
  41. if not os.path.isabs(d):
  42. docs += Glob("#" + d + "/*.xml") # Built-in.
  43. else:
  44. docs += Glob(d + "/*.xml") # Custom.
  45. _make_doc_data_class_path(os.path.join(env.Dir("#").abspath, "editor"))
  46. docs = sorted(docs)
  47. env.Depends("#editor/doc_data_compressed.gen.h", docs)
  48. env.CommandNoCache(
  49. "#editor/doc_data_compressed.gen.h",
  50. docs,
  51. env.Run(editor_builders.make_doc_header, "Generating documentation header."),
  52. )
  53. path = env.Dir(".").abspath
  54. # Editor translations
  55. tlist = glob.glob(path + "/translations/*.po")
  56. env.Depends("#editor/editor_translations.gen.h", tlist)
  57. env.CommandNoCache(
  58. "#editor/editor_translations.gen.h",
  59. tlist,
  60. env.Run(editor_builders.make_editor_translations_header, "Generating editor translations header."),
  61. )
  62. # Documentation translations
  63. tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po")
  64. env.Depends("#editor/doc_translations.gen.h", tlist)
  65. env.CommandNoCache(
  66. "#editor/doc_translations.gen.h",
  67. tlist,
  68. env.Run(editor_builders.make_doc_translations_header, "Generating translations header."),
  69. )
  70. # Fonts
  71. flist = glob.glob(path + "/../thirdparty/fonts/*.ttf")
  72. flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf"))
  73. flist.sort()
  74. env.Depends("#editor/builtin_fonts.gen.h", flist)
  75. env.CommandNoCache(
  76. "#editor/builtin_fonts.gen.h",
  77. flist,
  78. env.Run(editor_builders.make_fonts_header, "Generating builtin fonts header."),
  79. )
  80. env.add_source_files(env.editor_sources, "*.cpp")
  81. SConscript("debugger/SCsub")
  82. SConscript("fileserver/SCsub")
  83. SConscript("icons/SCsub")
  84. SConscript("import/SCsub")
  85. SConscript("plugins/SCsub")
  86. lib = env.add_library("editor", env.editor_sources)
  87. env.Prepend(LIBS=[lib])