From 44d3d879309505426a663c3ebee12934ac4e4fce Mon Sep 17 00:00:00 2001 From: Mikolaj Boc Date: Tue, 25 Jul 2023 14:01:09 +0200 Subject: [PATCH] Use a sanitized JS export name for WASM modules (qmake) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previously, a target name with a JS special character (like, -, for example), would lead to an invalid export name being generated for WASM modules. Sanitize these by replacing any non-alphanumeric character with underscores, as is done for feature names. This is a qmake version of 58a47edda15fe365220f8502ad42a7bd09bf83b7 Fixes: QTBUG-115506 Change-Id: I7c84076be54da91cf0f707c1613afc382acdcb83 Reviewed-by: Lorn Potter Reviewed-by: Piotr WierciƄski --- mkspecs/features/wasm/wasm.prf | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/wasm/wasm.prf b/mkspecs/features/wasm/wasm.prf index 72007fe863..71206ab8cd 100644 --- a/mkspecs/features/wasm/wasm.prf +++ b/mkspecs/features/wasm/wasm.prf @@ -18,8 +18,10 @@ exists($$QMAKE_QT_CONFIG) { !isEmpty(QT_WASM_EXPORT_NAME): { EXPORT_NAME = $$QT_WASM_EXPORT_NAME } else { - EXPORT_NAME = $${TARGET}_entry + TARGET_SANITIZED = $$replace(TARGET, [^a-zA-Z0-9_], _) + EXPORT_NAME = $${TARGET_SANITIZED}_entry } + EMCC_LFLAGS += -s EXPORT_NAME=$$EXPORT_NAME qtConfig(thread) { @@ -103,7 +105,7 @@ contains(TEMPLATE, .*app) { # replacing the app name placeholder with the actual app name. apphtml.name = application main html file apphtml.output = $$DESTDIR/$$TARGET_HTML - apphtml.commands = $$QMAKE_STREAM_EDITOR -e s/@APPNAME@/$$TARGET_BASE/g $$WASM_PLUGIN_PATH/wasm_shell.html > $$DESTDIR/$$TARGET_HTML + apphtml.commands = $$QMAKE_STREAM_EDITOR -e s/@APPNAME@/$$TARGET_BASE/g -e s/@APPEXPORTNAME@/$$EXPORT_NAME/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