@@ -34,11 +34,7 @@ elif host_machine.system() == 'android'
3434 ' However it may be added in the future' ,
3535 )
3636elif host_machine .system() == ' emscripten'
37- plat = ' emscripten'
38- error (
39- ' The meson buildconfig of pygame-ce does not support emscripten for now. ' ,
40- ' However it may be added in the future' ,
41- )
37+ plat = ' emscripten-@0@' .format(get_option (' emscripten_type' ))
4238else
4339 # here it one of: cygwin, dragonfly, freebsd, gnu, haiku, netbsd, openbsd, sunos
4440 plat = ' unix'
@@ -80,7 +76,7 @@ pg_dir = py.get_install_dir() / pg
8076
8177sdl_api = get_option (' sdl_api' )
8278sdl = ' SDL@0@' .format(sdl_api)
83- sdl_mixer = ' @0@_mixer' .format(sdl)
79+ sdl_mixer = (plat == ' emscripten-pygbag ' ) ? ' @0@_mixer_ogg ' .format(sdl) : ' @0@_mixer' .format(sdl)
8480sdl_ttf = ' @0@_ttf' .format(sdl)
8581sdl_image = ' @0@_image' .format(sdl)
8682
@@ -229,7 +225,20 @@ if plat == 'win' and host_machine.cpu_family().startswith('x86')
229225 install_data (dlls, install_dir : pg_dir, install_tag : ' pg-tag' )
230226
231227else
232- bases = [' /usr/local' , ' /usr' , ' /opt/homebrew' , ' /opt/local' ]
228+ if plat == ' emscripten-pygbag'
229+ bases = [
230+ ' /opt/python-wasm-sdk/emsdk/upstream/emscripten/cache/sysroot' ,
231+ ' /opt/python-wasm-sdk/devices/emsdk/usr'
232+ ]
233+ add_global_arguments ([' -DBUILD_STATIC' ], language : ' c' )
234+ elif plat == ' emscripten-generic'
235+ # TODO: check if these bases are valid in pyodide
236+ bases = [' /usr/local' , ' /usr' , ' /opt/local' ]
237+ add_global_arguments ([' -DBUILD_STATIC' ], language : ' c' )
238+ else
239+ bases = [' /usr/local' , ' /usr' , ' /opt/homebrew' , ' /opt/local' ]
240+ endif
241+
233242 foreach inc_dir : bases
234243 foreach sub_inc : [
235244 '' ,
244253 endforeach
245254
246255 foreach lib_dir : bases
247- foreach sub_lib : [' lib' , ' lib64' ]
256+ foreach sub_lib : [' lib' , ' lib64' , ' lib/wasm32-emscripten/pic ' , ' lib/wasm32-emscripten ' ]
248257 full_lib = lib_dir / sub_lib
249258 if fs.exists(full_lib)
250259 pg_lib_dirs += full_lib
@@ -312,7 +321,7 @@ if not freetype_dep.found()
312321endif
313322
314323portmidi_dep = dependency (' portmidi' , required : false )
315- if not portmidi_dep.found()
324+ if not portmidi_dep.found() and not plat.startswith( ' emscripten ' )
316325 portmidi_dep = declare_dependency (
317326 include_directories : pg_inc_dirs,
318327 dependencies : cc.find_library (
@@ -436,7 +445,7 @@ endif
436445subdir (' src_c' )
437446subdir (' src_py' )
438447
439- if not get_option (' stripped' )
448+ if not get_option (' stripped' ) and not plat.startswith( ' emscripten ' )
440449 # run make_docs and make docs
441450 if not fs.is_dir(' docs/generated' )
442451 make_docs = files (' buildconfig/make_docs.py' )
0 commit comments