SCsub 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  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_enc.cpp",
  17. "basisu_backend.cpp",
  18. "basisu_basis_file.cpp",
  19. "basisu_bc7enc.cpp",
  20. "basisu_opencl.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_pvrtc1_4.cpp",
  28. "basisu_resampler.cpp",
  29. "basisu_resample_filters.cpp",
  30. "basisu_ssim.cpp",
  31. "basisu_uastc_enc.cpp",
  32. "pvpngreader.cpp",
  33. ]
  34. encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources]
  35. transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
  36. # Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
  37. if not env.msvc:
  38. env_basisu.Append(CPPFLAGS=["-isystem", Dir(thirdparty_dir).path])
  39. else:
  40. env_basisu.Prepend(CPPPATH=[thirdparty_dir])
  41. if basisu_encoder:
  42. env_basisu.Prepend(CPPPATH=["#thirdparty/jpeg-compressor"])
  43. env_basisu.Prepend(CPPPATH=["#thirdparty/tinyexr"])
  44. if env["builtin_zstd"]:
  45. env_basisu.Prepend(CPPPATH=["#thirdparty/zstd"])
  46. env_thirdparty = env_basisu.Clone()
  47. env_thirdparty.disable_warnings()
  48. # Disable unneeded features to reduce binary size.
  49. # <https://github.com/BinomialLLC/basis_universal/wiki/How-to-Use-and-Configure-the-Transcoder>
  50. env_thirdparty.Append(
  51. CPPDEFINES=[
  52. # Storage formats.
  53. # Godot only implements `.basis` support through basis_universal.
  54. # Support for `.ktx` files are implemented with a direct libktx implementation.
  55. # Building the encoder requires `BASISD_SUPPORT_KTX2` to be enabled,
  56. # so we can only disable Zstandard compression for `.ktx` files
  57. # (this is not used in `.basis` files).
  58. ("BASISD_SUPPORT_KTX2_ZSTD", 0),
  59. # GPU compression formats.
  60. ("BASISD_SUPPORT_ATC", 0), # Proprietary Adreno format not supported by Godot.
  61. ("BASISD_SUPPORT_FXT1", 0), # Legacy format not supported by Godot.
  62. ("BASISD_SUPPORT_PVRTC1", 0), # Legacy format not supported by Godot.
  63. ("BASISD_SUPPORT_PVRTC2", 0), # Legacy format not supported by Godot.
  64. ]
  65. )
  66. if basisu_encoder:
  67. env_thirdparty.add_source_files(thirdparty_obj, encoder_sources)
  68. env_thirdparty.add_source_files(thirdparty_obj, transcoder_sources)
  69. env.modules_sources += thirdparty_obj
  70. # Godot source files
  71. module_obj = []
  72. env_basisu.add_source_files(module_obj, "*.cpp")
  73. env.modules_sources += module_obj
  74. # Needed to force rebuilding the module files when the thirdparty library is updated.
  75. env.Depends(module_obj, thirdparty_obj)