SCsub 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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/EdgeHolder.cpp",
  14. "core/MSDFErrorCorrection.cpp",
  15. "core/Projection.cpp",
  16. "core/Scanline.cpp",
  17. "core/Shape.cpp",
  18. "core/contour-combiners.cpp",
  19. "core/edge-coloring.cpp",
  20. "core/edge-segments.cpp",
  21. "core/edge-selectors.cpp",
  22. "core/equation-solver.cpp",
  23. "core/msdf-error-correction.cpp",
  24. "core/msdfgen.cpp",
  25. "core/rasterization.cpp",
  26. "core/render-sdf.cpp",
  27. "core/sdf-error-estimation.cpp",
  28. "core/shape-description.cpp",
  29. ]
  30. thirdparty_sources = [thirdparty_dir + file for file in thirdparty_sources]
  31. env_msdfgen.Append(CPPDEFINES=[("MSDFGEN_PUBLIC", "")])
  32. env_msdfgen.Prepend(CPPPATH=["#thirdparty/freetype/include", "#thirdparty/msdfgen", "#thirdparty/nanosvg"])
  33. lib = env_msdfgen.add_library("msdfgen_builtin", thirdparty_sources)
  34. thirdparty_obj += lib
  35. # Needs to be appended to arrive after libscene in the linker call,
  36. # but we don't want it to arrive *after* system libs, so manual hack
  37. # LIBS contains first SCons Library objects ("SCons.Node.FS.File object")
  38. # and then plain strings for system library. We insert between the two.
  39. inserted = False
  40. for idx, linklib in enumerate(env["LIBS"]):
  41. if isinstance(linklib, (str, bytes)): # first system lib such as "X11", otherwise SCons lib object
  42. env["LIBS"].insert(idx, lib)
  43. inserted = True
  44. break
  45. if not inserted:
  46. env.Append(LIBS=[lib])
  47. # Godot source files
  48. module_obj = []
  49. env_msdfgen.add_source_files(module_obj, "*.cpp")
  50. env.modules_sources += module_obj
  51. # Needed to force rebuilding the module files when the thirdparty library is updated.
  52. env.Depends(module_obj, thirdparty_obj)