@@ -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'
9086
9187pg_inc_dirs = []
9288pg_lib_dirs = []
89+
90+ if plat == ' emscripten-pygbag'
91+ sdl_dep = declare_dependency (
92+ link_args : [' -lSDL2' ],
93+ )
94+ sdl_image_dep = declare_dependency (
95+ link_args : [' -lSDL2_image' ],
96+ )
97+ sdl_mixer_dep = declare_dependency (
98+ link_args : [' -lSDL2_mixer_ogg' , ' -logg' , ' -lvorbis' ],
99+ )
100+ freetype_dep = declare_dependency (
101+ link_args : [' -lfreetype' , ' -lharfbuzz' ]
102+ )
103+ sdl_ttf_dep = declare_dependency (
104+ link_args : [' -lSDL2_ttf' ],
105+ dependencies : [freetype_dep]
106+ )
107+ elif plat == ' emscripten-generic'
108+ # Check out before-build attribute in [tool.cibuildwheel.pyodide] section
109+ # of pyproject.toml to see how these dependencies were installed.
110+ wasm_exceptions = [' -fwasm-exceptions' , ' -sSUPPORT_LONGJMP=wasm' ]
111+ add_global_arguments (wasm_exceptions, language : ' c' )
112+ add_global_link_arguments (wasm_exceptions, language : ' c' )
113+
114+ sdl_flags = [' -sUSE_SDL=2' ]
115+ freetype_flags = [' -sUSE_FREETYPE=1' ]
116+ sdl_dep = declare_dependency (
117+ compile_args : sdl_flags,
118+ link_args : sdl_flags + [' -lSDL2' , ' -lhtml5' ],
119+ )
120+ # TODO: add png
121+ sdl_image_dep = declare_dependency (
122+ link_args : [' -lSDL2_image-bmp-gif-jpg-qoi-svg-tga' , ' -ljpeg' ],
123+ )
124+ sdl_mixer_dep = declare_dependency (
125+ link_args : [' -lSDL2_mixer-mid-mod-mp3-ogg' , ' -lmodplug' , ' -lmpg123' , ' -logg' , ' -lvorbis' ],
126+ )
127+ freetype_dep = declare_dependency (
128+ compile_args : freetype_flags,
129+ link_args : freetype_flags + [' -lfreetype-legacysjlj' , ' -lharfbuzz' ]
130+ )
131+ sdl_ttf_dep = declare_dependency (
132+ link_args : [' -lSDL2_ttf' ],
133+ dependencies : [freetype_dep]
134+ )
135+ else
136+
93137if plat == ' win' and host_machine .cpu_family().startswith(' x86' )
94138 # yes, this is a bit ugly and hardcoded but it is what it is
95139 # TODO (middle-term goal) - Should migrate away from this
@@ -311,8 +355,10 @@ if not freetype_dep.found()
311355 )
312356endif
313357
358+ endif # emscripten
359+
314360portmidi_dep = dependency (' portmidi' , required : false )
315- if not portmidi_dep.found()
361+ if not portmidi_dep.found() and not plat.startswith( ' emscripten ' )
316362 portmidi_dep = declare_dependency (
317363 include_directories : pg_inc_dirs,
318364 dependencies : cc.find_library (
@@ -436,7 +482,7 @@ endif
436482subdir (' src_c' )
437483subdir (' src_py' )
438484
439- if not get_option (' stripped' )
485+ if not get_option (' stripped' ) and not plat.startswith( ' emscripten ' )
440486 # run make_docs and make docs
441487 if not fs.is_dir(' docs/generated' )
442488 make_docs = files (' buildconfig/make_docs.py' )
0 commit comments