SCsub 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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. 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. env.editor_sources.append("#platform/" + e + "/export/export.cpp")
  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_utf8("register_exporters.gen.cpp", "w") as f:
  31. f.write(reg_exporters_inc)
  32. f.write(reg_exporters)
  33. # API documentation
  34. docs = []
  35. doc_dirs = ["doc/classes"]
  36. for p in env.doc_class_path.values():
  37. if p not in doc_dirs:
  38. doc_dirs.append(p)
  39. for d in doc_dirs:
  40. try:
  41. for f in os.listdir(os.path.join(env.Dir('#').abspath, d)):
  42. docs.append("#" + os.path.join(d, f))
  43. except OSError:
  44. pass
  45. _make_doc_data_class_path(os.path.join(env.Dir('#').abspath, "editor/doc"))
  46. docs = sorted(docs)
  47. env.Depends("#editor/doc_data_compressed.gen.h", docs)
  48. env.CommandNoCache("#editor/doc_data_compressed.gen.h", docs, run_in_subprocess(editor_builders.make_doc_header))
  49. import glob
  50. path = env.Dir('.').abspath
  51. # Translations
  52. tlist = glob.glob(path + "/translations/*.po")
  53. env.Depends('#editor/translations.gen.h', tlist)
  54. env.CommandNoCache('#editor/translations.gen.h', tlist, run_in_subprocess(editor_builders.make_translations_header))
  55. # Fonts
  56. flist = glob.glob(path + "/../thirdparty/fonts/*.ttf")
  57. flist.extend(glob.glob(path + "/../thirdparty/fonts/*.otf"))
  58. flist.sort()
  59. env.Depends('#editor/builtin_fonts.gen.h', flist)
  60. env.CommandNoCache('#editor/builtin_fonts.gen.h', flist, run_in_subprocess(editor_builders.make_fonts_header))
  61. env.add_source_files(env.editor_sources, "*.cpp")
  62. env_thirdparty = env.Clone()
  63. env_thirdparty.disable_warnings()
  64. env_thirdparty.add_source_files(env.editor_sources, ["#thirdparty/misc/clipper.cpp"])
  65. SConscript('collada/SCsub')
  66. SConscript('doc/SCsub')
  67. SConscript('fileserver/SCsub')
  68. SConscript('icons/SCsub')
  69. SConscript('import/SCsub')
  70. SConscript('plugins/SCsub')
  71. lib = env.add_library("editor", env.editor_sources)
  72. env.Prepend(LIBS=[lib])