Skip to content

Commit 728aaeb

Browse files
Oipokripken
authored andcommitted
Compile and copy all vorbis libraries, fixes #7879 (#9849)
Vorbis actually consists of three libraries: vorbis.a, vorbisfile.a and vorbisenc.a. This pull request modifies the vorbis port to build and cache these files. Fixes #7879
1 parent 7e93e03 commit 728aaeb

File tree

12 files changed

+38
-30
lines changed

12 files changed

+38
-30
lines changed

AUTHORS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,7 @@ a license to everyone to use it as detailed in LICENSE.)
437437
* Gernot Lassnig <[email protected]>
438438
* Christian Boos <[email protected]>
439439
* Erik Scholz <[email protected]>
440+
* Michael de Lang <[email protected]>
440441
* Gergely Nagy <[email protected]>
441442
* Jan Habermann <[email protected]>
442443
* John Granström <[email protected]>

embuilder.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def is_flag(arg):
240240
elif what == 'sdl2-net':
241241
build_port('sdl2-net', libname('libSDL2_net'), ['-s', 'USE_SDL=2', '-s', 'USE_SDL_NET=2'])
242242
elif what == 'sdl2-mixer':
243-
build_port('sdl2-mixer', 'libSDL2_mixer.a', ['-s', 'USE_SDL=2', '-s', 'USE_SDL_MIXER=2', '-s', 'USE_VORBIS=1'])
243+
build_port('sdl2-mixer', libname('libSDL2_mixer'), ['-s', 'USE_SDL=2', '-s', 'USE_SDL_MIXER=2', '-s', 'USE_VORBIS=1'])
244244
elif what == 'freetype':
245245
build_port('freetype', 'libfreetype.a', ['-s', 'USE_FREETYPE=1'])
246246
elif what == 'harfbuzz':

tests/sdl2_mixer.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ int main(int argc, char* argv[]){
3737
return -1;
3838
if (Mix_PlayChannel(-1, wave, 0) == -1)
3939
return -1;
40+
// Ensure that the test gives an error if OGG support was not compiled into SDL2_Mixer. See #7879
41+
if (Mix_Init(MIX_INIT_OGG) == -1)
42+
return -1;
4043
printf("Starting sound play loop\n");
4144
emscripten_set_main_loop(sound_loop_then_quit, 0, 1);
4245
return 0;

tools/ports/boost_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def create():
3535
commands = []
3636
o_s = []
3737
o = os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp.o')
38-
command = [shared.PYTHON, shared.EMCC, os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), '-o', o]
38+
command = [shared.PYTHON, shared.EMCC, '-c', os.path.join(ports.get_build_dir(), 'boost_headers', 'dummy.cpp'), '-o', o]
3939
commands.append(command)
4040
ports.run_commands(commands)
4141
final = os.path.join(ports.get_build_dir(), 'boost_headers', libname)

tools/ports/bzip2.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ def create():
3737
for src in srcs:
3838
o = os.path.join(ports.get_build_dir(), 'bzip2', src + '.o')
3939
shared.safe_ensure_dirs(os.path.dirname(o))
40-
commands.append([shared.PYTHON, shared.EMCC, os.path.join(dest_path, src), '-O2', '-o', o, '-I' + dest_path, '-w', ])
40+
commands.append([shared.PYTHON, shared.EMCC, '-c', os.path.join(dest_path, src), '-O2', '-o', o, '-I' + dest_path, '-w', ])
4141
o_s.append(o)
4242
ports.run_commands(commands)
4343

tools/ports/cocos2d.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def create():
4141
shared.safe_ensure_dirs(os.path.dirname(o))
4242
command = [shared.PYTHON,
4343
shared.EMCC,
44+
'-c',
4445
os.path.join(cocos2dx_root, 'proj.emscripten', src),
4546
'-Wno-overloaded-virtual',
4647
'-Wno-deprecated-declarations',

tools/ports/regal.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def create():
120120
c = os.path.join(dest_path_src, src)
121121
o = os.path.join(dest_path_src, src + '.o')
122122
shared.safe_ensure_dirs(os.path.dirname(o))
123-
commands.append([shared.PYTHON, shared.EMCC, c,
123+
commands.append([shared.PYTHON, shared.EMCC, '-c', c,
124124
# specify the defined symbols as the Regal Makefiles does for Emscripten+Release
125125
# the define logic for other symbols will be handled automatically by Regal headers (SYS_EMSCRIPTEN, SYS_EGL, SYS_ES2, etc.)
126126
'-DNDEBUG',

tools/ports/sdl2_image.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def create():
4949

5050
for src in srcs:
5151
o = os.path.join(ports.get_build_dir(), 'sdl2_image', src + '.o')
52-
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)
52+
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)
5353
o_s.append(o)
5454
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
5555
ports.run_commands(commands)

tools/ports/sdl2_mixer.py

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
1+
# Copyright 2016 The Emscripten Authors. All rights reserved.
2+
# Emscripten is available under two separate licenses, the MIT license and the
3+
# University of Illinois/NCSA Open Source License. Both these licenses can be
4+
# found in the LICENSE file.
5+
16
import os
27
import shutil
3-
import stat
8+
import logging
49

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

1723
def create():
18-
cwd = os.getcwd()
19-
commonflags = ['--disable-shared', '--disable-music-cmd', '--enable-sdltest', '--disable-smpegtest']
20-
formatflags = ['--enable-music-wave', '--disable-music-mod', '--disable-music-midi', '--enable-music-ogg', '--disable-music-ogg-shared', '--disable-music-flac', '--disable-music-mp3']
21-
configure = os.path.join(ports.get_dir(), 'sdl2_mixer', 'SDL2_mixer-' + TAG, 'configure')
22-
build_dir = os.path.join(ports.get_build_dir(), 'sdl2_mixer')
23-
dist_dir = os.path.join(ports.get_build_dir(), 'sdl2_mixer', 'dist')
24-
out = os.path.join(dist_dir, 'lib', 'libSDL2_mixer.a')
25-
final = os.path.join(ports.get_build_dir(), 'sdl2_mixer', 'libSDL2_mixer.a')
26-
shared.safe_ensure_dirs(build_dir)
27-
28-
try:
29-
os.chdir(build_dir)
30-
os.chmod(configure, os.stat(configure).st_mode | stat.S_IEXEC)
31-
shared.run_process([shared.PYTHON, shared.EMCONFIGURE, configure, '--prefix=' + dist_dir] + formatflags + commonflags + ['CFLAGS=-s USE_VORBIS=1'])
32-
shared.run_process([shared.PYTHON, shared.EMMAKE, 'make', 'install'])
33-
shutil.copyfile(out, final)
34-
finally:
35-
os.chdir(cwd)
24+
logging.info('building port: sdl2_mixer')
25+
26+
source_path = os.path.join(ports.get_dir(), 'sdl2_mixer', 'SDL2_mixer-' + TAG)
27+
dest_path = os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer')
28+
29+
shutil.rmtree(dest_path, ignore_errors=True)
30+
shutil.copytree(source_path, dest_path)
31+
# necessary for proper including of SDL_mixer.h
32+
os.symlink(dest_path, os.path.join(dest_path, 'SDL2'))
33+
34+
final = os.path.join(dest_path, libname)
35+
ports.build_port(dest_path, final, [], ['-DOGG_MUSIC', '-s', 'USE_VORBIS=1'],
36+
['dynamic_flac', 'dynamic_fluidsynth', 'dynamic_mod', 'dynamic_modplug', 'dynamic_mp3',
37+
'dynamic_ogg', 'fluidsynth', 'load_mp3', 'music_cmd', 'music_flac', 'music_mad', 'music_mod',
38+
'music_modplug', 'playmus.c', 'playwave.c'],
39+
['external', 'native_midi', 'timidity'])
3640
return final
3741

38-
return [shared.Cache.get('libSDL2_mixer.a', create, what='port')]
42+
return [shared.Cache.get(libname, create, what='port')]
3943

4044

4145
def clear(ports, shared):
@@ -51,7 +55,7 @@ def process_dependencies(settings):
5155
def process_args(ports, args, settings, shared):
5256
if settings.USE_SDL_MIXER == 2:
5357
get(ports, settings, shared)
54-
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer', 'dist', 'include')]
58+
args += ['-Xclang', '-isystem' + os.path.join(shared.Cache.get_path('ports-builds'), 'sdl2_mixer')]
5559
return args
5660

5761

tools/ports/sdl2_net.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import shutil
88
import logging
99

10-
1110
TAG = 'version_2'
1211
HASH = '317b22ad9b6b2f7b40fac7b7c426da2fa2da1803bbe58d480631f1e5b190d730763f2768c77c72affa806c69a1e703f401b15a1be3ec611cd259950d5ebc3711'
1312

@@ -34,7 +33,7 @@ def create():
3433
o_s = []
3534
for src in srcs:
3635
o = os.path.join(ports.get_build_dir(), 'sdl2_net', src + '.o')
37-
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'])
36+
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'])
3837
o_s.append(o)
3938
shared.safe_ensure_dirs(os.path.dirname(o_s[0]))
4039
ports.run_commands(commands)

0 commit comments

Comments
 (0)