Skip to content

Commit 42fdf76

Browse files
committed
fix: fix a few more emscripten things
1 parent 8900695 commit 42fdf76

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

platforms/build-web.sh

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,12 +36,14 @@ export ARCH="wasm32"
3636
export CPU_ARCH="wasm32"
3737
export ENDIANESS="little"
3838

39-
export PACKAGE_FLAGS="'--use-port=sdl2', '--use-port=harfbuzz', '--use-port=freetype', '--use-port=zlib', '--use-port=sdl2_ttf', '--use-port=vorbis', '--use-port=mpg123', '--use-port=ogg', '--use-port=libmodplug', '--use-port=sdl2_mixer', '--use-port=libpng', '--use-port=libjpeg', '--use-port=sdl2_image', '-s SDL2_IMAGE_FORMATS=[\"png\",\"jpg\",\"svg\"]','--use-port=icu'"
39+
export ROMFS="platforms/romfs"
4040

41-
export COMMON_FLAGS="'-fexceptions', '-sEXCEPTION_CATCHING_ALLOWED=[..]', $PACKAGE_FLAGS"
41+
export PACKAGE_FLAGS="'--use-port=sdl2', '--use-port=harfbuzz', '--use-port=freetype', '--use-port=zlib', '--use-port=sdl2_ttf', '--use-port=vorbis', '--use-port=mpg123', '--use-port=ogg', '--use-port=libmodplug', '--use-port=sdl2_mixer', '-sSDL2_MIXER_FORMATS=[\"ogg\",\"mp3\",\" mod\"]','--use-port=libpng', '--use-port=libjpeg', '--use-port=sdl2_image', '-sSDL2_IMAGE_FORMATS=[\"png\",\"jpg\",\"svg\"]','--use-port=icu'"
42+
43+
export COMMON_FLAGS="'-fexceptions', '-pthread', '-sEXCEPTION_CATCHING_ALLOWED=[..]', $PACKAGE_FLAGS"
4244

4345
# TODO see if ALLOW_MEMORY_GROWTH is needed, but if we load ttf's and music it likely is and we don't have to debug OOm crahses, that aren't handled by some thrid party library, which is painful
44-
export LINK_FLAGS="$COMMON_FLAGS, '-sEXPORT_ALL=1', '-sUSE_WEBGPU=1', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sNO_EXIT_RUNTIME=0', '-sASSERTIONS=1','-sERROR_ON_UNDEFINED_SYMBOLS=1', '-sFETCH=1'"
46+
export LINK_FLAGS="$COMMON_FLAGS, '-sEXPORT_ALL=1', '-sUSE_WEBGPU=1', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sASSERTIONS=1','-sERROR_ON_UNDEFINED_SYMBOLS=1', '-sFETCH=1'"
4547
export COMPILE_FLAGS="$COMMON_FLAGS ,'-DAUDIO_PREFER_MP3'"
4648

4749
export CROSS_FILE="./platforms/crossbuild-web.ini"
@@ -88,6 +90,7 @@ cpp_link_args = [$LINK_FLAGS]
8890
needs_exe_wrapper = true
8991
sys_root = '$EMSCRIPTEN_SYS_ROOT'
9092
93+
APP_ROMFS='$ROMFS'
9194
9295
EOF
9396

@@ -118,6 +121,14 @@ else
118121
exit 1
119122
fi
120123

124+
if [ ! -d "$ROMFS" ]; then
125+
126+
mkdir -p "$ROMFS"
127+
128+
cp -r assets "$ROMFS/"
129+
130+
fi
131+
121132
if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then
122133

123134
meson setup "$BUILD_DIR" \

src/executables/meson.build

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,30 @@ if build_application
3333
]
3434
subdir('platforms/3ds')
3535
elif host_machine.system() == 'emscripten'
36+
emscripten_link_args = []
37+
38+
APP_ROMFS = meson.get_external_property('APP_ROMFS', '')
39+
40+
if APP_ROMFS != ''
41+
42+
fs = import('fs')
43+
44+
if not fs.is_absolute(APP_ROMFS)
45+
APP_ROMFS = meson.project_source_root() / APP_ROMFS
46+
endif
47+
48+
if not fs.exists(APP_ROMFS)
49+
error('APP_ROMFS should exist, but doesn\'t: \'' + APP_ROMFS + '\'')
50+
endif
51+
52+
emscripten_link_args += ['--preload-file', APP_ROMFS+'@/assets/']
53+
54+
endif
55+
56+
3657
emscripten_name = 'oopetris'
3758
emscripten_deps = [liboopetris_graphics_dep, graphic_application_deps]
38-
emscripten_link_args = ['--preload-file', '../assets@/assets/']
59+
3960
emscripten_options = {
4061
'warning_level': '3',
4162
'werror': true,

src/helper/web_utils.hpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44

55

66
#if !defined(__EMSCRIPTEN__)
7-
#error this header is for emscripten only
7+
#error "this header is for emscripten only"
8+
#endif
9+
10+
#if !defined(__EMSCRIPTEN_PTHREADS__)
11+
#error "need emscripten threads support"
812
#endif
913

1014

0 commit comments

Comments
 (0)