summaryrefslogtreecommitdiffstats
path: root/mkspecs/wasm-emscripten
diff options
context:
space:
mode:
authorMorten Sørvig <morten.sorvig@qt.io>2021-05-21 11:14:34 +0200
committerMorten Johan Sørvig <morten.sorvig@qt.io>2021-06-22 11:11:20 +0000
commit7ee4468a18f18dd2269fc422220fea4dc77017c7 (patch)
tree776251da15851e28841a3c53262e974c898d84cf /mkspecs/wasm-emscripten
parenta97445274ab94e38f457a0d874ec64aa0da60846 (diff)
wasm: enable MODULARIZE option and set EXPORT_NAME
Make Emscripten generate a global constructor function ("createQtAppInstance()") instead of a global javascript module object. This enables more fine-grained control over module instantiation; previously the module object would be created when the runtime javascript was evaluated, and the number of emscripten module/instances was limited to one per page. Set EXPORT_NAME to “createQtAppInstance” which avoids collisions with other non-Qt Emscripten modules on the same page. A further improvement would be to include the app name in EXPORT_NAME, but this is not done at this time. Update the code in qtloader.js to call the constructor function instead of working on a global module object. The qtloader.js API is functional before the wasm and Emscripten modules have been instantiated; store properties and forward to the Emscripten module when it's created. Change-Id: I12c49a5b9a4a932bbc46fcc5e5ecc453fd0fe7f0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Diffstat (limited to 'mkspecs/wasm-emscripten')
-rw-r--r--mkspecs/wasm-emscripten/qmake.conf4
1 files changed, 3 insertions, 1 deletions
diff --git a/mkspecs/wasm-emscripten/qmake.conf b/mkspecs/wasm-emscripten/qmake.conf
index ad66ff3982..cc3bc8064e 100644
--- a/mkspecs/wasm-emscripten/qmake.conf
+++ b/mkspecs/wasm-emscripten/qmake.conf
@@ -41,7 +41,9 @@ EMCC_COMMON_LFLAGS += \
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
-s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] \
--bind \
- -s FETCH=1
+ -s FETCH=1 \
+ -s MODULARIZE=1 \
+ -s EXPORT_NAME=createQtAppInstance
# The -s arguments can also be used with release builds,
# but are here in debug for clarity.