SCsub 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. # Sync list with upstream CMakeLists.txt
  11. encoder_sources = [
  12. "3rdparty/android_astc_decomp.cpp",
  13. "basisu_astc_hdr_enc.cpp",
  14. "basisu_backend.cpp",
  15. "basisu_basis_file.cpp",
  16. "basisu_bc7enc.cpp",
  17. "basisu_opencl.cpp",
  18. "basisu_comp.cpp",
  19. "basisu_enc.cpp",
  20. "basisu_etc.cpp",
  21. "basisu_frontend.cpp",
  22. "basisu_gpu_texture.cpp",
  23. "basisu_kernels_sse.cpp",
  24. "basisu_pvrtc1_4.cpp",
  25. "basisu_resampler.cpp",
  26. "basisu_resample_filters.cpp",
  27. "basisu_ssim.cpp",
  28. "basisu_uastc_enc.cpp",
  29. "pvpngreader.cpp",
  30. ]
  31. encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources]
  32. transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"]
  33. # Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC.
  34. if not env.msvc:
  35. env_basisu.Append(
  36. CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir("#thirdparty/jpeg-compressor").path]
  37. )
  38. else:
  39. env_basisu.Prepend(CPPPATH=[thirdparty_dir, "#thirdparty/jpeg-compressor"])
  40. if env["builtin_zstd"]:
  41. env_basisu.Prepend(CPPPATH=["#thirdparty/zstd"])
  42. env_basisu.Prepend(CPPPATH=["#thirdparty/tinyexr"])
  43. if env.dev_build:
  44. env_basisu.Append(CPPDEFINES=[("BASISU_DEVEL_MESSAGES", 1), ("BASISD_ENABLE_DEBUG_FLAGS", 1)])
  45. env_thirdparty = env_basisu.Clone()
  46. env_thirdparty.disable_warnings()
  47. # Disable unneeded features to reduce binary size.
  48. # <https://github.com/BinomialLLC/basis_universal/wiki/How-to-Use-and-Configure-the-Transcoder>
  49. env_thirdparty.Append(
  50. CPPDEFINES=[
  51. # Storage formats.
  52. # Godot only implements `.basis` support through basis_universal.
  53. # Support for `.ktx` files are implemented with a direct libktx implementation.
  54. # Building the encoder requires `BASISD_SUPPORT_KTX2` to be enabled,
  55. # so we can only disable Zstandard compression for `.ktx` files
  56. # (this is not used in `.basis` files).
  57. ("BASISD_SUPPORT_KTX2_ZSTD", 0),
  58. # GPU compression formats.
  59. ("BASISD_SUPPORT_ATC", 0), # Proprietary Adreno format not supported by Godot.
  60. ("BASISD_SUPPORT_FXT1", 0), # Legacy format not supported by Godot.
  61. ("BASISD_SUPPORT_PVRTC1", 0), # Legacy format not supported by Godot.
  62. ("BASISD_SUPPORT_PVRTC2", 0), # Legacy format not supported by Godot.
  63. ]
  64. )
  65. if env.editor_build:
  66. env_thirdparty.Append(CPPDEFINES=["BASISU_NO_IMG_LOADERS"])
  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)