Skip to content

armgit / godot

Public Imported from GitHub
0

Godot Engine – Multi-platform 2D and 3D game engine

SCons option to enable S3TC and ETC compression in export templates

David Snopek5f480e48f8d6
diff --git a/modules/etcpak/SCsub b/modules/etcpak/SCsub
index e6ecb2bc83f..c4b49640cac 100644
--- a/modules/etcpak/SCsub
+++ b/modules/etcpak/SCsub
@@ -31,6 +31,9 @@ env.modules_sources += thirdparty_obj
module_obj = []
+if env.editor_build or env["etcpak_export_templates"]:
+ env_etcpak.Append(CPPDEFINES=["ETCPAK_COMPRESS_ENABLED"])
+
env_etcpak.add_source_files(module_obj, "*.cpp")
env.modules_sources += module_obj
diff --git a/modules/etcpak/config.py b/modules/etcpak/config.py
index d22f9454ed2..3c47f2908e3 100644
--- a/modules/etcpak/config.py
+++ b/modules/etcpak/config.py
@@ -2,5 +2,17 @@ def can_build(env, platform):
return True
+def get_opts(platform):
+ from SCons.Variables import BoolVariable
+
+ return [
+ BoolVariable(
+ "etcpak_export_templates",
+ "Enable S3TC and ETC image compression in export template builds (increases binary size)",
+ False,
+ ),
+ ]
+
+
def configure(env):
pass
diff --git a/modules/etcpak/image_compress_etcpak.cpp b/modules/etcpak/image_compress_etcpak.cpp
index 1d8c936079d..02ba651aa9f 100644
--- a/modules/etcpak/image_compress_etcpak.cpp
+++ b/modules/etcpak/image_compress_etcpak.cpp
@@ -30,7 +30,7 @@
#include "image_compress_etcpak.h"
-#ifdef TOOLS_ENABLED
+#ifdef ETCPAK_COMPRESS_ENABLED
#include "core/os/os.h"
#include "core/string/print_string.h"
@@ -305,4 +305,4 @@ void _compress_etcpak(EtcpakType p_compress_type, Image *r_img) {
print_verbose(vformat("etcpak: Encoding took %d ms.", OS::get_singleton()->get_ticks_msec() - start_time));
}
-#endif // TOOLS_ENABLED
+#endif // ETCPAK_COMPRESS_ENABLED
diff --git a/modules/etcpak/image_compress_etcpak.h b/modules/etcpak/image_compress_etcpak.h
index eb57297b71a..c0b9d2f736f 100644
--- a/modules/etcpak/image_compress_etcpak.h
+++ b/modules/etcpak/image_compress_etcpak.h
@@ -30,7 +30,7 @@
#pragma once
-#ifdef TOOLS_ENABLED
+#ifdef ETCPAK_COMPRESS_ENABLED
#include "core/io/image.h"
@@ -54,4 +54,4 @@ void _compress_bc(Image *r_img, Image::UsedChannels p_channels);
void _compress_etcpak(EtcpakType p_compress_type, Image *r_img);
-#endif // TOOLS_ENABLED
+#endif // ETCPAK_COMPRESS_ENABLED
diff --git a/modules/etcpak/register_types.cpp b/modules/etcpak/register_types.cpp
index da0c1e5c1b0..6a3ba159520 100644
--- a/modules/etcpak/register_types.cpp
+++ b/modules/etcpak/register_types.cpp
@@ -38,7 +38,7 @@ void initialize_etcpak_module(ModuleInitializationLevel p_level) {
return;
}
-#ifdef TOOLS_ENABLED
+#ifdef ETCPAK_COMPRESS_ENABLED
Image::_image_compress_etc1_func = _compress_etc1;
Image::_image_compress_etc2_func = _compress_etc2;
Image::_image_compress_bc_func = _compress_bc;