diff options
author | Morten Johan Sørvig <morten.sorvig@qt.io> | 2018-06-01 15:13:30 +0200 |
---|---|---|
committer | Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io> | 2018-08-30 06:48:33 +0000 |
commit | 29c0377f07f4942f9957ea87d59c252148dc9e5b (patch) | |
tree | cb79a59b6c47305ca024675cc1325ed0a6be8aac /mkspecs/features | |
parent | 707ae5b66774a2ed4713da3b8fa69c1d002c3beb (diff) |
WebAssembly for QtBase
This is the squashed diff from wip/webassembly to dev.
Done-with: Peng Wu <peng.wu@intopalo.com>
Done-with: Sami Enne <sami.enne@intopalo.com>
Done-with: Morten Johan Sørvig <morten.sorvig@qt.io>
Started-by: Andrew Knight <andrew.knight@intopalo.com>
Change-Id: I6562433c0a38d6ec49ab675e0f104f2665f3392d
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Diffstat (limited to 'mkspecs/features')
-rw-r--r-- | mkspecs/features/toolchain.prf | 4 | ||||
-rw-r--r-- | mkspecs/features/wasm/qt.prf | 12 | ||||
-rw-r--r-- | mkspecs/features/wasm/wasm.prf | 81 |
3 files changed, 96 insertions, 1 deletions
diff --git a/mkspecs/features/toolchain.prf b/mkspecs/features/toolchain.prf index bce3ef3954..4ecfb8d889 100644 --- a/mkspecs/features/toolchain.prf +++ b/mkspecs/features/toolchain.prf @@ -34,7 +34,9 @@ isEmpty($${target_prefix}.INCDIRS) { # # Get default include and library paths from compiler # - gcc { + wasm { + # wasm compiler does not work here, just use defaults + } else: gcc { cmd_suffix = "<$$QMAKE_SYSTEM_NULL_DEVICE >$$QMAKE_SYSTEM_NULL_DEVICE" equals(QMAKE_HOST.os, Windows): \ cmd_prefix = "set LC_ALL=C&" diff --git a/mkspecs/features/wasm/qt.prf b/mkspecs/features/wasm/qt.prf new file mode 100644 index 0000000000..9b9b58d3de --- /dev/null +++ b/mkspecs/features/wasm/qt.prf @@ -0,0 +1,12 @@ + +qt_depends = $$resolve_depends(QT, "QT.") +equals(TEMPLATE, app):contains(qt_depends, gui(-private)?) { + LIBS *= -L$$[QT_INSTALL_PLUGINS/get]/platforms + + lib_name = wasm + lib_path_and_base = $$[QT_INSTALL_PLUGINS/get]/platforms/lib$${lib_name}$$qtPlatformTargetSuffix() + LIBS += -l$${lib_name}$$qtPlatformTargetSuffix() $$fromfile($${lib_path_and_base}.prl, QMAKE_PRL_LIBS) +} + +load(qt) + diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf new file mode 100644 index 0000000000..278a6719c7 --- /dev/null +++ b/mkspecs/features/wasm/wasm.prf @@ -0,0 +1,81 @@ + +# DESTDIR will be empty if not set in the app .pro file; make sure it has a value +isEmpty(DESTDIR): DESTDIR = $$OUT_PWD + +# 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 + 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 + + appjs.name = application qtloader.js + appjs.output = $$DESTDIR/qtloader.js + appjs.commands = $$QMAKE_COPY $$WASM_PLUGIN_PATH/qtloader.js $$DESTDIR + 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 + appsvg.commands = $$QMAKE_COPY $$WASM_PLUGIN_PATH/qtlogo.svg $$DESTDIR + 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 + } +} + +# 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 +} |