diff options
Diffstat (limited to 'mkspecs/features/wasm/wasm.prf')
-rw-r--r-- | mkspecs/features/wasm/wasm.prf | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 13ac43443d..25413d7470 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -2,6 +2,43 @@ # DESTDIR will be empty if not set in the app .pro file; make sure it has a value isEmpty(DESTDIR): DESTDIR = $$OUT_PWD +exists($$QMAKE_QT_CONFIG) { + qtConfig(thread) { + + EMCC_THREAD_LFLAGS += -s USE_PTHREADS=1 + + # Create worker threads at startup. This is supposed to be an optimization, + # however exceeding the pool size has been obesverved to hang the application. + POOL_SIZE = 4 + !isEmpty(QMAKE_WASM_PTHREAD_POOL_SIZE) { + POOL_SIZE = $$QMAKE_WASM_PTHREAD_POOL_SIZE + } + + message("Setting PTHREAD_POOL_SIZE to" $$POOL_SIZE) + EMCC_THREAD_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE + } else { + EMCC_THREAD_LFLAGS += -s ALLOW_MEMORY_GROWTH=1 + } + + qtConfig(thread) | !isEmpty(QMAKE_WASM_TOTAL_MEMORY) { + + # Hardcode wasm memory size. Emscripten does not currently support memory growth + # (ALLOW_MEMORY_GROWTH) in pthreads mode, and requires specifying the memory size + # at build time. Further, browsers limit the maximum initial memory size to 1GB. + # QMAKE_WASM_TOTAL_MEMORY must be a multiple of 64KB + TOTAL_MEMORY = 1GB + !isEmpty(QMAKE_WASM_TOTAL_MEMORY) { + TOTAL_MEMORY = $$QMAKE_WASM_TOTAL_MEMORY + } + message("Setting TOTAL_MEMORY to" $$TOTAL_MEMORY) + EMCC_THREAD_LFLAGS += -s TOTAL_MEMORY=$$TOTAL_MEMORY + } + QMAKE_LFLAGS += $$EMCC_THREAD_LFLAGS + QMAKE_LFLAGS_DEBUG += $$EMCC_THREAD_LFLAGS + QMAKE_CFLAGS += $$EMCC_THREAD_LFLAGS + QMAKE_CXXFLAGS += $$EMCC_THREAD_LFLAGS +} + # Create js and wasm files for applications contains(TEMPLATE, .*app) { TARGET_BASE = $${TARGET} @@ -34,7 +71,7 @@ contains(TEMPLATE, .*app) { # replacing the app name placeholder with the actual app name. apphtml.name = application main html file apphtml.output = $$DESTDIR/$$TARGET_HTML - apphtml.commands = sed -e s/APPNAME/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML + apphtml.commands = sed -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML apphtml.input = $$WASM_PLUGIN_PATH/wasm_shell.html apphtml.depends = $$apphtml.input QMAKE_EXTRA_COMPILERS += apphtml @@ -72,6 +109,13 @@ contains(TEMPLATE, .*app) { } } +# Pass --source-map-base on the linker line. This informs the +# browser where to find the source files when debugging. +WASM_SOURCE_MAP_BASE = http://localhost:8000/ +!isEmpty(QMAKE_WASM_SOURCE_MAP_BASE):\ + WASM_SOURCE_MAP_BASE = $$QMAKE_WASM_SOURCE_MAP_BASE +CONFIG(debug): QMAKE_LFLAGS += --source-map-base $$WASM_SOURCE_MAP_BASE + # Creates the stand-alone version of the library from bitcode !static:contains(TEMPLATE, .*lib): { load(resolve_target) |