SCsub 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. Import("env_modules")
  5. env_msdfgen = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. if env["builtin_msdfgen"]:
  9. env_msdfgen.disable_warnings()
  10. thirdparty_dir = "#thirdparty/msdfgen/"
  11. thirdparty_sources = [
  12. "core/Contour.cpp",
  13. "core/DistanceMapping.cpp",
  14. "core/EdgeHolder.cpp",
  15. "core/MSDFErrorCorrection.cpp",
  16. "core/Projection.cpp",
  17. "core/Scanline.cpp",
  18. "core/Shape.cpp",
  19. "core/contour-combiners.cpp",
  20. "core/edge-coloring.cpp",
  21. "core/edge-segments.cpp",
  22. "core/edge-selectors.cpp",
  23. "core/equation-solver.cpp",
  24. # "core/export-svg.cpp",
  25. "core/msdf-error-correction.cpp",
  26. "core/msdfgen.cpp",
  27. "core/rasterization.cpp",
  28. "core/render-sdf.cpp",
  29. # "core/save-bmp.cpp",
  30. # "core/save-fl32.cpp",
  31. # "core/save-rgba.cpp",
  32. # "core/save-tiff.cpp",
  33. "core/sdf-error-estimation.cpp",
  34. "core/shape-description.cpp",
  35. ]
  36. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  37. env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
  38. env_msdfgen.Prepend(CPPEXTPATH=["#thirdparty/freetype/include", "#thirdparty/msdfgen", "#thirdparty/nanosvg"])
  39. lib = env_msdfgen.add_library("msdfgen_builtin", thirdparty_sources)
  40. thirdparty_obj += lib
  41. # Needs to be appended to arrive after libscene in the linker call,
  42. # but we don't want it to arrive *after* system libs, so manual hack
  43. # LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
  44. # and then plain strings for system library. We insert between the two.
  45. inserted = False
  46. for idx, linklib in enumerate(env["LIBS"]):
  47. if isinstance(linklib, (str, bytes)): # first system lib such as "X11", otherwise SCons lib object
  48. env["LIBS"].insert(idx, lib)
  49. inserted = True
  50. break
  51. if not inserted:
  52. env.Append(LIBS=[lib])
  53. # Godot source files
  54. module_obj = []
  55. env_msdfgen.add_source_files(module_obj, "*.cpp")
  56. env.modules_sources += module_obj
  57. # Needed to force rebuilding the module files when the thirdparty library is updated.
  58. env.Depends(module_obj, thirdparty_obj)