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

Compile and copy all vorbis libraries, fixes #7879 #9849

Merged
merged 14 commits into from
Nov 26, 2019
Merged
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -437,4 +437,5 @@ a license to everyone to use it as detailed in LICENSE.)
* Gernot Lassnig <[email protected]>
* Christian Boos <[email protected]>
* Erik Scholz <[email protected]>
* Michael de Lang <[email protected]>
* Gergely Nagy <[email protected]>
2 changes: 1 addition & 1 deletion embuilder.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ def is_flag(arg):
elif what == 'sdl2-net':
build_port('sdl2-net', libname('libSDL2_net'), ['-s', 'USE_SDL=2', '-s', 'USE_SDL_NET=2'])
elif what == 'sdl2-mixer':
build_port('sdl2-mixer', 'libSDL2_mixer.a', ['-s', 'USE_SDL=2', '-s', 'USE_SDL_MIXER=2', '-s', 'USE_VORBIS=1'])
build_port('sdl2-mixer', libname('libSDL2_mixer'), ['-s', 'USE_SDL=2', '-s', 'USE_SDL_MIXER=2', '-s', 'USE_VORBIS=1'])
elif what == 'freetype':
build_port('freetype', 'libfreetype.a', ['-s', 'USE_FREETYPE=1'])
elif what == 'harfbuzz':
Expand Down
3 changes: 3 additions & 0 deletions tests/sdl2_mixer.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ int main(int argc, char* argv[]){
return -1;
if (Mix_PlayChannel(-1, wave, 0) == -1)
return -1;
// Ensure that the test gives an error if OGG support was not compiled into SDL2_Mixer. See #7879
if (Mix_Init(MIX_INIT_OGG) == -1)
return -1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Do this this test simply not work without this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Without this, the specific problem, namely that ogg support is not compiled into SDL2_Mixer, is never triggered. SDL2_Mixer initialises just fine without having ogg compiled in. This line of code forces an error if it is missing.

Copy link
Collaborator

Choose a reason for hiding this comment

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

But did the example just not play sound before?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, it's an example? I thought it was a test. The sound plays fine without this addition. Would you rather I create a new test specifically for ogg files?

Copy link
Collaborator

Choose a reason for hiding this comment

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

No it is a test. I just wonder what the purpose of the Mix_Init(MIX_INIT_OGG) line is if the code can play an ogg file even without this line? Is it just a way to verify that ogg support is built in? And if this code could play ogg files before this change, then surely ogg support was builtin previously?

I'm just trying to understand the state before this change. We could play ogg files? But this Mix_Init(MIX_INIT_OGG) would fail?

Copy link
Contributor Author

@Oipo Oipo Nov 16, 2019

Choose a reason for hiding this comment

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

I am sorry for the miscommunication. Let me try to clarify it:

  • No, playing ogg files is impossible without Mix_Init(MIX_INIT_OGG)
  • No, playing ogg files was impossible before, even with Mix_Init(MIX_INIT_OGG), it would return -1. SDL_GetError() would then return a message saying that ogg support was not compiled in.
  • Playing wave files without Mix_Init(MIX_INIT_OGG) has worked before and continues to work
  • With the changes made in this PR, this test, while not containing ogg files nor any attempt to play ogg files, will error when ogg support is not compiled in.
  • The changes made in this PR ensure that ogg support is compiled in and that this test succeeds in its new form.

Does this clarify things? If you have more questions, I'll be happy to answer them.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Got it. Sorry I thought this test played an ogg file.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good, but please add a comment, "this should error because OGG support was not compiled in".

printf("Starting sound play loop\n");
emscripten_set_main_loop(sound_loop_then_quit, 0, 1);
return 0;
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/boost_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def create():
commands = []
o_s = []
o = os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp.o')
command = [shared.PYTHON, shared.EMCC, os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), '-o', o]
command = [shared.PYTHON, shared.EMCC, '-c', os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), '-o', o]
commands.append(command)
ports.run_commands(commands)
final = os.path.join(ports.get_build_dir(), 'boost_headers', libname)
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/bzip2.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def create():
for src in srcs:
o = os.path.join(ports.get_build_dir(), 'bzip2', src + '.o')
shared.safe_ensure_dirs(os.path.dirname(o))
commands.append([shared.PYTHON, shared.EMCC, os.path.join(dest_path, src), '-O2', '-o', o, '-I' + dest_path, '-w', ])
commands.append([shared.PYTHON, shared.EMCC, '-c', os.path.join(dest_path, src), '-O2', '-o', o, '-I' + dest_path, '-w', ])
o_s.append(o)
ports.run_commands(commands)

Expand Down
1 change: 1 addition & 0 deletions tools/ports/cocos2d.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def create():
shared.safe_ensure_dirs(os.path.dirname(o))
command = [shared.PYTHON,
shared.EMCC,
'-c',
os.path.join(cocos2dx_root, 'proj.emscripten', src),
'-Wno-overloaded-virtual',
'-Wno-deprecated-declarations',
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/regal.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def create():
c = os.path.join(dest_path_src, src)
o = os.path.join(dest_path_src, src + '.o')
shared.safe_ensure_dirs(os.path.dirname(o))
commands.append([shared.PYTHON, shared.EMCC, c,
commands.append([shared.PYTHON, shared.EMCC, '-c', c,
# specify the defined symbols as the Regal Makefiles does for Emscripten+Release
# the define logic for other symbols will be handled automatically by Regal headers (SYS_EMSCRIPTEN, SYS_EGL, SYS_ES2, etc.)
'-DNDEBUG',
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/sdl2_image.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def create():

for src in srcs:
o = os.path.join(ports.get_build_dir(), 'sdl2_image', src + '.o')
commands.append([shared.PYTHON, shared.EMCC, os.path.join(ports.get_dir(), 'sdl2_image', 'SDL2_image-' + TAG, src), '-O2', '-s', 'USE_SDL=2', '-o', o, '-w'] + defs)
commands.append([shared.PYTHON, shared.EMCC, '-c', os.path.join(ports.get_dir(), 'sdl2_image', 'SDL2_image-' + TAG, src), '-O2', '-s', 'USE_SDL=2', '-o', o, '-w'] + defs)
o_s.append(o)
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
ports.run_commands(commands)
Expand Down
46 changes: 25 additions & 21 deletions tools/ports/sdl2_mixer.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Copyright 2016 The Emscripten Authors. All rights reserved.
# Emscripten is available under two separate licenses, the MIT license and the
# University of Illinois/NCSA Open Source License. Both these licenses can be
# found in the LICENSE file.

import os
import shutil
import stat
import logging

TAG = 'release-2.0.1'
HASH = '81fac757bd058adcb3eb5b2cc46addeaa44cee2cd4db653dad5d9666bdc0385cdc21bf5b72872e6dd6dd8eb65812a46d7752298827d6c61ad5ce2b6c963f7ed0'
Expand All @@ -13,29 +18,28 @@ def get(ports, settings, shared):
sdl_build = os.path.join(ports.get_build_dir(), 'sdl2')
assert os.path.exists(sdl_build), 'You must use SDL2 to use SDL2_mixer'
ports.fetch_project('sdl2_mixer', 'https://github.com/emscripten-ports/SDL2_mixer/archive/' + TAG + '.zip', 'SDL2_mixer-' + TAG, sha512hash=HASH)
libname = ports.get_lib_name('libSDL2_mixer')

def create():
cwd = os.getcwd()
commonflags = ['--disable-shared', '--disable-music-cmd', '--enable-sdltest', '--disable-smpegtest']
formatflags = ['--enable-music-wave', '--disable-music-mod', '--disable-music-midi', '--enable-music-ogg', '--disable-music-ogg-shared', '--disable-music-flac', '--disable-music-mp3']
configure = os.path.join(ports.get_dir(), 'sdl2_mixer', 'SDL2_mixer-' + TAG, 'configure')
build_dir = os.path.join(ports.get_build_dir(), 'sdl2_mixer')
dist_dir = os.path.join(ports.get_build_dir(), 'sdl2_mixer', 'dist')
out = os.path.join(dist_dir, 'lib', 'libSDL2_mixer.a')
final = os.path.join(ports.get_build_dir(), 'sdl2_mixer', 'libSDL2_mixer.a')
shared.safe_ensure_dirs(build_dir)

try:
os.chdir(build_dir)
os.chmod(configure, os.stat(configure).st_mode | stat.S_IEXEC)
shared.run_process([shared.PYTHON, shared.EMCONFIGURE, configure, '--prefix=' + dist_dir] + formatflags + commonflags + ['CFLAGS=-s USE_VORBIS=1'])
shared.run_process([shared.PYTHON, shared.EMMAKE, 'make', 'install'])
shutil.copyfile(out, final)
finally:
os.chdir(cwd)
logging.info('building port: sdl2_mixer')

source_path = os.path.join(ports.get_dir(), 'sdl2_mixer', 'SDL2_mixer-' + TAG)
dest_path = os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer')

shutil.rmtree(dest_path, ignore_errors=True)
shutil.copytree(source_path, dest_path)
# necessary for proper including of SDL_mixer.h
os.symlink(dest_path, os.path.join(dest_path, 'SDL2'))

final = os.path.join(dest_path, libname)
ports.build_port(dest_path, final, [], ['-DOGG_MUSIC', '-s', 'USE_VORBIS=1'],
['dynamic_flac', 'dynamic_fluidsynth', 'dynamic_mod', 'dynamic_modplug', 'dynamic_mp3',
'dynamic_ogg', 'fluidsynth', 'load_mp3', 'music_cmd', 'music_flac', 'music_mad', 'music_mod',
'music_modplug', 'playmus.c', 'playwave.c'],
['external', 'native_midi', 'timidity'])
return final

return [shared.Cache.get('libSDL2_mixer.a', create, what='port')]
return [shared.Cache.get(libname, create, what='port')]


def clear(ports, shared):
Expand All @@ -51,7 +55,7 @@ def process_dependencies(settings):
def process_args(ports, args, settings, shared):
if settings.USE_SDL_MIXER == 2:
get(ports, settings, shared)
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer', 'dist', 'include')]
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer')]
return args


Expand Down
3 changes: 1 addition & 2 deletions tools/ports/sdl2_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import shutil
import logging


TAG = 'version_2'
HASH = '317b22ad9b6b2f7b40fac7b7c426da2fa2da1803bbe58d480631f1e5b190d730763f2768c77c72affa806c69a1e703f401b15a1be3ec611cd259950d5ebc3711'

Expand All @@ -34,7 +33,7 @@ def create():
o_s = []
for src in srcs:
o = os.path.join(ports.get_build_dir(), 'sdl2_net', src + '.o')
commands.append([shared.PYTHON, shared.EMCC, os.path.join(ports.get_dir(), 'sdl2_net', 'SDL2_net-' + TAG, src), '-O2', '-s', 'USE_SDL=2', '-o', o, '-w'])
commands.append([shared.PYTHON, shared.EMCC, '-c', os.path.join(ports.get_dir(), 'sdl2_net', 'SDL2_net-' + TAG, src), '-O2', '-s', 'USE_SDL=2', '-o', o, '-w'])
o_s.append(o)
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
ports.run_commands(commands)
Expand Down
2 changes: 1 addition & 1 deletion tools/ports/sdl2_ttf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def create():
for src in srcs:
o = os.path.join(ports.get_build_dir(), 'sdl2_ttf', src + '.o')
command = [shared.PYTHON, shared.EMCC]
command += [os.path.join(ports.get_dir(), 'sdl2_ttf', 'SDL2_ttf-' + TAG, src)]
command += ['-c', os.path.join(ports.get_dir(), 'sdl2_ttf', 'SDL2_ttf-' + TAG, src)]
command += ['-O2', '-s', 'USE_SDL=2', '-s', 'USE_FREETYPE=1', '-o', o, '-w']
commands.append(command)
o_s.append(o)
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1500,7 +1500,7 @@ def build_port(src_path, output_path, includes=[], flags=[], exclude_files=[], e
for f in files:
ext = os.path.splitext(f)[1]
if ext in ('.c', '.cpp') and not any((excluded in f) for excluded in exclude_files):
srcs.append(os.path.join(root, f))
srcs.append(os.path.join(root, f))
include_commands = ['-I' + src_path]
for include in includes:
include_commands.append('-I' + include)
Expand Down