From 4ea4f3be957e1b5ecfda9e4709392ae9e5aa88be Mon Sep 17 00:00:00 2001 From: cutealien Date: Sat, 18 Aug 2018 19:50:51 +0000 Subject: [PATCH] Make it easier to enable support for compiling emscripten to wasm. Add some documentation. git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/branches/ogl-es@5638 dfc29bdd-3216-0410-991c-e03cc46cb475 --- examples/01.HelloWorld_emscripten/Makefile | 11 +++++++++++ examples/01.HelloWorld_emscripten/readme.txt | 2 ++ source/Irrlicht/Makefile | 3 +++ 3 files changed, 16 insertions(+) diff --git a/examples/01.HelloWorld_emscripten/Makefile b/examples/01.HelloWorld_emscripten/Makefile index 1a90d83b..f60a678e 100644 --- a/examples/01.HelloWorld_emscripten/Makefile +++ b/examples/01.HelloWorld_emscripten/Makefile @@ -48,7 +48,11 @@ all_win32 clean_win32 static_win32: SYSTEM=Win32-gcc all_win32 clean_win32 static_win32: SUF=.exe all_emscripten clean_emscripten: SUF=.html all_emscripten: CXXFLAGS += -fno-exceptions -fno-rtti -fstrict-aliasing -std=gnu++11 -U__STRICT_ANSI__ +# Pass on a custom html file. +#all_emscripten: CXXFLAGS += --shell-file shell_minimal.html all_emscripten: LDFLAGS += -lGL -lSDL --preload-file ../../media@/media -s ALLOW_MEMORY_GROWTH=1 -s NO_EXIT_RUNTIME=1 +#If you know the maximum memory (in bytes) which your application need then set it. It can speed things up a lot. +#all_emscripten: LDFLAGS += -s TOTAL_MEMORY=268435456 # You need the FULL_ES2 when using EDT_OGLES2 driver #all_emscripten: LDFLAGS += -s FULL_ES2=1 static_win32: CPPFLAGS += -D_IRR_STATIC_LIB_ @@ -57,6 +61,13 @@ static_win32: LDFLAGS += -lgdi32 -lwinspool -lcomdlg32 -lole32 -loleaut32 -luuid # name of the binary - only valid for targets which set SYSTEM DESTPATH = $(BinPath)/$(Target)$(SUF) +# Enable compiling to WASM and not just asm.js (you have to set it in the engine Makefile as well) +ifdef EMSCRIPTEN + ifdef WASM + CXXFLAGS += -s WASM=1 + endif +endif + emscripten: all_emscripten all_linux all_win32 all_emscripten static_win32: diff --git a/examples/01.HelloWorld_emscripten/readme.txt b/examples/01.HelloWorld_emscripten/readme.txt index b12bb328..e1cfb5b2 100644 --- a/examples/01.HelloWorld_emscripten/readme.txt +++ b/examples/01.HelloWorld_emscripten/readme.txt @@ -20,3 +20,5 @@ emmake make emscripten Go into examples/01.HelloWord_emscripten folder and call: emmake make all_emscripten + +Note: The shell_minimal.html is currently not used (as resizing isn't working yet correctly), but can be enabled in the Makefile. diff --git a/source/Irrlicht/Makefile b/source/Irrlicht/Makefile index 2979f3f9..b63bdfe8 100644 --- a/source/Irrlicht/Makefile +++ b/source/Irrlicht/Makefile @@ -90,6 +90,9 @@ ifdef EMSCRIPTEN else CFLAGS := -O3 -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES endif + ifdef WASM + CXXFLAGS += -s WASM=1 + endif else CFLAGS := -O3 -fexpensive-optimizations -DPNG_THREAD_UNSAFE_OK -DPNG_NO_MMX_CODE -DPNG_NO_MNG_FEATURES endif