Skip to content

Commit

Permalink
Use a sanitized JS export name for WASM modules (qmake)
Browse files Browse the repository at this point in the history
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 58a47ed

Fixes: QTBUG-115506
Change-Id: I7c84076be54da91cf0f707c1613afc382acdcb83
Reviewed-by: Lorn Potter <[email protected]>
Reviewed-by: Piotr Wierciński <[email protected]>
  • Loading branch information
mboc-qt committed Jul 27, 2023
1 parent ea0b7da commit 44d3d87
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mkspecs/features/wasm/wasm.prf
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 44d3d87

Please sign in to comment.