SCsub 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/env python
  2. Import("env")
  3. env.editor_sources = []
  4. import os
  5. import os.path
  6. from platform_methods import run_in_subprocess
  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{NULL, NULL}\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. # API documentation
  33. docs = []
  34. doc_dirs = ["doc/classes"]
  35. for p in env.doc_class_path.values():
  36. if p not in doc_dirs:
  37. doc_dirs.append(p)
  38. for d in doc_dirs:
  39. try:
  40. for f in os.listdir(os.path.join(env.Dir("#").abspath, d)):
  41. docs.append("#" + os.path.join(d, f))
  42. except OSError:
  43. pass
  44. _make_doc_data_class_path(os.path.join(env.Dir("#").abspath, "editor"))
  45. docs = sorted(docs)
  46. env.Depends("#editor/doc_data_compressed.gen.h", docs)
  47. env.CommandNoCache("#editor/doc_data_compressed.gen.h", docs, run_in_subprocess(editor_builders.make_doc_header))
  48. import glob
  49. path = env.Dir(".").abspath
  50. # Editor translations
  51. tlist = glob.glob(path + "/translations/*.po")
  52. env.Depends("#editor/editor_translations.gen.h", tlist)
  53. env.CommandNoCache(
  54. "#editor/editor_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_editor_translations_header)
  55. )
  56. # Documentation translations
  57. tlist = glob.glob(env.Dir("#doc").abspath + "/translations/*.po")
  58. env.Depends("#editor/doc_translations.gen.h", tlist)
  59. env.CommandNoCache(
  60. "#editor/doc_translations.gen.h", tlist, run_in_subprocess(editor_builders.make_doc_translations_header)
  61. )
  62. # Fonts
  63. flist = glob.glob(path + "/../thirdparty/fonts/*.ttf")
  64. flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf"))
  65. flist.sort()
  66. env.Depends("#editor/builtin_fonts.gen.h", flist)
  67. env.CommandNoCache("#editor/builtin_fonts.gen.h", flist, run_in_subprocess(editor_builders.make_fonts_header))
  68. env.add_source_files(env.editor_sources, "*.cpp")
  69. SConscript("debugger/SCsub")
  70. SConscript("fileserver/SCsub")
  71. SConscript("icons/SCsub")
  72. SConscript("import/SCsub")
  73. SConscript("plugins/SCsub")
  74. lib = env.add_library("editor", env.editor_sources)
  75. env.Prepend(LIBS=[lib])