ecb92aacab
Add QEventDispatcherWasm to QtCore. The event dispatcher supports managing event queue wakeups and timers, both for the main thread or for secondary threads. Blocking in processEvents() (using QEventLoop::WaitForMoreEvents) is supported when running on a secondary thread, or on the main thread when Qt is built with Emscripten’s asyncify support. Code is shared for all both modes as far as possible, with breakout functions which handle main and secondary thread as well as asyncify specifics,. Some functions like wakeUp() can be called from any thread, and needs to take the calling thread into consideration as well. The current asyncify implementation in Emscripten is restricted to one level of suspend, and this restriction carries over to Qt as well. In practice this means we support one level of exec()-like API. Note that this commit does not _enable_ use of the new event dispatcher. This will be done in separate commits. Task-number: QTBUG-76007 Task-number: QTBUG-64020 Change-Id: I77dc9ba34bcff59ef05dd23a46dbf1873cbe6780 Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
98 lines
3.1 KiB
Plaintext
98 lines
3.1 KiB
Plaintext
# qmake configuration for building with emscripten
|
|
MAKEFILE_GENERATOR = UNIX
|
|
QMAKE_PLATFORM = wasm unix
|
|
|
|
include(../common/gcc-base.conf)
|
|
include(../common/clang.conf)
|
|
|
|
load(device_config)
|
|
load(emcc_ver)
|
|
|
|
# Support enabling asyncify by configuring with "-device-option QT_EMSCRIPTEN_ASYNCIFY=1"
|
|
!isEmpty(QT_EMSCRIPTEN_ASYNCIFY): {
|
|
!equals(QT_EMSCRIPTEN_ASYNCIFY, 1):!equals(QT_EMSCRIPTEN_ASYNCIFY, 0): \
|
|
message(Error: The value for QT_EMSCRIPTEN_ASYNCIFY must be 0 or 1)
|
|
equals(QT_EMSCRIPTEN_ASYNCIFY, 1): {
|
|
QMAKE_CFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
|
|
QMAKE_CXXFLAGS += -DQT_HAVE_EMSCRIPTEN_ASYNCIFY
|
|
QMAKE_LFLAGS += -s ASYNCIFY
|
|
|
|
# Emscripten recommends building with optimizations when using asyncify
|
|
# in order to reduce wasm file size, and may also generate broken wasm
|
|
# (with "wasm validation error: too many locals" type errors) if optimizations
|
|
# are omitted. Enable optimizations also for debug builds.
|
|
QMAKE_LFLAGS_DEBUG += -Os
|
|
|
|
# Declare all async functions
|
|
QMAKE_LFLAGS += -s \'ASYNCIFY_IMPORTS=[\"qt_asyncify_suspend_js\", \"qt_asyncify_resume_js\", \"emscripten_sleep\"]\'
|
|
}
|
|
}
|
|
|
|
EMTERP_FLAGS = \
|
|
-s EMTERPRETIFY=1 \
|
|
-s EMTERPRETIFY_ASYNC=1 \
|
|
-s \"EMTERPRETIFY_FILE=\'data.binary\'\" \
|
|
-s ASSERTIONS=1 \
|
|
--profiling-funcs
|
|
|
|
EMCC_COMMON_LFLAGS += \
|
|
-s WASM=1 \
|
|
-s FULL_ES2=1 \
|
|
-s FULL_ES3=1 \
|
|
-s USE_WEBGL2=1 \
|
|
-s ERROR_ON_UNDEFINED_SYMBOLS=1 \
|
|
-s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] \
|
|
--bind \
|
|
-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.
|
|
EMCC_COMMON_LFLAGS_DEBUG = \
|
|
$$EMCC_COMMON_LFLAGS \
|
|
-s ASSERTIONS=2 \
|
|
-s DEMANGLE_SUPPORT=1 \
|
|
# -s LIBRARY_DEBUG=1 \ #print out library calls, verbose
|
|
# -s SYSCALL_DEBUG=1 \ #print out sys calls, verbose
|
|
# -s FS_LOG=1 \ #print out filesystem ops, verbose
|
|
# -s SOCKET_DEBUG \ #print out socket,network data transfer
|
|
-s GL_DEBUG=1 \
|
|
--profiling-funcs
|
|
|
|
QMAKE_LFLAGS_DEBUG += -g2
|
|
QMAKE_LFLAGS_RELEASE += -O2
|
|
|
|
QMAKE_COMPILER += emscripten
|
|
|
|
QMAKE_CC = emcc
|
|
QMAKE_CXX = em++
|
|
|
|
QMAKE_LINK = $$QMAKE_CXX
|
|
QMAKE_LINK_SHLIB = $$QMAKE_CXX
|
|
QMAKE_LINK_C = $$QMAKE_CC
|
|
QMAKE_LINK_C_SHLIB = $$QMAKE_CC
|
|
|
|
QMAKE_LIBS_THREAD = $$QMAKE_CFLAGS_THREAD
|
|
|
|
QMAKE_LFLAGS += $$EMCC_COMMON_LFLAGS
|
|
QMAKE_LFLAGS_DEBUG += $$EMCC_COMMON_LFLAGS_DEBUG
|
|
|
|
QMAKE_PREFIX_SHLIB = lib
|
|
QMAKE_EXTENSION_SHLIB = so # llvm bitcode, linked to js in post_link
|
|
QMAKE_PREFIX_STATICLIB = lib
|
|
QMAKE_EXTENSION_STATICLIB = a # llvm bitcode
|
|
|
|
QMAKE_AR = emar cqs
|
|
equals(QMAKE_HOST.os, Windows) {
|
|
QMAKE_LINK_OBJECT_MAX = 10
|
|
QMAKE_LINK_OBJECT_SCRIPT = object_script
|
|
QMAKE_AR_CMD = \
|
|
"$(file >$(OBJECTS_DIR)/$(TARGET).rsp, $(subst \\,/,$(OBJECTS)))$$escape_expand(\\n\\t)" \
|
|
"$(AR) $(DESTDIR)$(TARGET) @$(OBJECTS_DIR)/$(TARGET).rsp"
|
|
}
|
|
|
|
QMAKE_DISTCLEAN += *.html *.js *.wasm
|
|
|
|
load(qt_config)
|