Skip to content

Commit

Permalink
fix: fix web build
Browse files Browse the repository at this point in the history
after an upstream patch the local patch files needed to be adjusted
  • Loading branch information
Totto16 committed Dec 18, 2024
1 parent 2c4f439 commit 2df01bd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 20 deletions.
1 change: 1 addition & 0 deletions platforms/build-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ if ! [ -e "$EMSCRIPTEN_PACTH_FILE" ]; then
##TODO: upstream those patches
# see: https://github.com/emscripten-core/emscripten/pull/18379/commits
# and: https://github.com/emscripten-core/emscripten/pull/18379
# and: https://github.com/emscripten-core/emscripten/pull/22946

git apply --unsafe-paths -p1 --directory="$EMSCRIPTEN_UPSTREAM_ROOT" "$PATCH_DIR/sdl2_image_port.diff"
git apply --unsafe-paths -p1 --directory="$EMSCRIPTEN_UPSTREAM_ROOT" "$PATCH_DIR/sdl2_mixer_port.diff"
Expand Down
38 changes: 18 additions & 20 deletions platforms/emscripten/sdl2_image_port.diff
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
diff --git a/tools/ports/sdl2_image.py b/tools/ports/sdl2_image.py
index c72ef576..0c12feba 100644
index 70fa1499..36be807b 100644
--- a/tools/ports/sdl2_image.py
+++ b/tools/ports/sdl2_image.py
@@ -16,15 +16,17 @@ variants = {
@@ -18,7 +18,8 @@ variants = {
}

OPTIONS = {
Expand All @@ -12,46 +12,44 @@ index c72ef576..0c12feba 100644
}

SUPPORTED_FORMATS = {'avif', 'bmp', 'gif', 'jpg', 'jxl', 'lbm', 'pcx', 'png',
'pnm', 'qoi', 'svg', 'tga', 'tif', 'webp', 'xcf', 'xpm', 'xv'}
@@ -26,7 +27,8 @@ SUPPORTED_FORMATS = {'avif', 'bmp', 'gif', 'jpg', 'jxl', 'lbm', 'pcx', 'png',

# user options (from --use-port)
-opts: Dict[str, Set] = {
opts: Dict[str, Set] = {
- 'formats': set()
+opts = {
+ 'formats': set(),
+ 'mt': 0
}


@@ -42,7 +44,7 @@ def get_lib_name(settings):
@@ -44,7 +46,7 @@ def get_lib_name(settings):
libname = 'libSDL2_image'
if formats != '':
libname += '_' + formats
- return libname + '.a'
+ return libname + ('-mt' if opts['mt'] else '') + '.a'


def get(ports, settings, shared):
@@ -70,6 +72,8 @@ def get(ports, settings, shared):
libname += '-' + formats
- if settings.PTHREADS:
+ if settings.PTHREADS or opts['mt']:
libname += '-mt'
return libname + '.a'

@@ -75,7 +77,7 @@ def get(ports, settings, shared):
if 'jpg' in formats:
defs += ['-sUSE_LIBJPEG']
+ if opts['mt']:
+ defs += ['-pthread']
flags += ['-sUSE_LIBJPEG']

ports.build_port(src_dir, final, 'sdl2_image', flags=defs, srcs=srcs)
- if settings.PTHREADS:
+ if settings.PTHREADS or opts['mt']:
flags += ['-pthread']

@@ -99,7 +103,12 @@ def handle_options(options, error_handler):
ports.build_port(src_dir, final, 'sdl2_image', flags=flags, srcs=srcs)
@@ -106,6 +108,12 @@ def handle_options(options, error_handler):
error_handler(f'{format} is not a supported format')
else:
opts['formats'].add(format)
-
+
+ mt = options['mt']
+ if mt not in ["1","0"]:
+ error_handler(f'{mt} has to be either 0 or 1')
+ else:
+ opts['mt'] = int(mt)


def show():
return 'sdl2_image (-sUSE_SDL_IMAGE=2 or --use-port=sdl2_image; zlib license)'

0 comments on commit 2df01bd

Please sign in to comment.