Skip to content

Commit 9960e34

Browse files
committed
Remove problematic C functions from Pyodide builds
1 parent dd62976 commit 9960e34

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

‎build_sdl.py‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def python_machine() -> str:
6666
# Padding values need to be scrubbed.
6767
RE_PADDING = re.compile(r"padding\[[^;]*\];")
6868

69+
# Printf style functions cause issues on Pyodide builds
70+
RE_PRINTF = re.compile(r"^.*\*fmt, \.\.\.\).*;$", re.MULTILINE)
71+
6972
# These structs have an unusual size when packed by SDL on 32-bit platforms.
7073
FLEXIBLE_STRUCTS = (
7174
"SDL_CommonEvent",
@@ -378,6 +381,9 @@ def get_cdef() -> tuple[str, dict[str, str]]:
378381
)
379382
sdl_cdef = parser.get_output()
380383

384+
if "PYODIDE" in os.environ:
385+
sdl_cdef = RE_PRINTF.sub("", sdl_cdef)
386+
381387
sdl_cdef = sdl_cdef.replace("_Bool", "bool")
382388
sdl_cdef = RE_VAFUNC.sub("", sdl_cdef)
383389
sdl_cdef = RE_INLINE.sub("", sdl_cdef)

0 commit comments

Comments
 (0)