From 7cc3fc138c54e4b06e6d8b52d6c082e602ed2fce Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 21:00:53 +0300 Subject: [PATCH] Add the modularization option --- Makefile.emscripten | 1 + src/dist/Makefile.emscripten | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/Makefile.emscripten b/Makefile.emscripten index fb77ee3839..b1dd96469a 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -22,6 +22,7 @@ # # FHEROES2_STRICT_COMPILATION: build in strict compilation mode (turns warnings into errors) # FHEROES2_WITH_DEBUG: build in debug mode +# FHEROES2_WITH_MODULARIZE: wrap the emitted JS code in a function that returns a promise # FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2) .PHONY: all clean translations diff --git a/src/dist/Makefile.emscripten b/src/dist/Makefile.emscripten index 8010a5fbab..c5aac50d11 100644 --- a/src/dist/Makefile.emscripten +++ b/src/dist/Makefile.emscripten @@ -43,3 +43,10 @@ ifdef FHEROES2_WITH_DEBUG CCFLAGS := $(CCFLAGS) -gsource-map LDFLAGS := $(LDFLAGS) -gsource-map endif + +ifdef FHEROES2_WITH_MODULARIZE +LDFLAGS := $(LDFLAGS) \ + -sMODULARIZE \ + -sEXPORTED_RUNTIME_METHODS=FS,ENV,noExitRuntime,addOnExit,run \ + -sEXPORT_NAME=fheroes2 +endif