From 93d261b9650e3d1eb9347310fe8fc1f18e54e328 Mon Sep 17 00:00:00 2001 From: Lorn Potter Date: Mon, 26 Aug 2019 18:18:34 +1000 Subject: wasm: enforce emscripten version MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This creates a define in the binary, as well as writing emscripten version for qmake. It also enforces app builder to use a certain known version. Task-number: QTBUG-77745 Change-Id: I37691512171635cec66aa3ffa16258081f3f1e1b Reviewed-by: Morten Johan Sørvig Reviewed-by: Edward Welbourne --- configure.json | 4 ++++ configure.pri | 20 ++++++++++++++++++++ mkspecs/features/wasm/default_pre.prf | 25 +++++++++++++++++++++++++ mkspecs/features/wasm/wasm.prf | 5 +++++ 4 files changed, 54 insertions(+) create mode 100644 mkspecs/features/wasm/default_pre.prf diff --git a/configure.json b/configure.json index 159fdf12fa..23ef7625a6 100644 --- a/configure.json +++ b/configure.json @@ -1453,6 +1453,10 @@ Configure with '-qreal float' to create a build that is binary-compatible with 5 "type": "error", "condition": "!features.stl", "message": "Qt requires a compliant STL library." + }, + { + "type": "emccVersion", + "condition": "config.wasm" } ], diff --git a/configure.pri b/configure.pri index 2b8d20d607..557b8c2809 100644 --- a/configure.pri +++ b/configure.pri @@ -1224,6 +1224,12 @@ defineReplace(qtConfOutputPostProcess_publicPro) { "QT_RELEASE_DATE = $$config.input.qt_release_date" } + wasm: { + qt_emcc_version = $$qtSystemEmccVersion() + output += \ + "QT_EMCC_VERSION = $$qt_emcc_version" + } + return($$output) } @@ -1256,6 +1262,12 @@ defineReplace(qtConfOutputPostProcess_publicHeader) { !isEmpty(config.input.qt_libinfix): \ output += "$${LITERAL_HASH}define QT_LIBINFIX \"$$eval(config.input.qt_libinfix)\"" + wasm: { + qt_emcc_version = $$qtSystemEmccVersion() +output += \ + "$${LITERAL_HASH}define QT_EMCC_VERSION \"$$qt_emcc_version\"" + } + return($$output) } @@ -1338,6 +1350,14 @@ defineTest(qtConfReport_buildMode) { qtConfReportPadded($$1, $$build_mode) } +defineTest(qtConfReport_emccVersion) { + EMCC_VERSION = $$qtSystemEmccVersion() + REQ_VERSION = $$qtEmccRecommendedVersion() + !equals(EMCC_VERSION, $$REQ_VERSION) { + qtConfAddReport("You should use the recommended Emscripten version $$REQ_VERSION with this Qt. You have $$EMCC_VERSION $$QT_EMCC_VERSION") + } +} + # ensure pristine environment for configuration discard_from($$[QT_HOST_DATA/get]/mkspecs/qconfig.pri) discard_from($$[QT_HOST_DATA/get]/mkspecs/qmodule.pri) diff --git a/mkspecs/features/wasm/default_pre.prf b/mkspecs/features/wasm/default_pre.prf new file mode 100644 index 0000000000..982ef0498f --- /dev/null +++ b/mkspecs/features/wasm/default_pre.prf @@ -0,0 +1,25 @@ +load(default_pre) + +defineReplace(qtEmccRecommendedVersion) { + return (1.38.27) +} + +defineReplace(qtSystemEmccVersion) { + E_VERSION = $$system("emcc -v 2>&1 | perl -alne $$shell_quote($_ = $F[9]; s/://; print;) ") + return ($${E_VERSION}) +} + +defineTest(qtConfTest_emccVersion) { + + REQ_VERSION = $$qtEmccRecommendedVersion() + EMCC_VERSION = $$qtSystemEmccVersion() + + !defined(QT_EMCC_VERSION, var):!equals(EMCC_VERSION, $${REQ_VERSION}) { + warning ("You should use the recommended Emscripten version $$REQ_VERSION with this Qt. You have $${EMCC_VERSION} ") + } + contains(TEMPLATE, .*app) { + !equals(QT_EMCC_VERSION, $$EMCC_VERSION) { + warning("This Qt was built with Emscripten version $${QT_EMCC_VERSION}. You have $${EMCC_VERSION}. The difference may cause issues.") + } + } +} diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 5773e58010..2e886fc4a5 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -1,8 +1,11 @@ + # 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) { +## this may be subject to change + qtConfig(thread) { EMCC_THREAD_LFLAGS += -s USE_PTHREADS=1 @@ -109,6 +112,8 @@ contains(TEMPLATE, .*app) { } } +qtConfTest_emccVersion() + # 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/ -- cgit v1.2.3