From 36ff0591f2960726c6563e3af4d6ca5faf0a4a0d Mon Sep 17 00:00:00 2001 From: "Ithamar R. Adema" Date: Sun, 5 Feb 2023 10:58:35 +0100 Subject: [PATCH] Add build option for MP1/MP2 audio format support. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Enabling this adds 3.5k to the template size (Win/64bits). Co-authored-by: Riteo Co-authored-by: RĂ©mi Verschelde --- SConstruct | 3 ++- modules/minimp3/SCsub | 3 +++ modules/minimp3/audio_stream_mp3.cpp | 1 - modules/minimp3/config.py | 8 ++++++++ modules/minimp3/resource_importer_mp3.cpp | 4 ++++ 5 files changed, 17 insertions(+), 2 deletions(-) diff --git a/SConstruct b/SConstruct index a06dfc1bde5..4f411d6d0a5 100644 --- a/SConstruct +++ b/SConstruct @@ -375,6 +375,8 @@ for name, path in modules_detected.items(): else: enabled = False + opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled)) + # Add module-specific options. try: for opt in config.get_opts(selected_platform): @@ -384,7 +386,6 @@ for name, path in modules_detected.items(): sys.path.remove(path) sys.modules.pop("config") - opts.Add(BoolVariable("module_" + name + "_enabled", "Enable module '%s'" % (name,), enabled)) methods.write_modules(modules_detected) diff --git a/modules/minimp3/SCsub b/modules/minimp3/SCsub index 20e3165f38b..09e84f71e98 100644 --- a/modules/minimp3/SCsub +++ b/modules/minimp3/SCsub @@ -13,5 +13,8 @@ if not env.msvc: else: env_minimp3.Prepend(CPPPATH=[thirdparty_dir]) +if not env["minimp3_extra_formats"]: + env_minimp3.Append(CPPDEFINES=["MINIMP3_ONLY_MP3"]) + # Godot source files env_minimp3.add_source_files(env.modules_sources, "*.cpp") diff --git a/modules/minimp3/audio_stream_mp3.cpp b/modules/minimp3/audio_stream_mp3.cpp index 6af86a96dcf..4efa4d329ea 100644 --- a/modules/minimp3/audio_stream_mp3.cpp +++ b/modules/minimp3/audio_stream_mp3.cpp @@ -28,7 +28,6 @@ /* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ /**************************************************************************/ -#define MINIMP3_ONLY_MP3 #define MINIMP3_FLOAT_OUTPUT #define MINIMP3_IMPLEMENTATION #define MINIMP3_NO_STDIO diff --git a/modules/minimp3/config.py b/modules/minimp3/config.py index e6bdcb2a83d..115b376fc86 100644 --- a/modules/minimp3/config.py +++ b/modules/minimp3/config.py @@ -2,6 +2,14 @@ def can_build(env, platform): return True +def get_opts(platform): + from SCons.Variables import BoolVariable + + return [ + BoolVariable("minimp3_extra_formats", "Build minimp3 with MP1/MP2 decoding support", False), + ] + + def configure(env): pass diff --git a/modules/minimp3/resource_importer_mp3.cpp b/modules/minimp3/resource_importer_mp3.cpp index 4e56120ec6c..d60b979c3f1 100644 --- a/modules/minimp3/resource_importer_mp3.cpp +++ b/modules/minimp3/resource_importer_mp3.cpp @@ -47,6 +47,10 @@ String ResourceImporterMP3::get_visible_name() const { } void ResourceImporterMP3::get_recognized_extensions(List *p_extensions) const { +#ifndef MINIMP3_ONLY_MP3 + p_extensions->push_back("mp1"); + p_extensions->push_back("mp2"); +#endif p_extensions->push_back("mp3"); }