From 7ee4468a18f18dd2269fc422220fea4dc77017c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Morten=20S=C3=B8rvig?= Date: Fri, 21 May 2021 11:14:34 +0200 Subject: wasm: enable MODULARIZE option and set EXPORT_NAME MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- mkspecs/wasm-emscripten/qmake.conf | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'mkspecs') 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. -- cgit v1.2.3