Skip to content

Commit deed1c5

Browse files
authored
Fix SDL_mixer header installation after #9983 (#10021)
Also add basic sdl2_mixer test outside of browser tests that just tests for successful compilation. Fixes #10015
1 parent 446cca2 commit deed1c5

File tree

4 files changed

+10
-7
lines changed

4 files changed

+10
-7
lines changed

tests/sdl2_mixer.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ void sound_loop_then_quit() {
1515

1616
emscripten_cancel_main_loop();
1717
printf("Shutting down\n");
18+
#ifdef REPORT_RESULT
1819
REPORT_RESULT(1);
20+
#endif
1921
}
2022

2123
int main(int argc, char* argv[]){

tests/test_other.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1803,6 +1803,9 @@ def test_sdl_endianness(self):
18031803
run_process([PYTHON, EMCC, 'main.cpp'])
18041804
self.assertContained('1234, 1234, 4321\n', run_js('a.out.js'))
18051805

1806+
def test_sdl2_mixer(self):
1807+
Building.emcc(path_from_root('tests', 'sdl2_mixer.c'), ['-s', 'USE_SDL_MIXER=2'], output_filename='a.out.js')
1808+
18061809
def test_libpng(self):
18071810
shutil.copyfile(path_from_root('tests', 'pngtest.png'), 'pngtest.png')
18081811
Building.emcc(path_from_root('tests', 'pngtest.c'), ['--embed-file', 'pngtest.png', '-s', 'USE_ZLIB=1', '-s', 'USE_LIBPNG=1'], output_filename='a.out.js')

tools/ports/sdl2_mixer.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,7 @@ def create():
3737
['external', 'native_midi', 'timidity'])
3838

3939
# copy header to a location so it can be used as 'SDL2/'
40-
dest_include_path = os.path.join(dest_path, 'include', 'SDL2')
41-
os.makedirs(dest_include_path)
42-
shutil.copyfile(os.path.join(source_path, 'SDL_mixer.h'),
43-
os.path.join(dest_include_path, 'SDL_mixer.h'))
44-
40+
ports.install_headers(source_path, pattern='SDL_*.h', target='SDL2')
4541
return final
4642

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

tools/system_libs.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1553,8 +1553,10 @@ def install_headers(src_dir, pattern="*.h", target=None):
15531553
if target:
15541554
dest = os.path.join(dest, target)
15551555
shared.safe_ensure_dirs(dest)
1556-
for f in glob.glob(os.path.join(src_dir, pattern)):
1557-
logger.debug(os.path.join(dest, os.path.basename(f)))
1556+
matches = glob.glob(os.path.join(src_dir, pattern))
1557+
assert matches, "no headers found to install in %s" % src_dir
1558+
for f in matches:
1559+
logger.debug('installing: ' + os.path.join(dest, os.path.basename(f)))
15581560
shutil.copyfile(f, os.path.join(dest, os.path.basename(f)))
15591561

15601562
@staticmethod

0 commit comments

Comments
 (0)