summaryrefslogtreecommitdiffstats
path: root/cmake/QtWasmHelpers.cmake
Commit message (Collapse)AuthorAgeFilesLines
* wasm: use simpler syntax for EXPORTED_RUNTIME_METHODSMorten Sørvig2022-07-061-1/+1
| | | | | | | | | Recents emsdk versions support specifying the method list without using brackets. Switch to this syntax since that avoids any quoting issues. Pick-to: 6.4 Change-Id: Ib7bf8ec3f0d2ef67e8222a23e7af9b368ee99a00 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: Optimize use of openglesLorn Potter2022-06-221-11/+1
| | | | | | | | | | | | | | - USE_WEBGL2 is depreciated, Emscripten now uses MAX_WEBGL_VERSION - Optimize and remove use of emulated ES2 and ES3, which means only use WebGL friendly subset. Users can add USE_ES3=1 and USE_ES2=1 to the final linker arguments for those respective versions in order to enable using glDrawArrays and glDrawElements with unbound buffers. See https://emscripten.org/docs/porting/multimedia_and_graphics/OpenGL-support.html Pick-to: 6.4 Change-Id: I11ae359966964b3e7aa6e61ccc714c2bfbf61f96 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: Replace depreciated --embind compiler argumentLorn Potter2022-06-021-1/+2
| | | | | | | | As of Emscripten 3.1.3, the --embind compiler argment has been depreciated for -lembind Change-Id: Iac5bc21602f27fda7c1ea6814a1c9525b9a5afab Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: don't enable specialHTMLTargets by defaultMorten Sørvig2022-06-011-1/+1
| | | | | | | | | | | | | | | | | | Adding specialHTMLTargets to EXPORTED_RUNTIME_METHODS carries the obligation to actually use it as well; failing to do so makes Emscripten stop with a reference error on startup. However, we can't guarantee that Qt will use it in all cases. The current usage depends on QGuiApplication being used. Application code could be using QCoreApplication, or no application object at all. Detect if specialHTMLTargets is present instead, and then enable the code paths which uses it if that's the case. This means that apps which want to use e.g. multiple browser windows can opt into support by making sure EXPORTED_RUNTIME_METHODS contains specialHTMLTargets. Change-Id: I81105aa01946602fcf593f170e305d7dc9bad3be Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: enable WASM_BIGINTMorten Sørvig2022-05-121-1/+2
| | | | | | | | | | | | | | | | | | | JavaScripts's BigInt feature provides support for arbitrary-precision integers. This makes it possible to represent 64-bit integers; the standard JS Number type supports 32-bit integers only (or more accurately 53-bit integers - see Number.MAX_SAFE_INTEGER). Enable WASM_BIGINT which makes Emscripten map int64_t and uint64_t to BigInt when interfacing with JavaScript code. This removes one of the conditions which enables wasm-emscripten-finalize. Task-number: QTBUG-103352 Change-Id: Ia70d599daaf34c92695f5a2b61665e0c237e6b95 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com> Reviewed-by: David Skoland <david.skoland@qt.io>
* wasm: set ASSERTIONS level to default (1)Morten Sørvig2022-05-121-1/+0
| | | | | | | | | | This removes one of the conditions which enables wasm-emscripten-finalize. Task-number: QTBUG-103352 Change-Id: Id05db4b081dec360cdad2e611622e5baf09aeb23 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* wasm: add specialHTMLTargets to EXPORTED_RUNTIME_METHODS for qmakeLorn Potter2022-04-211-0/+1
| | | | | | | | | | | The change 0ec75f4b9932a65f9ec7ec79eb6f2e04691cea3f missed adding specialHTMLTargets for qmake Also add warning to keep QtWasmHelpers in sync with qmake.conf Change-Id: Idb363e77f0cecb4f125d3cb4f7507899149a3bac Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: use emscripten::val for specialHTMLTargetsLorn Potter2022-04-151-1/+1
| | | | | | | | | | | We need to add specialHTMLTargets to EXPORTED_RUNTIME_METHODS in order to use it, as Emscripten does not export it. Also, EM_ASM is not allowed for SIDE_MODULES, so it's better to use emscripten::val methods. Change-Id: I9b352ac98e2a961157f5bb36456bec3e35891270 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: remove SAFE_HEAP=1Morten Sørvig2022-04-131-1/+0
| | | | | | | | This adds significant run-time overhead and should not be on by default. Pick-to: 6.3 Change-Id: I33d312e31bd714f696d8acf2066eb4b285ff04af Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Disable SAFE_HEAP_LOG for wasmDavid Skoland2022-03-251-1/+0
| | | | | | | | | | This option completely ruins the output when running test, as it logs every single safe heap operation. I don't think this detailed logging is necessary or reasonable in a normal debug build. Pick-to: 6.3 Change-Id: I4bb740299d631d21453f9b4a8959634801fb3a1e Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: enable mobile native keyboardingLorn Potter2022-03-031-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | This works on iOS and Android, and Windows with touchscreen. On Android, we need to listen to the input event of a hidden text element and synthesize Qt keyboard events from that in order to get input events into Qt. On Windows, we need to be more creative about bringing the native virtual keyboard up. Because the entire canvas is contenteditable, we need to specify the inputmode is set to 'none', otherwise the v keyboard pops up when user clicks anywhere on the canvas. Therefore we set a hidden element as contenteditable, which pops up keyboard when Qt needs it for editable widgets. On Android, this is the same element that is used to proxy the keyboard input. [ChangeLog][wasm] Add support for native mobile keyboard Done-with: Morten Johan Sørvig <morten.sorvig@qt.io> Fixes: QTBUG-83064 Fixes: QTBUG-88803 Change-Id: I769fe344fc10c17971bd1c0a603501040fe82653 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: move user configurable settingsLorn Potter2022-02-231-25/+0
| | | | | | | | | | | Both INITIAL_MEMORY and PTHREAD_POOL_SIZE are settings users can change, they are not interface settings. Fixes: QTBUG-100693 Pick-to: 6.3 6.2 Change-Id: Ie1547c7f52c9fe109a313260616705728024b6b8 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io> Reviewed-by: David Skoland <david.skoland@qt.io>
* wasm: modernize pthreads optionMorten Johan Sørvig2022-01-171-2/+2
| | | | | | | | | | | Use “-pthreads” instead of “-s USE_PTHREADS=1”. This is both a compile and linker option. Pick-to: 6.3 Change-Id: Iaf7cb4ec41577fe596c3e81fda05c03fe0074c08 Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: remove deprecated argument for source mapsLorn Potter2021-12-131-1/+1
| | | | | | | | | -g4 was deprecated in Emscripten 2.0.17, and since we are well past that version we can safely use -gsource-map instead. Change-Id: I497155619d6320661f6be0e220b52fa7d6ca0b8e Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: remove duplicate “--bind” optionMorten Johan Sørvig2021-11-191-2/+0
| | | | | | | | | Not a compile option, and also added to the linker options above. Change-Id: Iab2107d4b5ee4bc73e85b3cd5070f1a96b3a5a3b Reviewed-by: David Skoland <david.skoland@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: increase default initial memoryLorn Potter2021-11-041-2/+6
| | | | | | | | | | | | | | | | Some apps may need more initial memory when linking, emscripten will fail with: wasm-ld: error: initial memory too small This increases the default initial memory form 16MB to 20MB. Larger apps might still get this error, in which case QT_WASM_INITIAL_MEMORY can be set. Pick-to: 6.2 Fixes: QTBUG-97457 Change-Id: Icdc56c41fb3a3852a9a83f7a3dc15820e83e1148 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: enable event dispatcher asyncify supportMorten Johan Sørvig2021-11-041-1/+1
| | | | | | | | | | | | | | | | | | | | | Misc. fixes, including: Fix a couple of typos in the JavaScript code. Also, macros- within-macros don’t work, (without resorting to preprocessor token pasting), so remove the debug output for now. Limit the exec() “simulateInfiniteLoop” workaround to top-level application exec() only. This way, asyncify can be used for nested QEventLoop::exec() calls. (Emscripten supports one level of suspend only, so we don’t want to use that for the top-level exec(), but instead use it for dialogs and such). Use the new QEventLoop::ProcessEventsFlag::ApplicationExec enum value to detect the exec() call type. Change-Id: Ic702bfc31faf2e9f84ac5d3ccf43d067c5c61bf0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* Rename variable for exported functionsDavid Skoland2021-10-131-1/+1
| | | | | | | | Emscripten complains that this variable is deprecated and should be replaced with the one given in this patch. Change-Id: Iafee06fcb1f292de25570545d74d7327679461b0 Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: add simd supportLorn Potter2021-10-051-0/+5
| | | | | | | | | | | | | | | | | | Emscripten only supports SSE1, SSE2, SSE3, SSSE3, SSE4.1, SSE4.2, and 128-bit AVX instruction sets at this time. https://emscripten.org/docs/porting/simd.html Browsers might need to enable simd support in the advanced configurations about: config or chrome:flags Enable by configuring Qt with -sse2 Pick-to: 6.2 Fixes: QTBUG-63924 Change-Id: Ifeafae20e199dee0d19689802ad20fd0bd424ca7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: don’t set exit_runtimeMorten Sørvig2021-06-231-1/+1
| | | | | | | | | | | | | | | | | | Go with Emscripten’s default of not shutting down on main() exit; this allows for writing main() in such a way that avoids the exec() workaround. Existing main() implementations (which do use the exec() workaround) do not shut down Qt cleanly anyway, so we gain little by shutting down the Emscripten runtime. Applications can set this flag if they do want to shut down on main() exit: LFAGS += -s EXIT_RUNTIME=1 Change-Id: I52e1cc2bc907d1d2146822713e39b7610db3f95b Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io> Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
* wasm: enable MODULARIZE option and set EXPORT_NAMEMorten Sørvig2021-06-221-0/+10
| | | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* wasm: fix build for emscripten 2.0.14Lorn Potter2021-06-211-1/+1
| | | | | | | | new syntax rules for EXTRA_EXPORTED_RUNTIME_METHODS valid after 2.0.16 Pick-to: 6.2 Change-Id: Iff33e4c6f3176619fb35ec0994a7cc87b5d937c7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: fix threaded buildsLorn Potter2021-06-081-2/+4
| | | | | | | set the thread pool size default to 4 Change-Id: I038a81610c82ac4d162c044d0e1f58196cffc7b7 Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
* wasm: fix cmake syntax for emscriptenLorn Potter2021-05-271-4/+4
| | | | | | | | | | | fix debugging demangler Emscripten apparently does not like the quotes in the compiler argument and remove array syntax Change-Id: I66652f6bdc5872faf540a877ca01bf75dde47bbb Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io> Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
* wasm: make sure bind is compiler argumentLorn Potter2021-05-141-0/+1
| | | | | | Fixes: QTBUG-93713 Change-Id: I027caccb5c37bab529c80efac0b575a363be5f89 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
* wasm: add cmake build supportLorn Potter2021-04-011-0/+92
A few configure defines get changed: QMAKE_WASM_PTHREAD_POOL_SIZE is now QT_WASM_PTHREAD_POOL_SIZE QMAKE_WASM_TOTAL_MEMORY is now QT_WASM_INITIAL_MEMORY QMAKE_WASM_SOURCE_MAP_BASE is now QT_WASM_SOURCE_MAP_BASE device-option EMSCRIPTEN_ASYNCIFY=1 is QT_EMSCRIPTEN_ASYNCIFY=1 To create source maps for debugging. use device-option QT_WASM_SOURCE_MAP=1 Task-number: QTBUG-78647 Change-Id: If9f30cd7fb408c386d6d69b5f7b1beecf1ab44b5 Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>