From a745e28f5204b262bd6e58e8a8c7c0882e32cbdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?R=C3=A9mi=20Verschelde?= Date: Sat, 30 Nov 2024 01:40:16 +0100 Subject: [PATCH] basis_universal: Clarify encoder-only dependencies, only used in editor builds --- modules/basis_universal/SCsub | 73 +++++++++++++++++-------------- modules/basis_universal/config.py | 3 +- 2 files changed, 42 insertions(+), 34 deletions(-) diff --git a/modules/basis_universal/SCsub b/modules/basis_universal/SCsub index e2014523854c..3a2762c0ce5b 100644 --- a/modules/basis_universal/SCsub +++ b/modules/basis_universal/SCsub @@ -12,45 +12,52 @@ thirdparty_obj = [] # Not unbundled so far since not widespread as shared library thirdparty_dir = "#thirdparty/basis_universal/" + +# Only build the encoder for editor builds +basisu_encoder = env.editor_build + # Sync list with upstream CMakeLists.txt -encoder_sources = [ - "3rdparty/android_astc_decomp.cpp", - "basisu_astc_hdr_enc.cpp", - "basisu_backend.cpp", - "basisu_basis_file.cpp", - "basisu_bc7enc.cpp", - "basisu_opencl.cpp", - "basisu_comp.cpp", - "basisu_enc.cpp", - "basisu_etc.cpp", - "basisu_frontend.cpp", - "basisu_gpu_texture.cpp", - "basisu_kernels_sse.cpp", - "basisu_pvrtc1_4.cpp", - "basisu_resampler.cpp", - "basisu_resample_filters.cpp", - "basisu_ssim.cpp", - "basisu_uastc_enc.cpp", - "pvpngreader.cpp", -] -encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources] +if basisu_encoder: + encoder_sources = [ + "3rdparty/android_astc_decomp.cpp", + "basisu_astc_hdr_enc.cpp", + "basisu_backend.cpp", + "basisu_basis_file.cpp", + "basisu_bc7enc.cpp", + "basisu_opencl.cpp", + "basisu_comp.cpp", + "basisu_enc.cpp", + "basisu_etc.cpp", + "basisu_frontend.cpp", + "basisu_gpu_texture.cpp", + "basisu_kernels_sse.cpp", + "basisu_pvrtc1_4.cpp", + "basisu_resampler.cpp", + "basisu_resample_filters.cpp", + "basisu_ssim.cpp", + "basisu_uastc_enc.cpp", + "pvpngreader.cpp", + ] + encoder_sources = [thirdparty_dir + "encoder/" + file for file in encoder_sources] + transcoder_sources = [thirdparty_dir + "transcoder/basisu_transcoder.cpp"] -# Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC. -if not env.msvc: - env_basisu.Append( - CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir("#thirdparty/jpeg-compressor").path] - ) -else: - env_basisu.Prepend(CPPPATH=[thirdparty_dir, "#thirdparty/jpeg-compressor"]) +if basisu_encoder: + # Treat Basis headers as system headers to avoid raising warnings. Not supported on MSVC. + if not env.msvc: + env_basisu.Append( + CPPFLAGS=["-isystem", Dir(thirdparty_dir).path, "-isystem", Dir("#thirdparty/jpeg-compressor").path] + ) + else: + env_basisu.Prepend(CPPPATH=[thirdparty_dir, "#thirdparty/jpeg-compressor"]) + + env_basisu.Prepend(CPPPATH=["#thirdparty/tinyexr"]) if env["builtin_zstd"]: env_basisu.Prepend(CPPPATH=["#thirdparty/zstd"]) -env_basisu.Prepend(CPPPATH=["#thirdparty/tinyexr"]) - if env.dev_build: - env_basisu.Append(CPPDEFINES=[("BASISU_DEVEL_MESSAGES", 1), ("BASISD_ENABLE_DEBUG_FLAGS", 1)]) + env_basisu.Append(CPPDEFINES=[("BASISU_FORCE_DEVEL_MESSAGES", 1), ("BASISD_ENABLE_DEBUG_FLAGS", 1)]) env_thirdparty = env_basisu.Clone() env_thirdparty.disable_warnings() @@ -74,9 +81,9 @@ env_thirdparty.Append( ] ) -if env.editor_build: - env_thirdparty.Append(CPPDEFINES=["BASISU_NO_IMG_LOADERS"]) +if basisu_encoder: env_thirdparty.add_source_files(thirdparty_obj, encoder_sources) + env_thirdparty.add_source_files(thirdparty_obj, transcoder_sources) env.modules_sources += thirdparty_obj diff --git a/modules/basis_universal/config.py b/modules/basis_universal/config.py index 6a67f2c77cb9..0f723cbb6b5e 100644 --- a/modules/basis_universal/config.py +++ b/modules/basis_universal/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - env.module_add_dependencies("basis_universal", ["jpg"]) + if env.editor_build: # Encoder dependencies + env.module_add_dependencies("basis_universal", ["jpg", "tinyexr"]) return True