Skip to content

Commit

Permalink
fix: fix some more web build errors
Browse files Browse the repository at this point in the history
patch fmt so that it can be compiled with emscripten
  • Loading branch information
Totto16 committed Nov 15, 2024
1 parent e37d5f2 commit df00493
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
22 changes: 11 additions & 11 deletions platforms/build-web.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ embuilder build sdl2 harfbuzz freetype zlib sdl2_ttf vorbis mpg123 ogg libmodplu

export EMSCRIPTEN_SYS_ROOT="$EMSCRIPTEN_ROOT/upstream/emscripten/cache/sysroot"

export BUILD_DIR="build-emcc"
export BUILD_DIR="build-web"

export CC="emcc"
export CXX="em++"
Expand All @@ -36,11 +36,13 @@ export ARCH="wasm32"
export CPU_ARCH="wasm32"
export ENDIANESS="little"

export COMMON_EMSCRIPTEN_OPTIONS="'-fexceptions', '-sEXCEPTION_CATCHING_ALLOWED=[..]'"
export PACKAGE_FLAGS="'-sUSE_SDL=2', '--use-port=sdl2'"

export COMMON_FLAGS="'-fexceptions', '-sEXCEPTION_CATCHING_ALLOWED=[..]', $PACKAGE_FLAGS"

# 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
export LINK_EMSCRIPTEN_OPTIONS="$COMMON_EMSCRIPTEN_OPTIONS, '-sEXPORT_ALL=1', '-sUSE_GLFW=3', '-sUSE_WEBGPU=1', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sNO_EXIT_RUNTIME=0', '-sASSERTIONS=1'"
export COMPILE_EMSCRIPTEN_OPTIONS="$COMMON_EMSCRIPTEN_OPTIONS , '-sUSE_SDL=2'"
export LINK_FLAGS="$COMMON_FLAGS, '-sEXPORT_ALL=1', '-sUSE_WEBGPU=1', '-sWASM=1', '-sALLOW_MEMORY_GROWTH=1', '-sNO_EXIT_RUNTIME=0', '-sASSERTIONS=1'"
export COMPILE_FLAGS="$COMMON_FLAGS ,'-DAUDIO_PREFER_MP3'"

export CROSS_FILE="./platforms/crossbuild-web.ini"

Expand Down Expand Up @@ -77,10 +79,10 @@ exe_wrapper = '$EMSDK_NODE'
[built-in options]
c_std = 'c11'
cpp_std = 'c++23'
c_args = [$COMPILE_EMSCRIPTEN_OPTIONS]
c_link_args = [$LINK_EMSCRIPTEN_OPTIONS]
cpp_args = [$COMPILE_EMSCRIPTEN_OPTIONS]
cpp_link_args = [$LINK_EMSCRIPTEN_OPTIONS]
c_args = [$COMPILE_FLAGS]
cpp_args = [$COMPILE_FLAGS]
c_link_args = [$LINK_FLAGS]
cpp_link_args = [$LINK_FLAGS]
[properties]
needs_exe_wrapper = true
Expand Down Expand Up @@ -122,9 +124,7 @@ if [ "$COMPILE_TYPE" == "complete_rebuild" ] || [ ! -e "$BUILD_DIR" ]; then
"--wipe" \
--cross-file "$CROSS_FILE" \
"-Dbuildtype=$BUILDTYPE" \
-Dcpp_args=-DAUDIO_PREFER_MP3 \
-Ddefault_library=static \
-Dfreetype2:zlib=disabled # TODI, since it's statically linked no duplicates are allowed, solve that
-Ddefault_library=static

fi

Expand Down
2 changes: 1 addition & 1 deletion subprojects/fmt.wrap
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ patch_url = https://wrapdb.mesonbuild.com/v2/fmt_11.0.2-1/get_patch
patch_hash = 90c9e3b8e8f29713d40ca949f6f93ad115d78d7fb921064112bc6179e6427c5e
source_fallback_url = https://github.com/mesonbuild/wrapdb/releases/download/fmt_11.0.2-1/fmt-11.0.2.tar.gz
wrapdb_version = 11.0.2-1
diff_files = fmt_dependency_override.diff
diff_files = fmt_dependency_override.diff, fmt_emscripten.diff

[provide]
fmt = fmt_dep
Expand Down
13 changes: 13 additions & 0 deletions subprojects/packagefiles/fmt_emscripten.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/include/fmt/base.h b/include/fmt/base.h
index 6276494..869e075 100644
--- a/include/fmt/base.h
+++ b/include/fmt/base.h
@@ -113,6 +113,8 @@
// Detect consteval, C++20 constexpr extensions and std::is_constant_evaluated.
#if !defined(__cpp_lib_is_constant_evaluated)
# define FMT_USE_CONSTEVAL 0
+#elif defined(__EMSCRIPTEN__)
+# define FMT_USE_CONSTEVAL 0
#elif FMT_CPLUSPLUS < 201709L
# define FMT_USE_CONSTEVAL 0
#elif FMT_GLIBCXX_RELEASE && FMT_GLIBCXX_RELEASE < 10

0 comments on commit df00493

Please sign in to comment.