From 5e6a851d6cb47afb780a470dc1ab08c6bdd31b15 Mon Sep 17 00:00:00 2001 From: "Ryan C. Gordon" Date: Sat, 9 Sep 2023 09:58:50 -0400 Subject: [PATCH] docs: Fixed some Emscripten details --- docs/README-emscripten.md | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/docs/README-emscripten.md b/docs/README-emscripten.md index 54a1b8818..3e7359ced 100644 --- a/docs/README-emscripten.md +++ b/docs/README-emscripten.md @@ -223,12 +223,12 @@ If you aren't developing SDL itself, have a desire to mess with its source code, or need something on the bleeding edge, don't build SDL. Just use Emscripten's packaged version! -Compile and link your app with `-s USE_SDL=2` and it'll use a build of +Compile and link your app with `-sUSE_SDL=2` and it'll use a build of SDL packaged with Emscripten. This comes from the same source code and fixes the Emscripten project makes to SDL are generally merged into SDL's revision control, so often this is much easier for app developers. -`-s USE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL +`-sUSE_SDL=1` will select Emscripten's JavaScript reimplementation of SDL 1.2 instead; if you need SDL 1.2, this might be fine, but we generally recommend you don't use SDL 1.2 in modern times. @@ -253,14 +253,14 @@ tools. cd SDL mkdir build cd build -emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-s USE_SDL=0 -O3" +emconfigure ../configure --host=wasm32-unknown-emscripten --disable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3" emmake make -j4 ``` If you want to build with thread support, something like this works: ```bash -emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-s USE_SDL=0 -O3 -pthread" LDFLAGS="-pthread" +emconfigure ../configure --host=wasm32-unknown-emscripten --enable-pthreads --disable-assembly --disable-cpuinfo CFLAGS="-sUSE_SDL=0 -O3 -pthread" LDFLAGS="-pthread" ``` Or with cmake: @@ -285,7 +285,7 @@ You need to compile with `emcc` instead of `gcc` or `clang` or whatever, but mostly it uses the same command line arguments as Clang. Link against the SDL/build/.libs/libSDL2.a file you generated by building SDL, -link with `-s USE_SDL=2` to use Emscripten's prepackaged SDL2 build. +link with `-sUSE_SDL=2` to use Emscripten's prepackaged SDL2 build. Usually you would produce a binary like this: @@ -296,7 +296,7 @@ gcc -o mygame mygame.c # or whatever But for Emscripten, you want to output something else: ```bash -gcc -o index.html mygame.c # or whatever +emcc -o index.html mygame.c ``` This will produce several files...support Javascript and WebAssembly (.wasm) @@ -305,8 +305,8 @@ runs your app. You will (probably) eventually want to replace or customize that file and do `-o index.js` instead to just build the code pieces. If you're working on a program of any serious size, you'll likely need to -link with `-s ALLOW_MEMORY_GROWTH=1 -s MAXIMUM_MEMORY=1gb` to get access -to more memory. If using pthreads, you'll need the `-s MAXIMUM_MEMORY=1gb` +link with `-sALLOW_MEMORY_GROWTH=1 -sMAXIMUM_MEMORY=1gb` to get access +to more memory. If using pthreads, you'll need the `-sMAXIMUM_MEMORY=1gb` or the app will fail to start on iOS browsers, but this might be a bug that goes away in the future.