SCsub 3.6 KB

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