Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add build option to enable MP1 and MP2 support in minimp3 #72729

Merged
merged 1 commit into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For context, I moved this so that the module_<name>_enabled option would come before the options specific to that module in scons --help. It shouldn't impact any of the logic otherwise (unless some custom modules rely on this being undefined in get_opts, but I doubt it :)).


# Add module-specific options.
try:
for opt in config.get_opts(selected_platform):
Expand All @@ -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)

Expand Down
3 changes: 3 additions & 0 deletions modules/minimp3/SCsub
Original file line number Diff line number Diff line change
Expand Up @@ -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")
1 change: 0 additions & 1 deletion modules/minimp3/audio_stream_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 8 additions & 0 deletions modules/minimp3/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions modules/minimp3/resource_importer_mp3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ String ResourceImporterMP3::get_visible_name() const {
}

void ResourceImporterMP3::get_recognized_extensions(List<String> *p_extensions) const {
#ifndef MINIMP3_ONLY_MP3
p_extensions->push_back("mp1");
p_extensions->push_back("mp2");
#endif
p_extensions->push_back("mp3");
}

Expand Down
Loading