SCsub 2.0 KB

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