SCsub 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. #!/usr/bin/env python
  2. Import("env")
  3. Import("env_modules")
  4. from compat import isbasestring
  5. env_freetype = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. if env["builtin_freetype"]:
  9. thirdparty_dir = "#thirdparty/freetype/"
  10. thirdparty_sources = [
  11. "src/autofit/autofit.c",
  12. "src/base/ftbase.c",
  13. "src/base/ftbbox.c",
  14. "src/base/ftbdf.c",
  15. "src/base/ftbitmap.c",
  16. "src/base/ftcid.c",
  17. "src/base/ftdebug.c",
  18. "src/base/ftfstype.c",
  19. "src/base/ftgasp.c",
  20. "src/base/ftglyph.c",
  21. "src/base/ftgxval.c",
  22. "src/base/ftinit.c",
  23. "src/base/ftmm.c",
  24. "src/base/ftotval.c",
  25. "src/base/ftpatent.c",
  26. "src/base/ftpfr.c",
  27. "src/base/ftstroke.c",
  28. "src/base/ftsynth.c",
  29. "src/base/ftsystem.c",
  30. "src/base/fttype1.c",
  31. "src/base/ftwinfnt.c",
  32. "src/bdf/bdf.c",
  33. "src/bzip2/ftbzip2.c",
  34. "src/cache/ftcache.c",
  35. "src/cff/cff.c",
  36. "src/cid/type1cid.c",
  37. "src/gxvalid/gxvalid.c",
  38. "src/gzip/ftgzip.c",
  39. "src/lzw/ftlzw.c",
  40. "src/otvalid/otvalid.c",
  41. "src/pcf/pcf.c",
  42. "src/pfr/pfr.c",
  43. "src/psaux/psaux.c",
  44. "src/pshinter/pshinter.c",
  45. "src/psnames/psnames.c",
  46. "src/raster/raster.c",
  47. "src/sdf/sdf.c",
  48. "src/svg/svg.c",
  49. "src/smooth/smooth.c",
  50. "src/truetype/truetype.c",
  51. "src/type1/type1.c",
  52. "src/type42/type42.c",
  53. "src/winfonts/winfnt.c",
  54. ]
  55. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  56. thirdparty_brotli_dir = "#thirdparty/brotli/"
  57. thirdparty_brotli_sources = [
  58. "common/constants.c",
  59. "common/context.c",
  60. "common/dictionary.c",
  61. "common/platform.c",
  62. "common/shared_dictionary.c",
  63. "common/transform.c",
  64. "dec/bit_reader.c",
  65. "dec/decode.c",
  66. "dec/huffman.c",
  67. "dec/state.c",
  68. ]
  69. thirdparty_sources += [thirdparty_brotli_dir + file for file in thirdparty_brotli_sources]
  70. env_freetype.Append(CPPDEFINES=["FT_CONFIG_OPTION_USE_BROTLI"])
  71. env_freetype.Prepend(CPPPATH=[thirdparty_brotli_dir + "include"])
  72. if env["platform"] == "uwp":
  73. # Include header for UWP to fix build issues
  74. env_freetype.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
  75. # Globally too, as freetype is used in scene (see bottom)
  76. env.Append(CCFLAGS=["/FI", '"modules/freetype/uwpdef.h"'])
  77. env_freetype.Prepend(CPPPATH=[thirdparty_dir + "/include"])
  78. # Also needed in main env for scene/
  79. env.Prepend(CPPPATH=[thirdparty_dir + "/include"])
  80. env_freetype.Append(CPPDEFINES=["FT2_BUILD_LIBRARY", "FT_CONFIG_OPTION_USE_PNG", "FT_CONFIG_OPTION_SYSTEM_ZLIB"])
  81. if env["target"] == "debug":
  82. env_freetype.Append(CPPDEFINES=["ZLIB_DEBUG"])
  83. # Also requires libpng headers
  84. if env["builtin_libpng"]:
  85. env_freetype.Prepend(CPPPATH=["#thirdparty/libpng"])
  86. sfnt = thirdparty_dir + "src/sfnt/sfnt.c"
  87. # Must be done after all CPPDEFINES are being set so we can copy them.
  88. if env["platform"] == "javascript":
  89. # Forcibly undefine this macro so SIMD is not used in this file,
  90. # since currently unsupported in WASM
  91. tmp_env = env_freetype.Clone()
  92. tmp_env.disable_warnings()
  93. tmp_env.Append(CPPFLAGS=["-U__OPTIMIZE__"])
  94. sfnt = tmp_env.Object(sfnt)
  95. thirdparty_sources += [sfnt]
  96. env_thirdparty = env_freetype.Clone()
  97. env_thirdparty.disable_warnings()
  98. lib = env_thirdparty.add_library("freetype_builtin", thirdparty_sources)
  99. thirdparty_obj += lib
  100. # Needs to be appended to arrive after libscene in the linker call,
  101. # but we don't want it to arrive *after* system libs, so manual hack
  102. # LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
  103. # and then plain strings for system library. We insert between the two.
  104. inserted = False
  105. for idx, linklib in enumerate(env["LIBS"]):
  106. if isbasestring(linklib): # first system lib such as "X11", otherwise SCons lib object
  107. env["LIBS"].insert(idx, lib)
  108. inserted = True
  109. break
  110. if not inserted:
  111. env.Append(LIBS=[lib])
  112. # Godot source files
  113. module_obj = []
  114. env_freetype.add_source_files(module_obj, "*.cpp")
  115. env.modules_sources += module_obj
  116. # Needed to force rebuilding the module files when the thirdparty library is updated.
  117. env.Depends(module_obj, thirdparty_obj)