SCsub 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #!/usr/bin/env python
  2. from misc.utility.scons_hints import *
  3. Import("env")
  4. Import("env_modules")
  5. env_basisu = env_modules.Clone()
  6. # Thirdparty source files
  7. thirdparty_obj = []
  8. # Not unbundled so far since not widespread as shared library
  9. thirdparty_dir = "#thirdparty/basis_universal/"
  10. # Only build the encoder for editor builds
  11. basisu_encoder = env.editor_build
  12. # Sync list with upstream CMakeLists.txt
  13. if basisu_encoder:
  14. encoder_sources = [
  15. "3rdparty/android_astc_decomp.cpp",
  16. "basisu_astc_hdr_6x6_enc.cpp",
  17. "basisu_astc_hdr_common.cpp",
  18. "basisu_backend.cpp",
  19. "basisu_basis_file.cpp",
  20. "basisu_bc7enc.cpp",
  21. "basisu_comp.cpp",
  22. "basisu_enc.cpp",
  23. "basisu_etc.cpp",
  24. "basisu_frontend.cpp",
  25. "basisu_gpu_texture.cpp",
  26. "basisu_kernels_sse.cpp",
  27. "basisu_opencl.cpp",
  28. "basisu_pvrtc1_4.cpp",
  29. "basisu_resample_filters.cpp",
  30. "basisu_resampler.cpp",
  31. "basisu_ssim.cpp",
  32. "basisu_uastc_enc.cpp",
  33. "basisu_uastc_hdr_4x4_enc.cpp",
  34. "jpgd.cpp",
  35. "pvpngreader.cpp",
  36. ]
  37. encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources]
  38. transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
  39. env_basisu.Prepend(CPPEXTPATH=[thirdparty_dir])
  40. if basisu_encoder:
  41. env_basisu.Prepend(CPPEXTPATH=["#thirdparty/tinyexr"])
  42. if env["builtin_zstd"]:
  43. env_basisu.Prepend(CPPEXTPATH=["#thirdparty/zstd"])
  44. env_thirdparty = env_basisu.Clone()
  45. env_thirdparty.disable_warnings()
  46. # Disable unneeded features to reduce binary size.
  47. # <https://github.com/BinomialLLC/basis_universal/wiki/How-to-Use-and-Configure-the-Transcoder>
  48. env_thirdparty.Append(
  49. CPPDEFINES=[
  50. # Enable ktx2 zstd supercompression.
  51. ("BASISD_SUPPORT_KTX2_ZSTD", 1),
  52. # GPU compression formats.
  53. ("BASISD_SUPPORT_ATC", 0), # Proprietary Adreno format not supported by Godot.
  54. ("BASISD_SUPPORT_FXT1", 0), # Legacy format not supported by Godot.
  55. ("BASISD_SUPPORT_PVRTC1", 0), # Legacy format not supported by Godot.
  56. ("BASISD_SUPPORT_PVRTC2", 0), # Legacy format not supported by Godot.
  57. ]
  58. )
  59. if basisu_encoder:
  60. env_thirdparty.add_source_files(thirdparty_obj, encoder_sources)
  61. env_thirdparty.add_source_files(thirdparty_obj, transcoder_sources)
  62. env.modules_sources += thirdparty_obj
  63. # Godot source files
  64. module_obj = []
  65. env_basisu.add_source_files(module_obj, "*.cpp")
  66. env.modules_sources += module_obj
  67. # Needed to force rebuilding the module files when the thirdparty library is updated.
  68. env.Depends(module_obj, thirdparty_obj)