2018-06-01 13:13:30 +00:00
|
|
|
|
2021-10-26 14:03:43 +00:00
|
|
|
QT_FOR_CONFIG += core-private
|
2019-08-26 08:18:34 +00:00
|
|
|
|
2018-06-01 13:13:30 +00:00
|
|
|
# DESTDIR will be empty if not set in the app .pro file; make sure it has a value
|
|
|
|
isEmpty(DESTDIR): DESTDIR = $$OUT_PWD
|
|
|
|
|
2018-03-20 12:30:53 +00:00
|
|
|
exists($$QMAKE_QT_CONFIG) {
|
2019-08-26 08:18:34 +00:00
|
|
|
## this may be subject to change
|
|
|
|
|
2018-03-20 12:30:53 +00:00
|
|
|
qtConfig(thread) {
|
|
|
|
|
2021-11-23 08:50:41 +00:00
|
|
|
EMCC_LFLAGS += -pthread
|
|
|
|
EMCC_CFLAGS += -pthread
|
2018-03-20 12:30:53 +00:00
|
|
|
|
|
|
|
# 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
|
2020-09-03 08:29:41 +00:00
|
|
|
!isEmpty(QT_WASM_PTHREAD_POOL_SIZE) {
|
|
|
|
POOL_SIZE = $$QT_WASM_PTHREAD_POOL_SIZE
|
2018-03-20 12:30:53 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
message("Setting PTHREAD_POOL_SIZE to" $$POOL_SIZE)
|
2021-11-23 08:50:41 +00:00
|
|
|
EMCC_LFLAGS += -s PTHREAD_POOL_SIZE=$$POOL_SIZE
|
2018-03-20 12:30:53 +00:00
|
|
|
} else {
|
2021-11-23 08:50:41 +00:00
|
|
|
EMCC_LFLAGS += -s ALLOW_MEMORY_GROWTH=1
|
2018-03-20 12:30:53 +00:00
|
|
|
}
|
2019-06-19 05:54:48 +00:00
|
|
|
|
2021-11-23 08:50:41 +00:00
|
|
|
isEmpty(QT_WASM_INITIAL_MEMORY) {
|
|
|
|
# Hardcode wasm memory size.
|
2019-06-19 05:54:48 +00:00
|
|
|
|
2021-11-23 08:50:41 +00:00
|
|
|
qtConfig(thread) {
|
|
|
|
# Pthreads and ALLOW_MEMORY_GROWTH can cause javascript wasm memory access to
|
|
|
|
# be slow. Instead, we specify the memory size
|
|
|
|
# at build time. Further, browsers limit the maximum initial memory size to 1GB.
|
|
|
|
# https://github.com/WebAssembly/design/issues/1271
|
2020-09-03 08:29:41 +00:00
|
|
|
INITIAL_MEMORY = 1GB
|
2021-11-23 08:50:41 +00:00
|
|
|
} else {
|
|
|
|
INITIAL_MEMORY = 50MB # emscripten default is 16MB, we need slightly more
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
# QT_WASM_INITIAL_MEMORY must be a multiple of 64KB (i.e. 65536)
|
|
|
|
INITIAL_MEMORY = $$QT_WASM_INITIAL_MEMORY
|
|
|
|
message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY)
|
2019-06-19 05:54:48 +00:00
|
|
|
}
|
2021-11-23 08:50:41 +00:00
|
|
|
EMCC_LFLAGS += -s INITIAL_MEMORY=$$INITIAL_MEMORY
|
|
|
|
message("Setting INITIAL_MEMORY to" $$INITIAL_MEMORY)
|
2021-04-16 05:34:57 +00:00
|
|
|
|
2021-10-26 14:03:43 +00:00
|
|
|
qtConfig(sse2) {
|
|
|
|
QMAKE_CFLAGS += -O2 -msimd128 -msse -msse2
|
|
|
|
QMAKE_CXXFLAGS += -O2 -msimd128 -msse -msse2
|
|
|
|
QMAKE_LFLAGS += -msimd128 -msse -msse2
|
|
|
|
QMAKE_LFLAGS_DEBUG += -msimd128 -msse -msse2
|
|
|
|
}
|
|
|
|
|
2021-11-23 08:50:41 +00:00
|
|
|
QMAKE_LFLAGS += $$EMCC_LFLAGS
|
|
|
|
QMAKE_LFLAGS_DEBUG += $$EMCC_LFLAGS
|
|
|
|
QMAKE_CFLAGS += $$EMCC_CFLAGS
|
|
|
|
QMAKE_CXXFLAGS += $$EMCC_CFLAGS
|
2018-03-20 12:30:53 +00:00
|
|
|
}
|
|
|
|
|
2018-06-01 13:13:30 +00:00
|
|
|
# Create js and wasm files for applications
|
|
|
|
contains(TEMPLATE, .*app) {
|
|
|
|
TARGET_BASE = $${TARGET}
|
|
|
|
TARGET_HTML = $${TARGET}.html
|
|
|
|
TARGET_JS = $${TARGET}.js
|
|
|
|
|
|
|
|
# Make the emscripten compiler generate a js file
|
|
|
|
TARGET = $$TARGET_JS
|
|
|
|
|
|
|
|
QMAKE_INCDIR += $$(HOME)/.emscripten_ports/openssl/include
|
|
|
|
|
|
|
|
CONFIG += static
|
|
|
|
js_file.files = $$TARGET_JS
|
|
|
|
js_file.path = $$target.path
|
|
|
|
isEmpty(js_file.path): \
|
|
|
|
js_file.path += ./
|
|
|
|
INSTALLS += js_file
|
|
|
|
|
|
|
|
# Copy hosting html and javascript to the application build directory.
|
|
|
|
exists($$[QT_INSTALL_PLUGINS]/platforms/wasm_shell.html) {
|
|
|
|
# don't pass this until it's installed somewhere
|
|
|
|
# otherwise makespec test fails during qt configure
|
|
|
|
WASM_PLUGIN_PATH = $$[QT_INSTALL_PLUGINS]/platforms
|
|
|
|
} else {
|
|
|
|
## internal build. not installed
|
|
|
|
WASM_PLUGIN_PATH = $$PWD/../../../src/plugins/platforms/wasm
|
|
|
|
}
|
|
|
|
|
|
|
|
# Copy/Generate main .html file (e.g. myapp.html) from the webassembly_shell.html by
|
|
|
|
# replacing the app name placeholder with the actual app name.
|
|
|
|
apphtml.name = application main html file
|
|
|
|
apphtml.output = $$DESTDIR/$$TARGET_HTML
|
2019-11-18 11:35:17 +00:00
|
|
|
apphtml.commands = $$QMAKE_STREAM_EDITOR -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML
|
2018-06-01 13:13:30 +00:00
|
|
|
apphtml.input = $$WASM_PLUGIN_PATH/wasm_shell.html
|
|
|
|
apphtml.depends = $$apphtml.input
|
|
|
|
QMAKE_EXTRA_COMPILERS += apphtml
|
|
|
|
|
|
|
|
appjs.name = application qtloader.js
|
|
|
|
appjs.output = $$DESTDIR/qtloader.js
|
2018-11-23 13:22:03 +00:00
|
|
|
appjs.commands = $$QMAKE_COPY $$shell_path($$WASM_PLUGIN_PATH/qtloader.js) $$shell_path($$DESTDIR)
|
2018-06-01 13:13:30 +00:00
|
|
|
appjs.input = $$WASM_PLUGIN_PATH/qtloader.js
|
|
|
|
appjs.depends = $$appjs.input
|
|
|
|
QMAKE_EXTRA_COMPILERS += appjs
|
|
|
|
|
|
|
|
appsvg.name = application qtlogo.svg
|
|
|
|
appsvg.output = $$DESTDIR/qtlogo.svg
|
2018-11-23 13:22:03 +00:00
|
|
|
appsvg.commands = $$QMAKE_COPY $$shell_path($$WASM_PLUGIN_PATH/qtlogo.svg) $$shell_path($$DESTDIR)
|
2018-06-01 13:13:30 +00:00
|
|
|
appsvg.input = $$WASM_PLUGIN_PATH/qtlogo.svg
|
|
|
|
appsvg.depends = $$appsvg.input
|
|
|
|
QMAKE_EXTRA_COMPILERS += appsvg
|
|
|
|
|
|
|
|
QMAKE_EXTRA_TARGETS += apphtml appjs appsvg
|
|
|
|
POST_TARGETDEPS += apphtml appjs appsvg
|
|
|
|
|
|
|
|
# Add manual target to make "make -B shellfiles" work.
|
|
|
|
shellfiles.target = shellfiles
|
|
|
|
shellfiles.depends = apphtml appjs appsvg
|
|
|
|
QMAKE_EXTRA_TARGETS += shellfiles
|
|
|
|
|
|
|
|
# emscripten ports are linked into the main module (this app), not the Qt
|
|
|
|
# libs which reference them
|
|
|
|
qt {
|
|
|
|
qt_depends = $$resolve_depends(QT, "QT.")
|
|
|
|
contains(qt_depends, core(-private)?): QMAKE_LFLAGS += \
|
|
|
|
$$QMAKE_LIBS_THREAD $$QMAKE_LIBS_ZLIB
|
|
|
|
contains(qt_depends, gui(-private)?): QMAKE_LFLAGS += \
|
|
|
|
$$QMAKE_LIBS_FREETYPE $$QMAKE_LIBS_LIBPNG
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-08-26 08:18:34 +00:00
|
|
|
qtConfTest_emccVersion()
|
|
|
|
|
2021-04-26 09:00:39 +00:00
|
|
|
CONFIG(debug):!isEmpty(QT_WASM_SOURCE_MAP) {
|
|
|
|
|
|
|
|
EMCC_VERSION = $$qtSystemEmccVersion()
|
|
|
|
|
2021-11-18 00:29:46 +00:00
|
|
|
QMAKE_LFLAGS += -gsource-map
|
2021-04-26 09:00:39 +00:00
|
|
|
# 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(QT_WASM_SOURCE_MAP_BASE):\
|
|
|
|
WASM_SOURCE_MAP_BASE = $$QT_WASM_SOURCE_MAP_BASE
|
|
|
|
QMAKE_LFLAGS += --source-map-base $$WASM_SOURCE_MAP_BASE
|
|
|
|
}
|
|
|
|
|
2018-11-27 21:02:07 +00:00
|
|
|
|
2018-06-01 13:13:30 +00:00
|
|
|
# Creates the stand-alone version of the library from bitcode
|
|
|
|
!static:contains(TEMPLATE, .*lib): {
|
|
|
|
load(resolve_target)
|
|
|
|
QMAKE_POST_LINK += $$QMAKE_LINK_SHLIB $$QMAKE_RESOLVED_TARGET -o $${QMAKE_RESOLVED_TARGET}.js
|
|
|
|
|
|
|
|
QMAKE_INCDIR += $$(HOME)/.emscripten_ports/openssl/include
|
|
|
|
}
|