Commit 7d80e20883666b1bb2c710d63e166878b5492447

Sam Clegg 2023-07-05T13:52:37

emscripten: Add JS library dependencies using EM_JS_DEPS macro See https://github.com/emscripten-core/emscripten/pull/19780 (cherry picked from commit 042243471fb7ecf6ba5e53f0ba35e825a8bb066a)

diff --git a/.github/workflows/emscripten.yml b/.github/workflows/emscripten.yml
index b32410a..5603e20 100644
--- a/.github/workflows/emscripten.yml
+++ b/.github/workflows/emscripten.yml
@@ -9,7 +9,7 @@ jobs:
       - uses: actions/checkout@v3
       - uses: mymindstorm/setup-emsdk@v12
         with:
-          version: 2.0.32
+          version: 3.1.35
       - name: Install ninja
         run: |
           sudo apt-get -y update
diff --git a/docs/README-emscripten.md b/docs/README-emscripten.md
index 5f8c277..147e18d 100644
--- a/docs/README-emscripten.md
+++ b/docs/README-emscripten.md
@@ -38,7 +38,7 @@ for some Javascript code to steal for this approach.
 
 ## Building SDL/emscripten
 
-SDL currently requires at least Emscripten 2.0.32 to build. Newer versions
+SDL currently requires at least Emscripten 3.1.35 to build. Newer versions
 are likely to work, as well.
 
 
diff --git a/src/audio/emscripten/SDL_emscriptenaudio.c b/src/audio/emscripten/SDL_emscriptenaudio.c
index af5f095..341c9df 100644
--- a/src/audio/emscripten/SDL_emscriptenaudio.c
+++ b/src/audio/emscripten/SDL_emscriptenaudio.c
@@ -197,6 +197,8 @@ static void EMSCRIPTENAUDIO_CloseDevice(_THIS)
 #endif
 }
 
+EM_JS_DEPS(sdlaudio, "$autoResumeAudioContext,$dynCall");
+
 static int EMSCRIPTENAUDIO_OpenDevice(_THIS, const char *devname)
 {
     SDL_AudioFormat test_format;
diff --git a/src/misc/emscripten/SDL_sysurl.c b/src/misc/emscripten/SDL_sysurl.c
index 12cb156..1d707fc 100644
--- a/src/misc/emscripten/SDL_sysurl.c
+++ b/src/misc/emscripten/SDL_sysurl.c
@@ -23,13 +23,11 @@
 
 #include <emscripten/emscripten.h>
 
+EM_JS_DEPS(sdlsysurl, "$UTF8ToString");
+
 int SDL_SYS_OpenURL(const char *url)
 {
-    EM_ASM({
-        window.open(UTF8ToString($0), "_blank");
-    },
-           url);
-
+    EM_ASM(window.open(UTF8ToString($0), "_blank"), url);
     return 0;
 }
 
diff --git a/src/video/emscripten/SDL_emscriptenmouse.c b/src/video/emscripten/SDL_emscriptenmouse.c
index 822995c..7dea22b 100644
--- a/src/video/emscripten/SDL_emscriptenmouse.c
+++ b/src/video/emscripten/SDL_emscriptenmouse.c
@@ -60,6 +60,8 @@ static SDL_Cursor *Emscripten_CreateDefaultCursor()
     return Emscripten_CreateCursorFromString("default", SDL_FALSE);
 }
 
+EM_JS_DEPS(sdlmouse, "$stringToUTF8,$UTF8ToString");
+
 static SDL_Cursor *Emscripten_CreateCursor(SDL_Surface *surface, int hot_x, int hot_y)
 {
     const char *cursor_url = NULL;